From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nf-next] netfilter: nfnetlink_log: collapse both dev log blocks
Date: Fri, 2 Oct 2026 14:41:32 +0200 [thread overview]
Message-ID: <20261002124132.13387-1-fw@strlen.de> (raw)
Looked like this:
if (indev && skb->dev &&
skb_mac_header_was_set(skb) &&
skb_mac_header_len(skb) != 0) {
...
}
if (indev && skb_mac_header_was_set(skb)) {
...
}
LLM (sashiko) claims there is a NULL deref in the second block, because
it dereferences skb->dev without checking skb->dev != NULL.
Don't know if `indev && !skb->dev` is even possible:
NF_HOOK() invocation normally passes skb->dev as the indev argument.
Instead of cargo-culting additional skb->dev check, lets just merge
both blocks into one. This gives 2nd block the tighter guards and
results in a small behavioral change:
When `skb_mac_header_was_set` is true but `skb_mac_header_len == 0`
HWADDR was not emitted, but HWTYPE/HWLEN was. But given 2nd block also
emits NFULA_HWHEADER based off skb->dev->hard_header_len, that change
is probably desireable.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nfnetlink_log.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index dddbaf6860cc..3df2998b8cc0 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -600,9 +600,7 @@ __build_packet_message(struct nfnl_log_net *log,
if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
goto nla_put_failure;
}
- }
- if (indev && 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)))
--
2.55.0
next reply other threads:[~2026-10-02 12:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 12:41 Florian Westphal [this message]
2026-10-02 17:38 ` [PATCH nf-next] netfilter: nfnetlink_log: collapse both dev log blocks 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=20261002124132.13387-1-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/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