net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
[ Upstream commitf4e4534850] 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 <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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ae7e941f4d
commit
57e6c54034
1 changed files with 1 additions and 1 deletions
|
|
@ -1781,7 +1781,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue