From: Fang Xieyan <fangxy@xiaopeng.com>
To: pablo@netfilter.org, fw@strlen.de
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>
Subject: [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match
Date: Mon, 26 Oct 2026 20:53:13 +0800 [thread overview]
Message-ID: <20261026125313.14810-1-fangxy@xiaopeng.com> (raw)
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
next reply other threads:[~2026-10-26 12:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:53 Fang Xieyan [this message]
2026-10-26 13:14 ` [PATCH] netfilter: xt_policy: add NULL check for skb_dst() in output policy match Florian Westphal
2026-10-26 15:34 ` Fang Xieyan
2026-10-29 18:55 ` netdev-bot+sashiko
2026-10-29 19:44 ` Florian Westphal
2026-10-29 22:20 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261026125313.14810-1-fangxy@xiaopeng.com \
--to=fangxy@xiaopeng.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuwb@xiaopeng.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox