From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
<netfilter-devel@vger.kernel.org>,
pablo@netfilter.org
Subject: [PATCH net 04/14] netfilter: nfnetlink_log: fix uninitialized padding leak in NFULA_PAYLOAD
Date: Wed, 25 Mar 2026 14:10:58 +0100 [thread overview]
Message-ID: <20260325131108.23045-5-fw@strlen.de> (raw)
In-Reply-To: <20260325131108.23045-1-fw@strlen.de>
From: Weiming Shi <bestswngs@gmail.com>
__build_packet_message() manually constructs the NFULA_PAYLOAD netlink
attribute using skb_put() and skb_copy_bits(), bypassing the standard
nla_reserve()/nla_put() helpers. While nla_total_size(data_len) bytes
are allocated (including NLA alignment padding), only data_len bytes
of actual packet data are copied. The trailing nla_padlen(data_len)
bytes (1-3 when data_len is not 4-byte aligned) are never initialized,
leaking stale heap contents to userspace via the NFLOG netlink socket.
Replace the manual attribute construction with nla_reserve(), which
handles the tailroom check, header setup, and padding zeroing via
__nla_reserve(). The subsequent skb_copy_bits() fills in the payload
data on top of the properly initialized attribute.
Fixes: df6fb868d611 ("[NETFILTER]: nfnetlink: convert to generic netlink attribute functions")
Reported-by: Xiang Mei <xmei5@asu.edu>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nfnetlink_log.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index b35a90955e2e..fcbe54940b2e 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -647,15 +647,11 @@ __build_packet_message(struct nfnl_log_net *log,
if (data_len) {
struct nlattr *nla;
- int size = nla_attr_size(data_len);
- if (skb_tailroom(inst->skb) < nla_total_size(data_len))
+ nla = nla_reserve(inst->skb, NFULA_PAYLOAD, data_len);
+ if (!nla)
goto nla_put_failure;
- nla = skb_put(inst->skb, nla_total_size(data_len));
- nla->nla_type = NFULA_PAYLOAD;
- nla->nla_len = size;
-
if (skb_copy_bits(skb, 0, nla_data(nla), data_len))
BUG();
}
--
2.52.0
next prev parent reply other threads:[~2026-03-25 13:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 13:10 [PATCH net 00/14] netfilter: updates for net Florian Westphal
2026-03-25 13:10 ` [PATCH net 01/14] netfilter: nft_set_pipapo_avx2: don't return non-matching entry on expiry Florian Westphal
2026-03-25 13:10 ` [PATCH net 02/14] selftests: netfilter: nft_concat_range.sh: add check for flush+reload bug Florian Westphal
2026-03-25 13:10 ` [PATCH net 03/14] netfilter: ipset: Fix data race between add and list header in all hash types Florian Westphal
2026-03-25 13:10 ` Florian Westphal [this message]
2026-03-25 13:10 ` [PATCH net 05/14] netfilter: x_tables: reject unsupported families in xt_check_match/xt_check_target Florian Westphal
2026-03-25 13:11 ` [PATCH net 06/14] netfilter: ip6t_rt: reject oversized addrnr in rt_mt6_check() Florian Westphal
2026-03-25 13:11 ` [PATCH net 07/14] netfilter: nft_set_rbtree: revisit array resize logic Florian Westphal
2026-03-25 13:11 ` [PATCH net 08/14] netfilter: nf_conntrack_expect: honor expectation helper field Florian Westphal
2026-03-25 13:11 ` [PATCH net 09/14] netfilter: nf_conntrack_expect: use expect->helper Florian Westphal
2026-03-25 13:11 ` [PATCH net 10/14] netfilter: ctnetlink: ensure safe access to master conntrack Florian Westphal
2026-03-25 17:26 ` Pablo Neira Ayuso
2026-03-25 17:28 ` Pablo Neira Ayuso
2026-03-25 17:28 ` Florian Westphal
2026-03-25 17:38 ` Pablo Neira Ayuso
2026-03-25 13:11 ` [PATCH net 11/14] netfilter: nf_conntrack_expect: store netns and zone in expectation Florian Westphal
2026-03-25 13:11 ` [PATCH net 12/14] netfilter: nf_conntrack_expect: skip expectations in other netns via proc Florian Westphal
2026-03-25 13:11 ` [PATCH net 13/14] netfilter: nf_conntrack_sip: fix use of uninitialized rtp_addr in process_sdp Florian Westphal
2026-03-25 13:11 ` [PATCH net 14/14] netfilter: ctnetlink: use netlink policy range checks Florian Westphal
2026-03-25 17:42 ` [PATCH net 00/14] netfilter: updates for net Florian Westphal
2026-03-25 17:48 ` Pablo Neira Ayuso
2026-03-25 17:51 ` Florian Westphal
2026-03-25 17:59 ` Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2026-03-25 22:26 [PATCH net,v2 00/14] Netfilter fixes " Pablo Neira Ayuso
2026-03-25 22:26 ` [PATCH net 04/14] netfilter: nfnetlink_log: fix uninitialized padding leak in NFULA_PAYLOAD Pablo Neira Ayuso
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=20260325131108.23045-5-fw@strlen.de \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.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