From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 680F6C77B7A for ; Wed, 7 Jun 2023 20:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234951AbjFGUsc (ORCPT ); Wed, 7 Jun 2023 16:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbjFGUsR (ORCPT ); Wed, 7 Jun 2023 16:48:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6C11BE2 for ; Wed, 7 Jun 2023 13:48:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 718C9646AF for ; Wed, 7 Jun 2023 20:48:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E74C433D2; Wed, 7 Jun 2023 20:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686170879; bh=qBOGRs3aGq8oHiPCJGQzwhQ33FQagpz75zyzSXfS6kY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3H0EaS5LMgMXJd+GB/Q0HKt8vUus/zFuv6xbrN8HpnRNIovByRey2qmBBkTipyqx 1xZHx0bCxcP2YhxonNrG4IGwbaPFO5v08IIwpK3vErhE+Gnw3QauYvWMTHVsTGT1o5 fvDoacj2l+LKEf6R5qm18t/nw4wDYlqUMVjnd2o8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pedro Tammela , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 026/120] net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report Date: Wed, 7 Jun 2023 22:15:42 +0200 Message-ID: <20230607200901.737214766@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230607200900.915613242@linuxfoundation.org> References: <20230607200900.915613242@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pedro Tammela [ Upstream commit f4e4534850a9d18c250a93f8d7fbb51310828110 ] 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 Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20230529153335.389815-1-pctammela@mojatatu.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 651f8ca912af0..99c869d8d3044 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -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; -- 2.39.2