Skip to contentSkip to conversation

net: psample: fix info leak in PSAMPLE_ATTR_DATA

PATCH Applied Jakub Kicinski 3 participants 3 messages Jun 16 – Jun 18

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: psample: fix info leak in PSAMPLE_ATTR_DATA

psample open codes nla_put() presumably to avoid wiping the data with 0s just to override it with packet data. This open coding is missing clearing the pad, however, each netlink attr is padded to 4B and data_len may not be divisible by 4B.

Fixes 6ae0a6286171 ("net: Introduce psample, a new genetlink channel for packet sampling")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 net/psample/psample.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/psample/psample.c +4 -2
index 7763662036fb..c112e1f0ccac 100644
@@ -476,15 +476,17 @@ void psample_sample_packet(struct psample_group *group,
 		goto error;
 
 	if (data_len) {
-		int nla_len = nla_total_size(data_len);
+		int nla_len = nla_attr_size(data_len);
 		struct nlattr *nla;
 
 		nla = skb_put(nl_skb, nla_len);
 		nla->nla_type = PSAMPLE_ATTR_DATA;
-		nla->nla_len = nla_attr_size(data_len);
+		nla->nla_len = nla_len;
 
 		if (skb_copy_bits(skb, 0, nla_data(nla), data_len))
 			goto error;
+
+		skb_put_zero(nl_skb, nla_padlen(data_len));
 	}
 
 #ifdef CONFIG_INET
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tue, Jun 16, 2026 at 02:30:46AM +0200, [email protected] wrote:

psample open codes nla_put() presumably to avoid wiping the data with 0s just to override it with packet data. This open coding is missing clearing the pad, however, each netlink attr is padded to 4B and data_len may not be divisible by 4B.

Fixes 6ae0a6286171 ("net: Introduce psample, a new genetlink channel for packet sampling")
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Mon, 15 Jun 2026 17:30:46 -0700 you wrote:

psample open codes nla_put() presumably to avoid wiping the data with 0s just to override it with packet data. This open coding is missing clearing the pad, however, each netlink attr is padded to 4B and data_len may not be divisible by 4B.

Fixes 6ae0a6286171 ("net: Introduce psample, a new genetlink channel for packet sampling")

[...]

Here is the summary with links:
- [net] net: psample: fix info leak in PSAMPLE_ATTR_DATA

    https://git.kernel.org/netdev/net/c/aedd02af1f8b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html