Skip to content

Commit 8bcfd09

Browse files
Julian Anastasovdavem330
authored andcommitted
ipv4: add missing initialization for flowi4_uid
Avoid matching of random stack value for uid when rules are looked up on input route or when RP filter is used. Problem should affect only setups that use ip rules with uid range. Fixes: 622ec2c ("net: core: add UID to flows, rules, and routes") Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8118b7b commit 8bcfd09

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

net/ipv4/fib_frontend.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
319319
int ret, no_addr;
320320
struct fib_result res;
321321
struct flowi4 fl4;
322-
struct net *net;
322+
struct net *net = dev_net(dev);
323323
bool dev_match;
324324

325325
fl4.flowi4_oif = 0;
@@ -332,20 +332,20 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
332332
fl4.flowi4_scope = RT_SCOPE_UNIVERSE;
333333
fl4.flowi4_tun_key.tun_id = 0;
334334
fl4.flowi4_flags = 0;
335+
fl4.flowi4_uid = sock_net_uid(net, NULL);
335336

336337
no_addr = idev->ifa_list == NULL;
337338

338339
fl4.flowi4_mark = IN_DEV_SRC_VMARK(idev) ? skb->mark : 0;
339340

340341
trace_fib_validate_source(dev, &fl4);
341342

342-
net = dev_net(dev);
343343
if (fib_lookup(net, &fl4, &res, 0))
344344
goto last_resort;
345345
if (res.type != RTN_UNICAST &&
346346
(res.type != RTN_LOCAL || !IN_DEV_ACCEPT_LOCAL(idev)))
347347
goto e_inval;
348-
if (!rpf && !fib_num_tclassid_users(dev_net(dev)) &&
348+
if (!rpf && !fib_num_tclassid_users(net) &&
349349
(dev->ifindex != oif || !IN_DEV_TX_REDIRECTS(idev)))
350350
goto last_resort;
351351
fib_combine_itag(itag, &res);

net/ipv4/route.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
18761876
fl4.flowi4_flags = 0;
18771877
fl4.daddr = daddr;
18781878
fl4.saddr = saddr;
1879+
fl4.flowi4_uid = sock_net_uid(net, NULL);
18791880
err = fib_lookup(net, &fl4, &res, 0);
18801881
if (err != 0) {
18811882
if (!IN_DEV_FORWARD(in_dev))

0 commit comments

Comments
 (0)