Skip to content

Commit aa4ad7c

Browse files
Yuyang Huangkuba-moo
authored andcommitted
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 <[email protected]> Cc: Lorenzo Colitti <[email protected]> Signed-off-by: Yuyang Huang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f288c7a commit aa4ad7c

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
@@ -5239,7 +5239,6 @@ int inet6_fill_ifmcaddr(struct sk_buff *skb,
52395239
nlmsg_end(skb, nlh);
52405240
return 0;
52415241
}
5242-
EXPORT_SYMBOL(inet6_fill_ifmcaddr);
52435242

52445243
static int inet6_fill_ifacaddr(struct sk_buff *skb,
52455244
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)