netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
@ 2023-05-29 15:33 Pedro Tammela
  2023-05-30 11:52 ` Simon Horman
  2023-05-31  7:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Pedro Tammela @ 2023-05-29 15:33 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, kuniyu, dh.herrmann, jhs,
	Pedro Tammela

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>
---
 net/netlink/af_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
  2023-05-29 15:33 [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report Pedro Tammela
@ 2023-05-30 11:52 ` Simon Horman
  2023-05-31  7:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-05-30 11:52 UTC (permalink / raw)
  To: Pedro Tammela
  Cc: netdev, davem, edumazet, kuba, pabeni, kuniyu, dh.herrmann, jhs

On Mon, May 29, 2023 at 12:33:35PM -0300, Pedro Tammela wrote:
> 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>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
  2023-05-29 15:33 [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report Pedro Tammela
  2023-05-30 11:52 ` Simon Horman
@ 2023-05-31  7:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-31  7:10 UTC (permalink / raw)
  To: Pedro Tammela
  Cc: netdev, davem, edumazet, kuba, pabeni, kuniyu, dh.herrmann, jhs

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 29 May 2023 12:33:35 -0300 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
    https://git.kernel.org/netdev/net/c/f4e4534850a9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-31  7:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-29 15:33 [PATCH net-next] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report Pedro Tammela
2023-05-30 11:52 ` Simon Horman
2023-05-31  7:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).