DanielLavrushin 报告 b4 手动指定内核保留路由表可能中断上联网路
DanielLavrushin 报告,b4 set 可将 routing.table 手动设为内核保留的 253、254、255(default、main、local),现有 set 校验未拒绝这些表。他举例:将 routing.fwmark 设为 0x10、routing.table 设为 254 并经 wg0 路由,启用会替换 main 表默认路由,停用又删除该默认路由,使路由器失去上联路由。此风险限于手动固定保留表的配置;TUN 引擎的 queue.tun.route_table 已拒绝这些编号。他建议 set 同样拒绝保留表、警告并改由 b4 分配空闲表;这是问题报告与修复建议,尚非已发布修复。
作者原文@DanielLavrushinProblem
A set can pin
routing.tableto 253, 254 or 255, the kernel's default, main and local tables. b4 then installs the set's default route into that table, and on cleanup deletes from it.
routeResolveIDsreturns a pinned mark and table as they are once the mark passes its checks; the table gets no check at all (routing.go#L3370-L3371).- Config validation only resets a negative table to 0 (validation.go#L375-L377).
- The TUN engine's
queue.tun.route_tablealready refuses 253-255 and picks a free table instead (validation.go#L613-L616).Effect
With
routing.fwmark0x10 androuting.table254 on a set routed towg0:
- enabling the set runs
ip route replace default dev wg0 proto 155 table 254, so the router's own default route, and every connection that uses the main table, leaves throughwg0;- disabling the set deletes that default from the main table, and the router is left without an uplink route.
Measured
A throwaway test calling
routeResolveIDswithFWMark: 0x10:pinned table 253 -> mark 0x10 table 253 pinned table 254 -> mark 0x10 table 254 pinned table 255 -> mark 0x10 table 255Suggested direction
Refuse 253-255 for a set's pinned table the way
queue.tun.route_tabledoes: log a warning and let b4 assign a table. A test that pins each of the three and expects an assigned table.Found while reviewing #739.