ipmr: prevent info-leak in pmr_cache_report()
Subsystems (3)
PATCH 1/1 ipmr: prevent info-leak in pmr_cache_report()
Yiming Qian reported:
<quote>
ipmr_cache_report() allocates a report skb with alloc_skb(128, GFP_ATOMIC) and appends a struct igmphdr using skb_put(). In the non-IGMPMSG_WHOLEPKT` path it initializes only:
- igmp->type
- igmp->code
but does not initialize:
- igmp->csum
- igmp->group
Later, igmpmsg_netlink_event() copies the bytes after sizeof(struct igmpmsg) into the IPMRA_CREPORT_PKT netlink attribute and emits RTM_NEWCACHEREPORT on RTNLGRP_IPV4_MROUTE_R.
As a result, 6 bytes of stale heap data from the skb head are disclosed to userspace.
</quote>
Let's use skb_put_zero() instead of skb_put() to fix this bug.
--- net/ipv4/ipmr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/ipmr.c +4 -3
@@ -1112,11 +1112,12 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg->im_vif_hi = vifi >>8 ;ipv4_pktinfo_prepare (mroute_sk, pkt, false);memcpy (skb->cb, pkt->cb,sizeof (skb->cb)); -/* Add our header */ - igmp =skb_put (skb,sizeof (struct igmphdr )); +/* Add our header. +* Note that code, csum and group fields are cleared. +*/ + igmp =skb_put_zero (skb,sizeof (struct igmphdr )); igmp->type = assert; msg->im_msgtype = assert; - igmp->code =0 ;ip_hdr (skb)->tot_len =htons (skb->len);/* Fix the length */ skb->transport_header = skb->network_header; }
Signature · 1 line
2.54.0.545.g6539524ca2-goog
Nit: s/pmr_cache_report/ipmr_cache_report/ in subject
Quoted 23 lines · Eric Dumazet
Yiming Qian reported:
<quote>
ipmr_cache_report()allocates a report skb withalloc_skb(128, GFP_ATOMIC)and appends astruct igmphdrusingskb_put(). In the non-IGMPMSG_WHOLEPKT` path it initializes only:-
igmp->type
-igmp->codebut does not initialize:
-
igmp->csum
-igmp->groupLater,
igmpmsg_netlink_event()copies the bytes aftersizeof(struct igmpmsg)into theIPMRA_CREPORT_PKTnetlink attribute and emitsRTM_NEWCACHEREPORTonRTNLGRP_IPV4_MROUTE_R.As a result, 6 bytes of stale heap data from the skb head are disclosed to userspace.
</quote>
Quoted 5 lines
Let's use
skb_put_zero()instead ofskb_put()to fix this bug.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by Yiming Qian <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
FYI, I checked and ip6mr_cache_report() seems OK.
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 8 lines · On Thu, 30 Apr 2026 07:06:11 +0000 you wrote:
Yiming Qian reported:
<quote>
ipmr_cache_report()allocates a report skb withalloc_skb(128, GFP_ATOMIC)and appends astruct igmphdrusingskb_put(). In the non-IGMPMSG_WHOLEPKT` path it initializes only:[...]
Here is the summary with links:
- [net] ipmr: prevent info-leak in pmr_cache_report()
https://git.kernel.org/netdev/net/c/4f34002e2e37
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html