Skip to content

Commit 277aa23

Browse files
author
CKI Backport Bot
committed
netlink: correct nlmsg size for multicast notifications
JIRA: https://issues.redhat.com/browse/RHEL-84540 commit aa4ad7c Author: Yuyang Huang <yuyanghuang@google.com> Date: Sat Dec 21 19:00:07 2024 +0900 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: 2c2b61d ("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> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 36fdf8d commit 277aa23

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

net/ipv4/igmp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,9 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
14731473
int err = -ENOMEM;
14741474

14751475
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);
14771479
if (!skb)
14781480
goto error;
14791481

@@ -1484,7 +1486,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
14841486
goto error;
14851487
}
14861488

1487-
rtnl_notify(skb, net, 0, RTNLGRP_IPV4_MCADDR, NULL, GFP_ATOMIC);
1489+
rtnl_notify(skb, net, 0, RTNLGRP_IPV4_MCADDR, NULL, GFP_KERNEL);
14881490
return;
14891491
error:
14901492
rtnl_set_sk_err(net, RTNLGRP_IPV4_MCADDR, err);

net/ipv6/addrconf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5242,7 +5242,6 @@ int inet6_fill_ifmcaddr(struct sk_buff *skb,
52425242
nlmsg_end(skb, nlh);
52435243
return 0;
52445244
}
5245-
EXPORT_SYMBOL(inet6_fill_ifmcaddr);
52465245

52475246
static int inet6_fill_ifacaddr(struct sk_buff *skb,
52485247
const struct ifacaddr6 *ifaca,

net/ipv6/mcast.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,9 @@ static void inet6_ifmcaddr_notify(struct net_device *dev,
920920
int err = -ENOMEM;
921921

922922
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);
924926
if (!skb)
925927
goto error;
926928

@@ -931,7 +933,7 @@ static void inet6_ifmcaddr_notify(struct net_device *dev,
931933
goto error;
932934
}
933935

934-
rtnl_notify(skb, net, 0, RTNLGRP_IPV6_MCADDR, NULL, GFP_ATOMIC);
936+
rtnl_notify(skb, net, 0, RTNLGRP_IPV6_MCADDR, NULL, GFP_KERNEL);
935937
return;
936938
error:
937939
rtnl_set_sk_err(net, RTNLGRP_IPV6_MCADDR, err);

0 commit comments

Comments
 (0)