Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

netlink: correct nlmsg size for multicast notifications

Corrected the netlink message size calculation for multicast group
join/leave notifications. The previous calculation did not account for
the inclusion of both IPv4/IPv6 addresses and ifa_cacheinfo in the
payload. This fix ensures that the allocated message size is
sufficient to hold all necessary information.

This patch also includes the following improvements:
* Uses GFP_KERNEL instead of GFP_ATOMIC when holding the RTNL mutex.
* Uses nla_total_size(sizeof(struct in6_addr)) instead of
nla_total_size(16).
* Removes unnecessary EXPORT_SYMBOL().

Fixes: 2c2b61d2138f ("netlink: add IGMP/MLD join/leave notifications")
Cc: Maciej Żenczykowski <maze@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Yuyang Huang <yuyanghuang@google.com>
Link: https://patch.msgid.link/20241221100007.1910089-1-yuyanghuang@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Yuyang Huang and committed by
Jakub Kicinski
aa4ad7c3 f288c7a1

+8 -5
+4 -2
net/ipv4/igmp.c
··· 1473 1473 int err = -ENOMEM; 1474 1474 1475 1475 skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg)) + 1476 - nla_total_size(sizeof(__be32)), GFP_ATOMIC); 1476 + nla_total_size(sizeof(__be32)) + 1477 + nla_total_size(sizeof(struct ifa_cacheinfo)), 1478 + GFP_KERNEL); 1477 1479 if (!skb) 1478 1480 goto error; 1479 1481 ··· 1486 1484 goto error; 1487 1485 } 1488 1486 1489 - rtnl_notify(skb, net, 0, RTNLGRP_IPV4_MCADDR, NULL, GFP_ATOMIC); 1487 + rtnl_notify(skb, net, 0, RTNLGRP_IPV4_MCADDR, NULL, GFP_KERNEL); 1490 1488 return; 1491 1489 error: 1492 1490 rtnl_set_sk_err(net, RTNLGRP_IPV4_MCADDR, err);
-1
net/ipv6/addrconf.c
··· 5239 5239 nlmsg_end(skb, nlh); 5240 5240 return 0; 5241 5241 } 5242 - EXPORT_SYMBOL(inet6_fill_ifmcaddr); 5243 5242 5244 5243 static int inet6_fill_ifacaddr(struct sk_buff *skb, 5245 5244 const struct ifacaddr6 *ifaca,
+4 -2
net/ipv6/mcast.c
··· 920 920 int err = -ENOMEM; 921 921 922 922 skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg)) + 923 - nla_total_size(16), GFP_ATOMIC); 923 + nla_total_size(sizeof(struct in6_addr)) + 924 + nla_total_size(sizeof(struct ifa_cacheinfo)), 925 + GFP_KERNEL); 924 926 if (!skb) 925 927 goto error; 926 928 ··· 933 931 goto error; 934 932 } 935 933 936 - rtnl_notify(skb, net, 0, RTNLGRP_IPV6_MCADDR, NULL, GFP_ATOMIC); 934 + rtnl_notify(skb, net, 0, RTNLGRP_IPV6_MCADDR, NULL, GFP_KERNEL); 937 935 return; 938 936 error: 939 937 rtnl_set_sk_err(net, RTNLGRP_IPV6_MCADDR, err);