netlink: correct nlmsg size for multicast notifications
Subsystems (3)
PATCH v2 1/1 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().
---
Changelog since v1:
- 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().
net/ipv4/igmp.c | 6 ++++-- net/ipv6/addrconf.c | 1 - net/ipv6/mcast.c | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-)
net/ipv4/igmp.c +4 -2
@@ -1473,7 +1473,9 @@ static void inet_ifmcaddr_notify(struct net_device *dev,int err = -ENOMEM ; skb =nlmsg_new (NLMSG_ALIGN (sizeof (struct ifaddrmsg )) + -nla_total_size (sizeof (__be32)),GFP_ATOMIC ); +nla_total_size (sizeof (__be32)) + +nla_total_size (sizeof (struct ifa_cacheinfo )), +GFP_KERNEL );if (!skb) goto error;
@@ -1484,7 +1486,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev, goto error; } -rtnl_notify (skb, net,0 ,RTNLGRP_IPV4_MCADDR ,NULL ,GFP_ATOMIC ); +rtnl_notify (skb, net,0 ,RTNLGRP_IPV4_MCADDR ,NULL ,GFP_KERNEL );return ; error:rtnl_set_sk_err (net,RTNLGRP_IPV4_MCADDR , err);
net/ipv6/addrconf.c +0 -1
@@ -5239,7 +5239,6 @@ int inet6_fill_ifmcaddr(struct sk_buff *skb,nlmsg_end (skb, nlh);return 0 ; } -EXPORT_SYMBOL (inet6_fill_ifmcaddr); static int inet6_fill_ifacaddr(struct sk_buff *skb, const struct ifacaddr6 *ifaca,
net/ipv6/mcast.c +4 -2
@@ -920,7 +920,9 @@ static void inet6_ifmcaddr_notify(struct net_device *dev,int err = -ENOMEM ; skb =nlmsg_new (NLMSG_ALIGN (sizeof (struct ifaddrmsg )) + -nla_total_size (16 ),GFP_ATOMIC ); +nla_total_size (sizeof (struct in6_addr )) + +nla_total_size (sizeof (struct ifa_cacheinfo )), +GFP_KERNEL );if (!skb) goto error;
@@ -931,7 +933,7 @@ static void inet6_ifmcaddr_notify(struct net_device *dev, goto error; } -rtnl_notify (skb, net,0 ,RTNLGRP_IPV6_MCADDR ,NULL ,GFP_ATOMIC ); +rtnl_notify (skb, net,0 ,RTNLGRP_IPV6_MCADDR ,NULL ,GFP_KERNEL );return ; error:rtnl_set_sk_err (net,RTNLGRP_IPV6_MCADDR , err);
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Sat, 21 Dec 2024 19:00:07 +0900 you wrote:
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_cacheinfoin the payload. This fix ensures that the allocated message size is sufficient to hold all necessary information.
Quoted 7 lines
This patch also includes the following improvements:
* UsesGFP_KERNELinstead ofGFP_ATOMICwhen holding the RTNL mutex.
* Usesnla_total_size(sizeof(struct in6_addr))instead ofnla_total_size(16).
* Removes unnecessaryEXPORT_SYMBOL().[...]
Here is the summary with links:
- [net-next,v2] netlink: correct nlmsg size for multicast notifications
https://git.kernel.org/netdev/net-next/c/aa4ad7c3f283
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html