Article View: linux.kernel.netdev
Article #7492[PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match
From: Fang Xieyan
Date: Mon, 26 Oct 2026 12:53
Date: Mon, 26 Oct 2026 12:53
34 lines
9490 bytes
9490 bytes
match_policy_out() accesses dst->xfrm without checking whether skb_dst() returned NULL. If no dst entry is attached to the skb, this dereference is invalid. Check dst before accessing dst->xfrm and return -1 when no dst entry is present. This follows the existing handling of a dst entry without XFRM state and preserves the XT_POLICY_MATCH_NONE semantics in policy_mt(). Code review identified the unchecked dereference. No reachable path that passes an skb with a NULL dst to match_policy_out() has been identified in current kernels. Reviewed-by: Weibin Liu <liuwb@xiaopeng.com> Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com> --- net/netfilter/xt_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c index ff54e3a8581e..6bbaf92f0cfc 100644 --- a/net/netfilter/xt_policy.c +++ b/net/netfilter/xt_policy.c @@ -87,7 +87,7 @@ match_policy_out(const struct sk_buff *skb, const struct xt_policy_info *info, int strict = info->flags & XT_POLICY_MATCH_STRICT; int i, pos; - if (dst->xfrm == NULL) + if (!dst || dst->xfrm == NULL) return -1; for (i = 0; dst && dst->xfrm; -- 2.50.1
Technical Details
Message-ID:
<20261026125313.14810-1-fangxy@xiaopeng.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351903-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351903-linux-kernel-netdev=dewy.ru
From: fangxy@xiaopeng.com (Fang Xieyan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match
Date: Mon, 26 Oct 2026 20:53:13 +0800
Organization: Usenet Network
Message-ID: <20261026125313.14810-1-fangxy@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1307669"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QaF+UJ0MKoliQE4loXDr7vUgLUk= sha256:IguYbWSgtTIU7FZSmzDxnDXk1k+ke1wKTqL1k4ZAQyY=
sha1:Eb56UKOJ5f8a3iwQv5pzggxZLyA= sha256:a8l/ou17vt9rUn6PPZEvVM8yw12up5Zb1BE5Fb/A3WY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id E8D0F125BA8; Mon, 26 Oct 2026 15:54:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=xiaopeng.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id hhKTFYuL4oE7;
Mon, 26 Oct 2026 15:54:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351903-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id CF9C5125BA5; Mon, 26 Oct 2026 15:54:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 44EF42E0FA; Mon, 26 Oct 2026 12:53:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793019213;
b=BOS9oa5gz0fuefv9piOcafWTXKAVlEpzTiaUk195UMkEo/Qw5tCJqOeec/6Mig4Qb8Jh
pRBlga+U+nsJG5ziru4Jl8JflZa1eNeh9cpnTGFfnsn2Y386neq4uAwBXfp+E/E/J07Al
XCZbBh7Tem+Qybpgp/nkSImvR1ljjOvn/b5HAYdBcYsUUSWxmPNhstHrXR/dqopJVuRVO
vt2bzH7rmEaBj/tID+5Q6fuhori5A4caYeF/Izg0CP4xzCN2xxhICQMtpFT9AojUmN9xY
SdfMUD+rr9CRJ/ZKUtNho8fxvsM8ARcS7gEJQJWjLRIw32PrgNId00+/eSP2TwqCY4Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793019213;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=4sPsWijS0o1vuhCMct6ehUV/2rvCyrpEssuEEpT4abY=;
b=WnS8sjx+lJnLZ8bSKx0EWcR+WdZNYmO2FP5dAzJZsyo41w60gTY/oJWiOLRipZdaZmMW
Oycz+paK0AbrDKPRslt/7jL38fg0Gs7xk9ES7v6/LoLj2NAcHAWQRUbYjVmDQnLAQouKO
ASBId4tkr2TJeLJhfTE2zVPxG5Mx5R3MPZRZkimsK4jNdqYc8XyEBxN4A4VTT8dqEm4op
otzt8A+DBYXR21gh/AJbRaXT3mSi8kRlBSNOhyngxMak3KdjZ0ChIzCpsNYfFMAaC//8x
G/pnJ2OOl0YzxXcujcjx8Y5lHKmoiBnQ24+m9y3XA2zgVj1Zo9vi3ywcwCfiU1uL/fQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=AWBEHmIh;
dmarc=none header.from=xiaopeng.com;
spf=pass smtp.mailfrom=xiaopeng.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 1ACD8606A325;
Mon, 26 Oct 2026 12:53:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=AWBEHmIh
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793019207;
b=OiByDZ6F+Du4abrpcm8VqPzL/55vZTMm472jVSzya+oyDVJl+jLpGGghAVGcMQ8sKBPo
FQiNr356d7SuX8aAAR53pegAMU2yp4rX3z8YM7WqdXLaIyGUh7RuveYhdy1xZVIVJCnni
Yf4jgs0d9u96hGcDdPeR8fgW1bUFrRE80BkGuEi9hVUdwKNvbZp9hSyrnPP8SHnv7iQwe
2PozQz6tpQJq8ZpiwOKspC0jLlKdGmIqp5XdjPFk2Wv/auCxLW0NRSa6H7ifChAMFc3Io
rN5X1BYhJdAmfwjtT9qx1ue3zKLgzaN8ImWmdKLhYtEKPUhYlnxbTt/aEQJ9gqzkAbA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793019207;
h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=4sPsWijS0o1vuhCMct6ehUV/2rvCyrpEssuEEpT4abY=;
b=OvtRb0ywLae+NntUE46ywdEFIn+Zle7r55qgnhPkIndZwgrNvxQOrpo8lq/hsPQ7h+S+
zrG3zTWL4/kRUe7U9Lo0Xe2UFvj/MYvaWVsWCr2cXm04/HbSd4cK+5okAD4rXQQOtInCB
a7Z5q2IM0bLfD6/FlfOs5T4yBgdg5W7fOSPtHhRMJYHJ1N1HFwyojlk2pv5pt47WFmk+l
ca9+0mv7EQ8hYyEtW81OEG7wX/EwdduP1MWI682WR1eItqRWdsZTwaqLXhvOf4RvW8/ZN
tkU99i84aIWxpRcKm3vQ629CkmUemBqCFuDpXtSdmriNdvAoeGwH8wdrmE2BQH8S/cQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=xiaopeng.com;
spf=pass smtp.mailfrom=xiaopeng.com;
dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=AWBEHmIh;
arc=none smtp.remote-ip=115.124.28.169
X-Received: from out28-169.mail.aliyun.com (out28-169.mail.aliyun.com [115.124.28.169])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C31606A31A;
Mon, 26 Oct 2026 12:53:24 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3C31606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=xiaopeng.com; s=default;
t=1793019196; h=From:To:Subject:Date:Message-ID:MIME-Version;
bh=4sPsWijS0o1vuhCMct6ehUV/2rvCyrpEssuEEpT4abY=;
b=AWBEHmIhQCCnHyNEvCdhbg0f2AuqsF7AlHUVK/HiYovR0/32IKs2kjcIZCP069tXRLWsw/u9r0GZvDRiQBOO+corbwKai9+asfvc8LkSD5n9JSMRfgArWLl/p4/yQ/HuJ7UF0iDP5uKNHdQbTH1bPtR6aLSLpmo5tfDFCJAyKXo=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.05106358|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0177122-0.0906822-0.891606;FP=18328251804473314834|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033037034138;MF=fangxy@xiaopeng.com;NM=1;PH=DS;RN=13;RT=13;SR=0;TI=SMTPD_---.jq1bEE5_1793019194;
X-Received: from localhost.localdomain(mailfrom:fangxy@xiaopeng.com fp:SMTPD_---.jq1bEE5_1793019194 cluster:ay29)
by smtp.aliyun-inc.com;
Mon, 26 Oct 2026 20:53:15 +0800
X-Cc: phil@nwl.cc,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
netfilter-devel@vger.kernel.org,
coreteam@netfilter.org,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Weibin Liu <liuwb@xiaopeng.com>
X-Mailer: git-send-email 2.50.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list