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 X-Spam-Level: X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A0EC11F69 for ; Mon, 5 Jul 2021 15:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F56461997 for ; Mon, 5 Jul 2021 15:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233220AbhGEPfF (ORCPT ); Mon, 5 Jul 2021 11:35:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:58848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232597AbhGEPc4 (ORCPT ); Mon, 5 Jul 2021 11:32:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E177E619A9; Mon, 5 Jul 2021 15:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625499019; bh=GsM7kTT8tLZRHnd8pH8qOql2SjIfQ9+HXrYJLfJFeGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4MRL6Lgz0JP99CzmA+jPw/orr2PbAYJVWWqmBryoa0s3vrwmGb5bYvneaq3TbzuI VE4qMTFNlu1ji7VdqhFRJYbdp6rnf0oBQUszSmM4RfT6K2cG0bN5Lx1wPzkT0GvRHx vnmqHztOutnvaNdY+YB+QfG8rmZ95uMUVVWTZn2zLYs1Aers0GjfI38ou9uH9CJ7+3 E083b0O4AaKkgW1H3pi/DyhYurs9UfDwZZErGc9Oi4ue5t6FTcRNB9V4XRzACTQ8OF Jpsp2c1IlHsL/H+BHw6/QtFJQf+Z1/6RTt9oa0634Q/ojcDtlPFHOGjPdgHNUVWSJI oI4vIwB9p2byA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Richard Fitzgerald , kernel test robot , Petr Mladek , Sasha Levin Subject: [PATCH AUTOSEL 5.10 14/41] random32: Fix implicit truncation warning in prandom_seed_state() Date: Mon, 5 Jul 2021 11:29:34 -0400 Message-Id: <20210705153001.1521447-14-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210705153001.1521447-1-sashal@kernel.org> References: <20210705153001.1521447-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Fitzgerald [ Upstream commit d327ea15a305024ef0085252fa3657bbb1ce25f5 ] sparse generates the following warning: include/linux/prandom.h:114:45: sparse: sparse: cast truncates bits from constant value This is because the 64-bit seed value is manipulated and then placed in a u32, causing an implicit cast and truncation. A forced cast to u32 doesn't prevent this warning, which is reasonable because a typecast doesn't prove that truncation was expected. Logical-AND the value with 0xffffffff to make explicit that truncation to 32-bit is intended. Reported-by: kernel test robot Signed-off-by: Richard Fitzgerald Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20210525122012.6336-3-rf@opensource.cirrus.com Signed-off-by: Sasha Levin --- include/linux/prandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/prandom.h b/include/linux/prandom.h index bbf4b4ad61df..056d31317e49 100644 --- a/include/linux/prandom.h +++ b/include/linux/prandom.h @@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m) */ static inline void prandom_seed_state(struct rnd_state *state, u64 seed) { - u32 i = (seed >> 32) ^ (seed << 10) ^ seed; + u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL; state->s1 = __seed(i, 2U); state->s2 = __seed(i, 8U); -- 2.30.2