Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1829719rwb; Fri, 2 Dec 2022 01:30:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6BeKzI1c5l6XfEa748kNMGVWfiwDnGWCiTUOR9AXrGbvDCbb6jf2kNDEqados3RyMpm7Uv X-Received: by 2002:a05:6a00:1696:b0:537:b0c3:691 with SMTP id k22-20020a056a00169600b00537b0c30691mr51239727pfc.59.1669973441546; Fri, 02 Dec 2022 01:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669973441; cv=none; d=google.com; s=arc-20160816; b=lAuwq+lqNPDgJ6HY+cxXvZvauQeJJW4t+BRkIEfmHmMWF0HX6IT8fjtavSb3c8Eo/A TYwA3eI1GPvcwFHnU6FRfhxyoYRDVOVKBom25Nkk7t0Orvc7O3Mz9Adg1k8E4wq0Gd7s ++z7kyjr+5YMViSLYTIyhtRofY0fOdDe6rSOULE5DT33SRT8tlcF+sZZ5oKenKmXTbpx V/ZokOeIBeuYewXx2A/G/fIzUCP1X1EZfO5PfuxiJVTJqRtFSJdGLFkVthfvsUJyPQUT +eJDe+rxFapMEP6Mxf2db1uCU4FjTBUT0Uql+/8m8iZyj4DoYxbB7IiUGibnOPNXAG1j ap5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=d9eJOBY9coqq5710aYmIvg1tkAZt0zwDixD23yTSliA=; b=sdkoamgsuC8qslv+icwY7TvVpzkguqUsqKlVmnb9KeXdL/zLm+UZ0WA2yiOhvsDoxQ uaebiuNP18nSgQ6SQwgrZAczwA63IWd9AK5L8C6WVV/RSyR8nG/L3+qSHogtAKiNYSPX 8GSRSqBcrNDEIZO8j+SlCnzpdRaFFH1QHtTy0+bJ0zAtDrOaJkY7CjimOIsznEnAoO7M OS832uxUy4a9SJZq+Ym0mfQZfCOyCALXN3FB7Magdx7Z52WAirtcTn26DWmH6ldsSyQC oGd8PEXktTcbdygAOjfQhumCglRgQnnaDFXrqn2sFvM9vKcoSfyn3+TMIEeG1xpc6GfK qHVQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a655889000000b00476c8632d24si7084171pgu.686.2022.12.02.01.30.31; Fri, 02 Dec 2022 01:30:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbiLBIgJ (ORCPT + 82 others); Fri, 2 Dec 2022 03:36:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232182AbiLBIfm (ORCPT ); Fri, 2 Dec 2022 03:35:42 -0500 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2B771759A; Fri, 2 Dec 2022 00:34:10 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 96A9E1E80D27; Fri, 2 Dec 2022 16:30:06 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tHXrPYcJdepW; Fri, 2 Dec 2022 16:30:03 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 204621E80CCF; Fri, 2 Dec 2022 16:30:03 +0800 (CST) From: Li Qiong To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, kernel-janitors@vger.kernel.org, coreteam@netfilter.org, Yu Zhe , Li Qiong Subject: [PATCH] netfilter: nfnetlink: check 'skb->dev' pointer in nfulnl_log_packet() Date: Fri, 2 Dec 2022 16:33:04 +0800 Message-Id: <20221202083304.9005-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 The 'skb->dev' may be NULL, it should be better to check it. Signed-off-by: Li Qiong --- net/netfilter/nfnetlink_log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index d97eb280cb2e..74ac9fa40137 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -572,7 +572,7 @@ __build_packet_message(struct nfnl_log_net *log, } } - if (indev && skb_mac_header_was_set(skb)) { + if (indev && skb->dev && skb_mac_header_was_set(skb)) { if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) || nla_put_be16(inst->skb, NFULA_HWLEN, htons(skb->dev->hard_header_len))) @@ -724,7 +724,7 @@ nfulnl_log_packet(struct net *net, + nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp)) + nla_total_size(sizeof(struct nfgenmsg)); /* NLMSG_DONE */ - if (in && skb_mac_header_was_set(skb)) { + if (in && skb->dev && skb_mac_header_was_set(skb)) { size += nla_total_size(skb->dev->hard_header_len) + nla_total_size(sizeof(u_int16_t)) /* hwtype */ + nla_total_size(sizeof(u_int16_t)); /* hwlen */ -- 2.11.0