Message ID | 20230728100035.32092-1-yuehaibing@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp336192vqg; Fri, 28 Jul 2023 03:31:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFmreT9h+GVpE4DLl70YKpPfITdRg9qH1gJSZi2tHQOfhx2XQ6T2q+opDQAsh38CeYX/389 X-Received: by 2002:a17:906:cc18:b0:99b:4210:cc76 with SMTP id ml24-20020a170906cc1800b0099b4210cc76mr2179849ejb.28.1690540301379; Fri, 28 Jul 2023 03:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690540301; cv=none; d=google.com; s=arc-20160816; b=1JRlCM3DMiKr8pQsaXz8rPjYS+qgSVnKnkbQRiAmK5tlybLe4qp6vJA/jGjU/bIlwj pOLLQz/IEyORvRxKUbIrd16cveGaH15kRg+Qm9OMxWZR8gq/+6dcScPZJzGYCyiavoQY idPdM6GXYCff5Vl3R0Y3MpPK4ckWdJbwQwU8IfRFEMaojp/hKG+0vVfPwcae6W3sAqlK IPEkwiv+9kpVPdHrTJGF+tiY1R2SQlX5q+U4YEWiLhJr4tKGpb3F52OttSvZZ/M4Ss03 aB0g6/YUO82waH/ql1sxGbnrQyAY/XOg6ZD1d48tL5hNRZpf/WAIsT7XDsCllNOd77aI aSWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=rtfkKPZAoag77n/xiLwX0AQkNPmTix3SlLwK0vO4h1I=; fh=JeXy3A7IZl/quCImKorQJ0+UjOEGHzScLCgKSNLV84M=; b=tCFvVXeGces3x9U7lXZ4vPJQL7iW6JVmPwg64EK8S8EJQkCe6hs73cFqlnQxN4st9J aLHJZPujUxJYDO3aiT9yAUn4abYFpp+G3hkej6EdyHqpe3WbIdf8PuRoiVXbwUR96lj9 GDCp30FV/493bpQ3ifyPg3FDWh4/9D0xYgkQQaSs//DG5KKA+Oml5Q/NwtkU7zNMFfxj OwYlunfNAwL+Po9coSJcuIMOr6FnMQYvWR217YJqwJmFBlVlfh9DnPaV+sduuh2ueTp4 tzkAjYK14rtV+cOBo9sBtkaNvwOPlJTd+0YXjmnR1fh+IelwSAWa2eDRGHia4RcY8ouP q+vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020a1709065f8200b00987d26a0998si2601290eju.455.2023.07.28.03.31.16; Fri, 28 Jul 2023 03:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235410AbjG1KCw (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Fri, 28 Jul 2023 06:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235627AbjG1KC3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Jul 2023 06:02:29 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BA446A2; Fri, 28 Jul 2023 03:01:55 -0700 (PDT) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RC3683prdzVjn4; Fri, 28 Jul 2023 18:00:16 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 18:01:53 +0800 From: Yue Haibing <yuehaibing@huawei.com> To: <davem@davemloft.net>, <dsahern@kernel.org>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <yoshfuji@linux-ipv6.org> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Yue Haibing <yuehaibing@huawei.com> Subject: [PATCH] ip6mr: Fix skb_under_panic in ip6mr_cache_report() Date: Fri, 28 Jul 2023 18:00:35 +0800 Message-ID: <20230728100035.32092-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772659987193186569 X-GMAIL-MSGID: 1772659987193186569 |
Series |
ip6mr: Fix skb_under_panic in ip6mr_cache_report()
|
|
Commit Message
Yue Haibing
July 28, 2023, 10 a.m. UTC
skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4
head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:192!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 2 PID: 22968 Comm: kworker/2:11 Not tainted 6.5.0-rc3-00044-g0a8db05b571a #236
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Workqueue: ipv6_addrconf addrconf_dad_work
RIP: 0010:skb_panic+0x152/0x1d0
Call Trace:
<TASK>
skb_push+0xc4/0xe0
ip6mr_cache_report+0xd69/0x19b0
reg_vif_xmit+0x406/0x690
dev_hard_start_xmit+0x17e/0x6e0
__dev_queue_xmit+0x2d6a/0x3d20
vlan_dev_hard_start_xmit+0x3ab/0x5c0
dev_hard_start_xmit+0x17e/0x6e0
__dev_queue_xmit+0x2d6a/0x3d20
neigh_connected_output+0x3ed/0x570
ip6_finish_output2+0x5b5/0x1950
ip6_finish_output+0x693/0x11c0
ip6_output+0x24b/0x880
NF_HOOK.constprop.0+0xfd/0x530
ndisc_send_skb+0x9db/0x1400
ndisc_send_rs+0x12a/0x6c0
addrconf_dad_completed+0x3c9/0xea0
addrconf_dad_work+0x849/0x1420
process_one_work+0xa22/0x16e0
worker_thread+0x679/0x10c0
ret_from_fork+0x28/0x60
ret_from_fork_asm+0x11/0x20
When setup a vlan device on dev pim6reg, DAD ns packet may sent on reg_vif_xmit().
reg_vif_xmit()
ip6mr_cache_report()
skb_push(skb, -skb_network_offset(pkt));//skb_network_offset(pkt) is 4
And skb_push declar as this:
void *skb_push(struct sk_buff *skb, unsigned int len);
skb->data -= len;
//0xffff888f5f86a84c - 0xfffffffc = 0xffff887f5f86a850
skb->data is set to 0xffff887f5f86a850, which is invalid mem addr, lead to skb_push() fails.
Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).")
Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
net/ipv6/ip6mr.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On Fri, Jul 28, 2023 at 06:00:35PM +0800, Yue Haibing wrote: > skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4 > head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg > ------------[ cut here ]------------ > kernel BUG at net/core/skbuff.c:192! > invalid opcode: 0000 [#1] PREEMPT SMP KASAN > CPU: 2 PID: 22968 Comm: kworker/2:11 Not tainted 6.5.0-rc3-00044-g0a8db05b571a #236 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 > Workqueue: ipv6_addrconf addrconf_dad_work > RIP: 0010:skb_panic+0x152/0x1d0 > Call Trace: > <TASK> > skb_push+0xc4/0xe0 > ip6mr_cache_report+0xd69/0x19b0 > reg_vif_xmit+0x406/0x690 > dev_hard_start_xmit+0x17e/0x6e0 > __dev_queue_xmit+0x2d6a/0x3d20 > vlan_dev_hard_start_xmit+0x3ab/0x5c0 > dev_hard_start_xmit+0x17e/0x6e0 > __dev_queue_xmit+0x2d6a/0x3d20 > neigh_connected_output+0x3ed/0x570 > ip6_finish_output2+0x5b5/0x1950 > ip6_finish_output+0x693/0x11c0 > ip6_output+0x24b/0x880 > NF_HOOK.constprop.0+0xfd/0x530 > ndisc_send_skb+0x9db/0x1400 > ndisc_send_rs+0x12a/0x6c0 > addrconf_dad_completed+0x3c9/0xea0 > addrconf_dad_work+0x849/0x1420 > process_one_work+0xa22/0x16e0 > worker_thread+0x679/0x10c0 > ret_from_fork+0x28/0x60 > ret_from_fork_asm+0x11/0x20 > > When setup a vlan device on dev pim6reg, DAD ns packet may sent on reg_vif_xmit(). > reg_vif_xmit() > ip6mr_cache_report() > skb_push(skb, -skb_network_offset(pkt));//skb_network_offset(pkt) is 4 > And skb_push declar as this: nit: declar as this -> declared as > void *skb_push(struct sk_buff *skb, unsigned int len); > skb->data -= len; > //0xffff888f5f86a84c - 0xfffffffc = 0xffff887f5f86a850 > skb->data is set to 0xffff887f5f86a850, which is invalid mem addr, lead to skb_push() fails. > > Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).") > Signed-off-by: Yue Haibing <yuehaibing@huawei.com> ...
On Fri, Jul 28, 2023 at 12:01 PM Yue Haibing <yuehaibing@huawei.com> wrote: > > skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4 > head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg > ------------[ cut here ]------------ > > When setup a vlan device on dev pim6reg, DAD ns packet may sent on reg_vif_xmit(). > reg_vif_xmit() > ip6mr_cache_report() > skb_push(skb, -skb_network_offset(pkt));//skb_network_offset(pkt) is 4 > And skb_push declar as this: > void *skb_push(struct sk_buff *skb, unsigned int len); > skb->data -= len; > //0xffff888f5f86a84c - 0xfffffffc = 0xffff887f5f86a850 > skb->data is set to 0xffff887f5f86a850, which is invalid mem addr, lead to skb_push() fails. > > Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).") > Signed-off-by: Yue Haibing <yuehaibing@huawei.com> > --- > net/ipv6/ip6mr.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c > index cc3d5ad17257..ee9c2ff8b0e4 100644 > --- a/net/ipv6/ip6mr.c > +++ b/net/ipv6/ip6mr.c > @@ -1051,9 +1051,9 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, > int ret; > > #ifdef CONFIG_IPV6_PIMSM_V2 > + int nhoff = skb_network_offset(pkt); > if (assert == MRT6MSG_WHOLEPKT || assert == MRT6MSG_WRMIFWHOLE) > - skb = skb_realloc_headroom(pkt, -skb_network_offset(pkt) > - +sizeof(*msg)); > + skb = skb_realloc_headroom(pkt, -nhoff + sizeof(*msg)); > else > #endif > skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC); > @@ -1073,7 +1073,8 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, > And all this only to mangle msg->im6_msgtype and > to set msg->im6_mbz to "mbz" :-) > */ > - skb_push(skb, -skb_network_offset(pkt)); > + skb->data += nhoff; > + skb->len -= nhoff; __skb_pull(skb, nhoff); > > skb_push(skb, sizeof(*msg)); > skb_reset_transport_header(skb); > -- > 2.34.1 >
On 2023/7/28 18:50, Eric Dumazet wrote: > On Fri, Jul 28, 2023 at 12:01 PM Yue Haibing <yuehaibing@huawei.com> wrote: >> >> skbuff: skb_under_panic: text:ffffffff88771f69 len:56 put:-4 >> head:ffff88805f86a800 data:ffff887f5f86a850 tail:0x88 end:0x2c0 dev:pim6reg >> ------------[ cut here ]------------ >> > >> When setup a vlan device on dev pim6reg, DAD ns packet may sent on reg_vif_xmit(). >> reg_vif_xmit() >> ip6mr_cache_report() >> skb_push(skb, -skb_network_offset(pkt));//skb_network_offset(pkt) is 4 >> And skb_push declar as this: >> void *skb_push(struct sk_buff *skb, unsigned int len); >> skb->data -= len; >> //0xffff888f5f86a84c - 0xfffffffc = 0xffff887f5f86a850 >> skb->data is set to 0xffff887f5f86a850, which is invalid mem addr, lead to skb_push() fails. >> >> Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).") >> Signed-off-by: Yue Haibing <yuehaibing@huawei.com> >> --- >> net/ipv6/ip6mr.c | 7 ++++--- >> 1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c >> index cc3d5ad17257..ee9c2ff8b0e4 100644 >> --- a/net/ipv6/ip6mr.c >> +++ b/net/ipv6/ip6mr.c >> @@ -1051,9 +1051,9 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, >> int ret; >> >> #ifdef CONFIG_IPV6_PIMSM_V2 >> + int nhoff = skb_network_offset(pkt); >> if (assert == MRT6MSG_WHOLEPKT || assert == MRT6MSG_WRMIFWHOLE) >> - skb = skb_realloc_headroom(pkt, -skb_network_offset(pkt) >> - +sizeof(*msg)); >> + skb = skb_realloc_headroom(pkt, -nhoff + sizeof(*msg)); >> else >> #endif >> skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC); >> @@ -1073,7 +1073,8 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, >> And all this only to mangle msg->im6_msgtype and >> to set msg->im6_mbz to "mbz" :-) >> */ >> - skb_push(skb, -skb_network_offset(pkt)); >> + skb->data += nhoff; >> + skb->len -= nhoff; > > __skb_pull(skb, nhoff); Thanks, will do this in v2. > >> >> skb_push(skb, sizeof(*msg)); >> skb_reset_transport_header(skb); >> -- >> 2.34.1 >> > . >
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index cc3d5ad17257..ee9c2ff8b0e4 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1051,9 +1051,9 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, int ret; #ifdef CONFIG_IPV6_PIMSM_V2 + int nhoff = skb_network_offset(pkt); if (assert == MRT6MSG_WHOLEPKT || assert == MRT6MSG_WRMIFWHOLE) - skb = skb_realloc_headroom(pkt, -skb_network_offset(pkt) - +sizeof(*msg)); + skb = skb_realloc_headroom(pkt, -nhoff + sizeof(*msg)); else #endif skb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(*msg), GFP_ATOMIC); @@ -1073,7 +1073,8 @@ static int ip6mr_cache_report(const struct mr_table *mrt, struct sk_buff *pkt, And all this only to mangle msg->im6_msgtype and to set msg->im6_mbz to "mbz" :-) */ - skb_push(skb, -skb_network_offset(pkt)); + skb->data += nhoff; + skb->len -= nhoff; skb_push(skb, sizeof(*msg)); skb_reset_transport_header(skb);