Skip to content

Commit 8a2618e

Browse files
idoschkuba-moo
authored andcommitted
ipv4: Fix incorrect table ID in IOCTL path
Commit f96a3d7 ("ipv4: Fix incorrect route flushing when source address is deleted") started to take the table ID field in the FIB info structure into account when determining if two structures are identical or not. This field is initialized using the 'fc_table' field in the route configuration structure, which is not set when adding a route via IOCTL. The above can result in user space being able to install two identical routes that only differ in the table ID field of their associated FIB info. Fix by initializing the table ID field in the route configuration structure in the IOCTL path. Before the fix: # ip route add default via 192.0.2.2 # route add default gw 192.0.2.2 # ip -4 r show default # default via 192.0.2.2 dev dummy10 # default via 192.0.2.2 dev dummy10 After the fix: # ip route add default via 192.0.2.2 # route add default gw 192.0.2.2 SIOCADDRT: File exists # ip -4 r show default default via 192.0.2.2 dev dummy10 Audited the code paths to ensure there are no other paths that do not properly initialize the route configuration structure when installing a route. Fixes: 5a56a0b ("net: Don't delete routes in different VRFs") Fixes: f96a3d7 ("ipv4: Fix incorrect route flushing when source address is deleted") Reported-by: gaoxingwang <[email protected]> Link: https://lore.kernel.org/netdev/[email protected]/ Tested-by: gaoxingwang <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 84770d1 commit 8a2618e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/fib_frontend.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
576576
cfg->fc_scope = RT_SCOPE_UNIVERSE;
577577
}
578578

579+
if (!cfg->fc_table)
580+
cfg->fc_table = RT_TABLE_MAIN;
581+
579582
if (cmd == SIOCDELRT)
580583
return 0;
581584

0 commit comments

Comments
 (0)