Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEDC0156C0 for ; Mon, 26 Jun 2023 21:49:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CBECC433C8; Mon, 26 Jun 2023 21:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687816199; bh=7za3I3AAMC1MXB+6NLirqnu2IknXMW6JjTr9xOxreP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMdY9PJF7VfySQu5CHRdUTtZ2v+uhrzmFme3UWpc5qUvYcbpgaO8rjVBhgSIpKglm ho00BtkAxmV78iYevGUZV+4BMPXQHwcbbGM4s+votkvaoH/PFd1qkkTF6QiHPrRaVp GFOIgtH3xxMzge9BakMh4/Ss3hVGc9fNWDvx4ay5xisylq76dBf375NmMPD+JWmcqu 6vzKJvAvo/q5hiv2gjEcJIguwq1jWqISa4gd6dQLsnoe05Q2x+2bnIUX3KTcTfqamt qvgf/qvqVtn62uwpDPvyuSpqK8NxvIewyMQnSFBX4jvsOKYYY8Af1fwfm4gRYch7bM NOZCKLVc6/UlA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Mastykin , Paul Moore , "David S . Miller" , Sasha Levin , edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH AUTOSEL 6.3 03/16] netlabel: fix shift wrapping bug in netlbl_catmap_setlong() Date: Mon, 26 Jun 2023 17:49:43 -0400 Message-Id: <20230626214956.178942-3-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230626214956.178942-1-sashal@kernel.org> References: <20230626214956.178942-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.3.9 Content-Transfer-Encoding: 8bit From: Dmitry Mastykin [ Upstream commit b403643d154d15176b060b82f7fc605210033edd ] There is a shift wrapping bug in this code on 32-bit architectures. NETLBL_CATMAP_MAPTYPE is u64, bitmap is unsigned long. Every second 32-bit word of catmap becomes corrupted. Signed-off-by: Dmitry Mastykin Acked-by: Paul Moore Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/netlabel/netlabel_kapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index 54c0830039470..27511c90a26f4 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -857,7 +857,8 @@ int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap, offset -= iter->startbit; idx = offset / NETLBL_CATMAP_MAPSIZE; - iter->bitmap[idx] |= bitmap << (offset % NETLBL_CATMAP_MAPSIZE); + iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap + << (offset % NETLBL_CATMAP_MAPSIZE); return 0; } -- 2.39.2