netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu
@ 2019-02-16  0:58 wenxu
  2019-02-16 16:34 ` Alexei Starovoitov
  0 siblings, 1 reply; 4+ messages in thread
From: wenxu @ 2019-02-16  0:58 UTC (permalink / raw)
  To: davem, rong.a.chen, netdev; +Cc: sfr, lkp

From: wenxu <wenxu@ucloud.cn>

BUG report in selftests: bpf: test_tunnel.sh

Testing IPIP tunnel...
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
PGD 0 P4D 0
Oops: 0010 [#1] SMP PTI
CPU: 0 PID: 16822 Comm: ping Not tainted 5.0.0-rc3-00352-gc8b34e6 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
RIP: 0010:          (null)
Code: Bad RIP value.
RSP: 0018:ffffc9000104f9c8 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffffe8ffffc071a8 RCX: 0000000000000000
RDX: ffff888054e33000 RSI: ffff88807796f500 RDI: ffffe8ffffc07130
RBP: ffff88807796f500 R08: ffff88806da4f0a0 R09: 0000000000000000
R10: 0000000000000004 R11: ffff888054e33000 R12: 0000000000000054
R13: ffff88805e714000 R14: ffff88806da4f0a0 R15: 0000000000000000
FS:  00007f4c00431500(0000) GS:ffff88813fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 000000008276e000 CR4: 00000000000406f0
Call Trace:
 ? tnl_update_pmtu+0x21b/0x250 [ip_tunnel]
 ? ip_md_tunnel_xmit+0x1b7/0xdc0 [ip_tunnel]
 ? ipip_tunnel_xmit+0x90/0xc0 [ipip]
 ? dev_hard_start_xmit+0x98/0x210
 ? __dev_queue_xmit+0x6a9/0x8e0

The bpf program set tunnel_key through bpf_skb_set_tunnel_key which will
drop the old dst_entry and create a DST_METADATA dst_entry. It will lead
the tunnel_update_pmtu operator the dst_entry incorrect. So It should be
check the dst_entry is valid.

Fixes: c8b34e680a09 ("ip_tunnel: Add tnl_update_pmtu in ip_md_tunnel_xmit")
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 net/ipv4/ip_tunnel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 893f013..a665f11 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -515,7 +515,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
 		mtu = dst_mtu(&rt->dst) - dev->hard_header_len
 					- sizeof(struct iphdr) - tunnel_hlen;
 	else
-		mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
+		mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
 
 	skb_dst_update_pmtu(skb, mtu);
 
@@ -530,7 +530,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
 	}
 #if IS_ENABLED(CONFIG_IPV6)
 	else if (skb->protocol == htons(ETH_P_IPV6)) {
-		struct rt6_info *rt6 = (struct rt6_info *)skb_dst(skb);
+		struct rt6_info *rt6 = (struct rt6_info *)skb_valid_dst(skb);
 		__be32 daddr;
 
 		daddr = md ? dst : tunnel->parms.iph.daddr;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu
  2019-02-16  0:58 [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu wenxu
@ 2019-02-16 16:34 ` Alexei Starovoitov
  2019-02-17  3:35   ` wenxu
  0 siblings, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2019-02-16 16:34 UTC (permalink / raw)
  To: wenxu
  Cc: David S. Miller, rong.a.chen, Network Development, Stephen Rothwell, LKP

On Sat, Feb 16, 2019 at 2:11 AM <wenxu@ucloud.cn> wrote:
>
> From: wenxu <wenxu@ucloud.cn>
>
> BUG report in selftests: bpf: test_tunnel.sh
>
> Testing IPIP tunnel...
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
> PGD 0 P4D 0
> Oops: 0010 [#1] SMP PTI
> CPU: 0 PID: 16822 Comm: ping Not tainted 5.0.0-rc3-00352-gc8b34e6 #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> RIP: 0010:          (null)
> Code: Bad RIP value.
> RSP: 0018:ffffc9000104f9c8 EFLAGS: 00010286
> RAX: 0000000000000000 RBX: ffffe8ffffc071a8 RCX: 0000000000000000
> RDX: ffff888054e33000 RSI: ffff88807796f500 RDI: ffffe8ffffc07130
> RBP: ffff88807796f500 R08: ffff88806da4f0a0 R09: 0000000000000000
> R10: 0000000000000004 R11: ffff888054e33000 R12: 0000000000000054
> R13: ffff88805e714000 R14: ffff88806da4f0a0 R15: 0000000000000000
> FS:  00007f4c00431500(0000) GS:ffff88813fc00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: ffffffffffffffd6 CR3: 000000008276e000 CR4: 00000000000406f0
> Call Trace:
>  ? tnl_update_pmtu+0x21b/0x250 [ip_tunnel]
>  ? ip_md_tunnel_xmit+0x1b7/0xdc0 [ip_tunnel]
>  ? ipip_tunnel_xmit+0x90/0xc0 [ipip]
>  ? dev_hard_start_xmit+0x98/0x210
>  ? __dev_queue_xmit+0x6a9/0x8e0
>
> The bpf program set tunnel_key through bpf_skb_set_tunnel_key which will
> drop the old dst_entry and create a DST_METADATA dst_entry. It will lead
> the tunnel_update_pmtu operator the dst_entry incorrect. So It should be
> check the dst_entry is valid.
>
> Fixes: c8b34e680a09 ("ip_tunnel: Add tnl_update_pmtu in ip_md_tunnel_xmit")
> Signed-off-by: wenxu <wenxu@ucloud.cn>

different fix for this issue was sent earlier:
https://patchwork.ozlabs.org/patch/1042687/
I think it's more complete than this one.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu
  2019-02-16 16:34 ` Alexei Starovoitov
@ 2019-02-17  3:35   ` wenxu
  2019-02-17  3:45     ` wenxu
  0 siblings, 1 reply; 4+ messages in thread
From: wenxu @ 2019-02-17  3:35 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: David S. Miller, rong.a.chen, Network Development, Stephen Rothwell, LKP

On 2019/2/17 上午12:34, Alexei Starovoitov wrote:
> On Sat, Feb 16, 2019 at 2:11 AM <wenxu@ucloud.cn> wrote:
>> From: wenxu <wenxu@ucloud.cn>
>>
>> BUG report in selftests: bpf: test_tunnel.sh
>>
>> Testing IPIP tunnel...
>> BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
>> PGD 0 P4D 0
>> Oops: 0010 [#1] SMP PTI
>> CPU: 0 PID: 16822 Comm: ping Not tainted 5.0.0-rc3-00352-gc8b34e6 #1
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
>> RIP: 0010:          (null)
>> Code: Bad RIP value.
>> RSP: 0018:ffffc9000104f9c8 EFLAGS: 00010286
>> RAX: 0000000000000000 RBX: ffffe8ffffc071a8 RCX: 0000000000000000
>> RDX: ffff888054e33000 RSI: ffff88807796f500 RDI: ffffe8ffffc07130
>> RBP: ffff88807796f500 R08: ffff88806da4f0a0 R09: 0000000000000000
>> R10: 0000000000000004 R11: ffff888054e33000 R12: 0000000000000054
>> R13: ffff88805e714000 R14: ffff88806da4f0a0 R15: 0000000000000000
>> FS:  00007f4c00431500(0000) GS:ffff88813fc00000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: ffffffffffffffd6 CR3: 000000008276e000 CR4: 00000000000406f0
>> Call Trace:
>>  ? tnl_update_pmtu+0x21b/0x250 [ip_tunnel]
>>  ? ip_md_tunnel_xmit+0x1b7/0xdc0 [ip_tunnel]
>>  ? ipip_tunnel_xmit+0x90/0xc0 [ipip]
>>  ? dev_hard_start_xmit+0x98/0x210
>>  ? __dev_queue_xmit+0x6a9/0x8e0
>>
>> The bpf program set tunnel_key through bpf_skb_set_tunnel_key which will
>> drop the old dst_entry and create a DST_METADATA dst_entry. It will lead
>> the tunnel_update_pmtu operator the dst_entry incorrect. So It should be
>> check the dst_entry is valid.
>>
>> Fixes: c8b34e680a09 ("ip_tunnel: Add tnl_update_pmtu in ip_md_tunnel_xmit")
>> Signed-off-by: wenxu <wenxu@ucloud.cn>
> different fix for this issue was sent earlier:
> https://patchwork.ozlabs.org/patch/1042687/
> I think it's more complete than this one.
>
sorry for didn't saw the patch before. But I think the patch I provide more simpler and  also complete for fix this problem


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu
  2019-02-17  3:35   ` wenxu
@ 2019-02-17  3:45     ` wenxu
  0 siblings, 0 replies; 4+ messages in thread
From: wenxu @ 2019-02-17  3:45 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: David S. Miller, rong.a.chen, Network Development, Stephen Rothwell, LKP

On 2019/2/17 上午11:35, wenxu wrote:
> On 2019/2/17 上午12:34, Alexei Starovoitov wrote:
>> On Sat, Feb 16, 2019 at 2:11 AM <wenxu@ucloud.cn> wrote:
>>> From: wenxu <wenxu@ucloud.cn>
>>>
>>> BUG report in selftests: bpf: test_tunnel.sh
>>>
>>> Testing IPIP tunnel...
>>> BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
>>> PGD 0 P4D 0
>>> Oops: 0010 [#1] SMP PTI
>>> CPU: 0 PID: 16822 Comm: ping Not tainted 5.0.0-rc3-00352-gc8b34e6 #1
>>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
>>> RIP: 0010:          (null)
>>> Code: Bad RIP value.
>>> RSP: 0018:ffffc9000104f9c8 EFLAGS: 00010286
>>> RAX: 0000000000000000 RBX: ffffe8ffffc071a8 RCX: 0000000000000000
>>> RDX: ffff888054e33000 RSI: ffff88807796f500 RDI: ffffe8ffffc07130
>>> RBP: ffff88807796f500 R08: ffff88806da4f0a0 R09: 0000000000000000
>>> R10: 0000000000000004 R11: ffff888054e33000 R12: 0000000000000054
>>> R13: ffff88805e714000 R14: ffff88806da4f0a0 R15: 0000000000000000
>>> FS:  00007f4c00431500(0000) GS:ffff88813fc00000(0000) knlGS:0000000000000000
>>> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>>> CR2: ffffffffffffffd6 CR3: 000000008276e000 CR4: 00000000000406f0
>>> Call Trace:
>>>  ? tnl_update_pmtu+0x21b/0x250 [ip_tunnel]
>>>  ? ip_md_tunnel_xmit+0x1b7/0xdc0 [ip_tunnel]
>>>  ? ipip_tunnel_xmit+0x90/0xc0 [ipip]
>>>  ? dev_hard_start_xmit+0x98/0x210
>>>  ? __dev_queue_xmit+0x6a9/0x8e0
>>>
>>> The bpf program set tunnel_key through bpf_skb_set_tunnel_key which will
>>> drop the old dst_entry and create a DST_METADATA dst_entry. It will lead
>>> the tunnel_update_pmtu operator the dst_entry incorrect. So It should be
>>> check the dst_entry is valid.
>>>
>>> Fixes: c8b34e680a09 ("ip_tunnel: Add tnl_update_pmtu in ip_md_tunnel_xmit")
>>> Signed-off-by: wenxu <wenxu@ucloud.cn>
>> different fix for this issue was sent earlier:
>> https://patchwork.ozlabs.org/patch/1042687/
>> I think it's more complete than this one.
>>
> sorry for didn't saw the patch before. But I think the patch I provide more simpler and  also complete for fix this problem
>
>
>
sorry for skip this patch. Thx!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-17  3:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-16  0:58 [PATCH net-next] ip_tunnel: Fix DST_METADATA dst_entry handle in tnl_update_pmtu wenxu
2019-02-16 16:34 ` Alexei Starovoitov
2019-02-17  3:35   ` wenxu
2019-02-17  3:45     ` wenxu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).