Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6877184rwb; Mon, 5 Dec 2022 20:12:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MrRshozW0SRqdtzq9aQj2dLmaBRYEG0kRfbdIxv6Yc733g2latdCkLfzaKDC9jY4dSocM X-Received: by 2002:a17:902:d88d:b0:186:cb27:4e01 with SMTP id b13-20020a170902d88d00b00186cb274e01mr69869920plz.139.1670299934959; Mon, 05 Dec 2022 20:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670299934; cv=none; d=google.com; s=arc-20160816; b=ujj1pmyE0jg+W2Er4taqBpL0sLpyfGpzbpFy6/TjklB2Z8Dk4trhsg7amuUD97Rt0Q dxW8re2HvufYuPVVyaA5FFPpiyOTpw9IhfI1ERkrYq9Xa0UDCcA6lkZutRU9iSUt/Udg OSHiJG/EkY8Rc/JjLHJbz5G6MpQUiKV0x902bHrrwIgCrpgk25USl+sqNBOatTlOIElW 3QWXdboVipoD6ydeoo242kL1vqtwP1QE6Srn8gFn0rG5uOs4gJMSCq46sdqAOytW0E06 NvzK6tTFBRXFW+axJeYgkaZq6C10GEtk4bRtFa567EjgfH/E4/qFFOg9EUuhUpHs1yCS 15ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=L0rThEAGpgTOyn17zGhI/zm1G/vnQGsdtcnyo/9H9BA=; b=jGjC4YmaWvBOM7+mKoKVWfU5Z6VKPKINPStHzRMMFgw7cxafjPekCvYm2Ic76sCIcw li0JpVJLv8F2Z3QBHVFifi0kB14Ard6RfZBqRYUUevOXh/E8hoOQI4nRdJRXPwFdBHGs ecjVzorboIWrK6DKFxm+Y6gR/V6YdViMAXLP4tRuOsetR9lJ1+/J4QXPIggd9QTNUgXw vUV+HFzE5sXnfSAU/cz9arJR2uCW4XawJ3EHdCXrZHUiFS0QF3vM9ZE5JNOGcMebfEb1 nFKCmBvMkbQg9jIuCzExDByHi/EEIx+q5+ylevsbGhYC9F+B1Nrg88BcV+QzLO8Kj6tt Yo3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nNZc+wIj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot7-20020a17090b3b4700b002196df802afsi15799849pjb.76.2022.12.05.20.12.04; Mon, 05 Dec 2022 20:12:14 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=nNZc+wIj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233898AbiLFDVv (ORCPT + 80 others); Mon, 5 Dec 2022 22:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233884AbiLFDVo (ORCPT ); Mon, 5 Dec 2022 22:21:44 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4F6F222B4 for ; Mon, 5 Dec 2022 19:21:43 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id v206so17016101ybv.7 for ; Mon, 05 Dec 2022 19:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=L0rThEAGpgTOyn17zGhI/zm1G/vnQGsdtcnyo/9H9BA=; b=nNZc+wIjDrFq8+W5tMuzccBqAOZsun3xycLU00kiE/tUDoF6VUGJhkvDZRi4FgaNO4 EbnvDBzUBRmL6SEnejnlh89ho4B6nr9Vj3z1fbgAq9Lz6Y2OE8gwyRHD/RJBSO3/C8GE Aawh77F5YTX/M2BWfLyZ/kKDVrwx1G8tqWSORrWpj/nT6rMStGG4pNoG2w2GtpYy9v2y YG2x4djqMD+6so3fckQIjLBLPpjFatwpp4cV73l2sjF0JERBpRBL7LzMTIYgQBY4GWgJ +u8HsPIt0f0chuvxry5bc1JVQGDopoAtjHEp6H09etyXgf/ptETXXO8ZK2xMTiSVyvZ+ JwXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L0rThEAGpgTOyn17zGhI/zm1G/vnQGsdtcnyo/9H9BA=; b=LMR+GkUCx10/6IVG97exjUQN5axgWEnfJgoDoMISeN2h+PjxGqoit+LGf//InqMuu5 Rg+wHWQzQFERc8TZBAVuR2uMm/X/Op8KmyQXjJonSG8l23E2S3Zxw3qfzliSwkj2xW8E zBmS9D/EUuuMeuAc7RU9sZjicrJrZgpQYmIpfeE80cnqmpDgLy6d0ZsxrOqfI9P6XOgf l1fD517cA6ApkvgqDFne2HIb1yL5YMTvH4j5nGgzDBiHY8SH8FNQ/Ty1O4fZmES+2NWD IVaxfIa7ckAFSzjz8+G2wabbhNIRInmBlvXrXxHIvQmvMcroQPWhL4/tkkZyR6k64fIE uO5g== X-Gm-Message-State: ANoB5pni+xKP31Ajrxve72UN2icU+dHGJ58ITZ2bGen56hCpxOezIaDM 6mH993C5s8JyHyQI8wBI3KZSc2dlUiab5eAMJNv2tQ== X-Received: by 2002:a25:d197:0:b0:703:4bfd:3986 with SMTP id i145-20020a25d197000000b007034bfd3986mr1052241ybg.407.1670296902643; Mon, 05 Dec 2022 19:21:42 -0800 (PST) MIME-Version: 1.0 References: <1669817512-4560-1-git-send-email-george.kennedy@oracle.com> <99adf483-ae89-8010-4689-fd50a77ff023@oracle.com> In-Reply-To: From: Eric Dumazet Date: Tue, 6 Dec 2022 04:21:31 +0100 Message-ID: Subject: Re: [PATCH] net: check for dev pointer being NULL in dev_hard_header() to avoid GPF To: George Kennedy Cc: Pavan Chebbi , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, harshit.m.mogalapalli@oracle.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 6, 2022 at 2:11 AM George Kennedy wrote: > > Hi Eric, > > More info... > > On 12/1/2022 11:11 PM, Eric Dumazet wrote: > > On Thu, Dec 1, 2022 at 9:44 PM George Kennedy wrote: > >> > >> > >> On 12/1/2022 2:25 PM, Eric Dumazet wrote: > >>> On Thu, Dec 1, 2022 at 2:16 PM Pavan Chebbi wrote: > >>>> On Wed, Nov 30, 2022 at 7:43 PM George Kennedy > >>>> wrote: > >>>>> The dev pointer can be NULL in dev_hard_header(). Add check for dev being > >>>>> NULL in dev_hard_header() to avoid GPF. > >>>>> > >>>>> general protection fault, probably for non-canonical address > >>>>> 0xdffffc0000000046: 0000 [#1] PREEMPT SMP KASAN NOPTI > >>>>> KASAN: null-ptr-deref in range [0x0000000000000230-0x0000000000000237] > >>>>> CPU: 1 PID: 45 Comm: kworker/1:1 Not tainted 6.1.0-rc7+ #2 > >>>>> Hardware name: Red Hat KVM, BIOS 1.15.0-2.module+el8.6.0+20659+3dcf7c70 > >>>>> Workqueue: mld mld_ifc_work > >>>>> RIP: 0010:macvlan_hard_header (./include/linux/netdevice.h:3057 > >>>>> (discriminator 4) drivers/net/macvlan.c:594 (discriminator 4)) > >>>>> RSP: 0018:ffff888103d377d0 EFLAGS: 00010212 > >>>>> RAX: dffffc0000000000 RBX: ffff88801cf1a000 RCX: 0000000000000000 > >>>>> RDX: 0000000000000046 RSI: 0000000000000000 RDI: 0000000000000230 > >>>>> RBP: ffff88801e8ef328 R08: 0000000000000000 R09: 0000000000000060 > >>>>> R10: 0000000000000000 R11: 0000000000000000 R12: ffff88801f0497c0 > >>>>> R13: 0000000000000000 R14: ffff888045187c98 R15: 0000000000000060 > >>>>> FS: 0000000000000000(0000) GS:ffff888106c80000(0000) > >>>>> knlGS:0000000000000000 > >>>>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >>>>> CR2: 00007fbf3f1c1840 CR3: 0000000014e36000 CR4: 00000000000006e0 > >>>>> Call Trace: > >>>>> > >>>>> neigh_connected_output (./include/linux/netdevice.h:3060 > >>>>> net/core/neighbour.c:1595) > >>>>> ip6_finish_output2 (./include/net/neighbour.h:546 > >>>>> net/ipv6/ip6_output.c:134) > >>>>> ip6_finish_output (net/ipv6/ip6_output.c:195 net/ipv6/ip6_output.c:206) > >>>>> ip6_output (./include/linux/netfilter.h:291 net/ipv6/ip6_output.c:227) > >>>>> NF_HOOK.constprop.0 (./include/net/dst.h:445 > >>>>> ./include/linux/netfilter.h:302) > >>>>> mld_sendpack (net/ipv6/mcast.c:1824) > >>>>> mld_send_cr (net/ipv6/mcast.c:2122) > >>>>> mld_ifc_work (net/ipv6/mcast.c:2655) > >>>>> process_one_work (kernel/workqueue.c:2294) > >>>>> worker_thread (./include/linux/list.h:292 kernel/workqueue.c:2437) > >>>>> kthread (kernel/kthread.c:376) > >>>>> ret_from_fork (arch/x86/entry/entry_64.S:312) > >>>>> > >>>>> Modules linked in: > >>>>> Dumping ftrace buffer: > >>>>> (ftrace buffer empty) > >>>>> ---[ end trace 0000000000000000 ]--- > >>>>> > >>>>> Fixes: 0c4e85813d0a ("[NET]: Wrap netdevice hardware header creation.") > >>>>> Reported-by: syzkaller > >>>>> Signed-off-by: George Kennedy > >>>>> --- > >>>>> include/linux/netdevice.h | 2 +- > >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>>>> > >>>>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > >>>>> index eddf8ee270e7..9b25a6301fa5 100644 > >>>>> --- a/include/linux/netdevice.h > >>>>> +++ b/include/linux/netdevice.h > >>>>> @@ -3054,7 +3054,7 @@ static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, > >>>>> const void *daddr, const void *saddr, > >>>>> unsigned int len) > >>>>> { > >>>>> - if (!dev->header_ops || !dev->header_ops->create) > >>>>> + if (!dev || !dev->header_ops || !dev->header_ops->create) > >>> Do you have a repro ? > >> See syzkaller repros attached. > >> > >>> This patch will not prevent a crash later I think. > >> The repro ran overnight without failure with the patch applied. > > Yes, but the patch is hiding a potential bug that might show up with > > other 'repros' > The repro fails when these devices are configured (seem like small mtu): > > 20: vxcan0@vxcan1: mtu 72 qdisc noqueue state UP group default qlen 1000 > link/can > inet 172.20.20.38/24 scope global vxcan0 > valid_lft forever preferred_lft forever > 21: vxcan1@vxcan0: mtu 72 qdisc noqueue state UP group default qlen 1000 > link/can > inet 172.20.20.39/24 scope global vxcan1 > valid_lft forever preferred_lft forever > > > # diff ../config.fail .config > 3325c3325 > < CONFIG_CAN_VXCAN=y > --- > > # CONFIG_CAN_VXCAN is not set > > Thanks, > George Small MTU has caused numerous issues in the past. I am pretty sure we miss some READ_ONCE(dev->mtu) and other safety checks.