summaryrefslogtreecommitdiff
path: root/net/netlink
diff options
context:
space:
mode:
authorPedro Tammela <pctammela@mojatatu.com>2023-05-29 18:33:35 +0300
committerJakub Kicinski <kuba@kernel.org>2023-05-31 10:02:24 +0300
commitf4e4534850a9d18c250a93f8d7fbb51310828110 (patch)
treece3dd0df6c9a5291ed2ddc843ba2cd773d97d2b5 /net/netlink
parent36eec020fab668719b541f34d97f44e232ffa165 (diff)
downloadlinux-f4e4534850a9d18c250a93f8d7fbb51310828110.tar.xz
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: b42be38b2778 ("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>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/af_netlink.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index c87804112d0c..3a1e0fd5bf14 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -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;