net: drop_monitor: fix info leak in NET_DM_ATTR_PAYLOAD
Subsystems (3)
PATCH v2 1/1 net: drop_monitor: fix info leak in NET_DM_ATTR_PAYLOAD
net_dm_packet_report_fill() and net_dm_hw_packet_report_fill() open code the NET_DM_ATTR_PAYLOAD attribute to avoid zeroing the packet payload before overwriting it with skb_copy_bits().
skb_put() reserves nla_total_size(payload_len), i.e. the header plus the NLA_ALIGN() padding, but only payload_len bytes are copied in. When payload_len is not a multiple of 4 the 1-3 padding bytes are never initialized and are leaked to user space inside the netlink message.
KMSAN confirms the leak for the software path when the packet payload length is not 4-byte aligned:
BUG: KMSAN: kernel-infoleak in _copy_to_iter _copy_to_iter __skb_datagram_iter skb_copy_datagram_iter netlink_recvmsg sock_recvmsg __sys_recvfrom Uninit was created at: kmem_cache_alloc_node_noprof __alloc_skb net_dm_packet_work Bytes 173-175 of 176 are uninitialized
Use __nla_reserve(), which sets up the attribute header and zeroes the padding, instead of open coding the attribute construction.
---
v2: use __nla_reserve() instead of open coding the attribute (Eric Dumazet)
v1: https://lore.kernel.org/netdev/[email protected]/
net/core/drop_monitor.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
net/core/drop_monitor.c +2 -6
@@ -671,9 +671,7 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,if (nla_put_u16 (msg,NET_DM_ATTR_PROTO ,be16_to_cpu (skb->protocol))) goto nla_put_failure; - attr =skb_put (msg,nla_total_size (payload_len)); - attr->nla_type =NET_DM_ATTR_PAYLOAD ; - attr->nla_len =nla_attr_size (payload_len); + attr =__nla_reserve (msg,NET_DM_ATTR_PAYLOAD , payload_len);if (skb_copy_bits (skb,0 ,nla_data (attr), payload_len)) goto nla_put_failure;
@@ -831,9 +829,7 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,if (nla_put_u16 (msg,NET_DM_ATTR_PROTO ,be16_to_cpu (skb->protocol))) goto nla_put_failure; - attr =skb_put (msg,nla_total_size (payload_len)); - attr->nla_type =NET_DM_ATTR_PAYLOAD ; - attr->nla_len =nla_attr_size (payload_len); + attr =__nla_reserve (msg,NET_DM_ATTR_PAYLOAD , payload_len);if (skb_copy_bits (skb,0 ,nla_data (attr), payload_len)) goto nla_put_failure;
Signature · 1 line
2.43.0
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 10 lines · On Wed, 22 Jul 2026 21:28:17 +0900 you wrote:
net_dm_packet_report_fill()andnet_dm_hw_packet_report_fill()open code theNET_DM_ATTR_PAYLOADattribute to avoid zeroing the packet payload before overwriting it withskb_copy_bits().
skb_put()reservesnla_total_size(payload_len), i.e. the header plus theNLA_ALIGN()padding, but onlypayload_lenbytes are copied in. Whenpayload_lenis not a multiple of 4 the 1-3 padding bytes are never initialized and are leaked to user space inside the netlink message.[...]
Here is the summary with links:
- [v2,net] net: drop_monitor: fix info leak in NET_DM_ATTR_PAYLOAD
https://git.kernel.org/netdev/net/c/5e9c8baee032
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html