mirror of
https://github.com/torvalds/linux.git
synced 2026-12-05 12:54:27 +00:00
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: b42be38b27 ("netlink: add API to retrieve all group memberships")
Signed-off-by: Pedro Tammela <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
This commit is contained in:
committed by
Jakub Kicinski
parent
36eec020fa
commit
f4e4534850
@@ -1779,7 +1779,7 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen))
|
||||
if (put_user(ALIGN(BITS_TO_BYTES(nlk->ngroups), sizeof(u32)), optlen))
|
||||
err = -EFAULT;
|
||||
netlink_unlock_table();
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user