Skip to content

Commit 27d5332

Browse files
lxindavem330
authored andcommitted
l2tp: remove skb_dst_set() from l2tp_xmit_skb()
In the tx path of l2tp, l2tp_xmit_skb() calls skb_dst_set() to set skb's dst. However, it will eventually call inet6_csk_xmit() or ip_queue_xmit() where skb's dst will be overwritten by: skb_dst_set_noref(skb, dst); without releasing the old dst in skb. Then it causes dst/dev refcnt leak: unregister_netdevice: waiting for eth0 to become free. Usage count = 1 This can be reproduced by simply running: # modprobe l2tp_eth && modprobe l2tp_ip # sh ./tools/testing/selftests/net/l2tp.sh So before going to inet6_csk_xmit() or ip_queue_xmit(), skb's dst should be dropped. This patch is to fix it by removing skb_dst_set() from l2tp_xmit_skb() and moving skb_dst_drop() into l2tp_xmit_core(). Fixes: 3557baa ("[L2TP]: PPP over L2TP driver core") Reported-by: Hangbin Liu <[email protected]> Signed-off-by: Xin Long <[email protected]> Acked-by: James Chapman <[email protected]> Tested-by: James Chapman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1412bb2 commit 27d5332

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

net/l2tp/l2tp_core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
10281028

10291029
/* Queue the packet to IP for output */
10301030
skb->ignore_df = 1;
1031+
skb_dst_drop(skb);
10311032
#if IS_ENABLED(CONFIG_IPV6)
10321033
if (l2tp_sk_is_v6(tunnel->sock))
10331034
error = inet6_csk_xmit(tunnel->sock, skb, NULL);
@@ -1099,10 +1100,6 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
10991100
goto out_unlock;
11001101
}
11011102

1102-
/* Get routing info from the tunnel socket */
1103-
skb_dst_drop(skb);
1104-
skb_dst_set(skb, sk_dst_check(sk, 0));
1105-
11061103
inet = inet_sk(sk);
11071104
fl = &inet->cork.fl;
11081105
switch (tunnel->encap) {

0 commit comments

Comments
 (0)