Skip to content

Commit f4e4534

Browse files
tammelakuba-moo
authored andcommitted
net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
The current code for the length calculation wrongly truncates the reported length of the groups array, causing an under report of the subscribed groups. To fix this, use 'BITS_TO_BYTES()' which rounds up the division by 8. Fixes: b42be38 ("netlink: add API to retrieve all group memberships") Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/r/20230529153335.389815-1-pctammela@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 36eec02 commit f4e4534

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netlink/af_netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
17791779
break;
17801780
}
17811781
}
1782-
if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen))
1782+
if (put_user(ALIGN(BITS_TO_BYTES(nlk->ngroups), sizeof(u32)), optlen))
17831783
err = -EFAULT;
17841784
netlink_unlock_table();
17851785
return err;

0 commit comments

Comments
 (0)