Skip to content

Commit 7de3330

Browse files
committed
Merge branch 'ipv4-Prevent-user-triggerable-warning'
Ido Schimmel says: ==================== net: ipv4: Prevent user triggerable warning Patch #1 prevents a user triaggerable warning in the flow dissector by setting 'skb->dev' in skbs used for IPv4 output route get requests. Patch #2 adds a test case that triggers the warning without the first patch. I have audited all the RTM_GETROUTE handlers and could not find any other callpath where an skb is passed to the flow dissector with both 'skb->dev' and 'skb->sk' cleared. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 639c1b2 + 676f4bb commit 7de3330

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

net/ipv4/route.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
28492849
err = -rt->dst.error;
28502850
} else {
28512851
fl4.flowi4_iif = LOOPBACK_IFINDEX;
2852+
skb->dev = net->loopback_dev;
28522853
rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb);
28532854
err = 0;
28542855
if (IS_ERR(rt))

tools/testing/selftests/net/rtnetlink.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ kci_test_polrouting()
205205

206206
kci_test_route_get()
207207
{
208+
local hash_policy=$(sysctl -n net.ipv4.fib_multipath_hash_policy)
209+
208210
ret=0
209211

210212
ip route get 127.0.0.1 > /dev/null
@@ -223,6 +225,19 @@ kci_test_route_get()
223225
check_err $?
224226
ip route get 10.23.7.11 from 10.23.7.12 iif "$devdummy" > /dev/null
225227
check_err $?
228+
ip route add 10.23.8.0/24 \
229+
nexthop via 10.23.7.13 dev "$devdummy" \
230+
nexthop via 10.23.7.14 dev "$devdummy"
231+
check_err $?
232+
sysctl -wq net.ipv4.fib_multipath_hash_policy=0
233+
ip route get 10.23.8.11 > /dev/null
234+
check_err $?
235+
sysctl -wq net.ipv4.fib_multipath_hash_policy=1
236+
ip route get 10.23.8.11 > /dev/null
237+
check_err $?
238+
sysctl -wq net.ipv4.fib_multipath_hash_policy="$hash_policy"
239+
ip route del 10.23.8.0/24
240+
check_err $?
226241
ip addr del dev "$devdummy" 10.23.7.11/24
227242
check_err $?
228243

0 commit comments

Comments
 (0)