Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3753540pxv; Mon, 19 Jul 2021 08:00:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2y5uEry1cxsxvc7p8DxvOplaDvdL2NR+3iQ9CiXqRDhH8ZtmUzcwnAI6eJQ1iZ7tMM5XC X-Received: by 2002:a05:6638:35a8:: with SMTP id v40mr22905151jal.126.1626706844442; Mon, 19 Jul 2021 08:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626706844; cv=none; d=google.com; s=arc-20160816; b=QcTGyfWJzLHCoEic2vonK3QfeKu7Dhk5+xhwa3pwaowM7dsWz+g+DSu8MQKkMIn0AX Rk1lFzBzHUbdtEnOJAfjEtEkdOp5FZPkmHZEoEXET/i4w14TnIhI1enn1tX4hCOcN/Vr iAAACrhuuRawfDllPeVZ4BBcZs1TWtjIV+R7oCZ4DOkoD2g8m+DocP57sz5o2x0aMg3Z W+jAPEAQSKvRDVpUYl7zYRMmueyrOqjzAdQ+hlyKaBZ7Cv8+MBx9UTxUC8mwGaJNEd17 +LwnGyJOmnmMkZIpVTrKZvO68at857/K+eav15SBU5xmcGwLIx4D0y4mPYb7hZxQClln NTdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Qau0pgdqGrh8zmnnP0vU8bktB+DzU2nBH1fDjL83g0g=; b=RJz1Uqp8wBknWOHhX9IgP6qoK8XJkyz5ZGynr/PwIIJFAdLt7Dju1kLclIg8vYyNph rEHSXz+keLnt08LDHJhGOCqGFZL3gOQPuYo2L4n1D90g4jGK1mR3crSvXOD6F+c9wK7n Wi+2j9faaahbJCmNAzW0fvs4dh80dcgExHJw+Yv5ewBJNl0QXPxlptW2Kfj+N6/t6R3K hMMC8kDpOOSqwqdSMOXGdINI7bH/bGarEn92r0I+u5yfOGTGEY8mTFoBpNIOzNpgca9W h1KjLQNpVtSOWULFxJuXa3zBTtBAlVmI7XRPji00oT2iv5nxRz31q1c9qzY/lNp6nEWn 6ZbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeZyeVZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si23322293ilu.104.2021.07.19.08.00.30; Mon, 19 Jul 2021 08:00:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eeZyeVZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242428AbhGSOTN (ORCPT + 99 others); Mon, 19 Jul 2021 10:19:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:53426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241934AbhGSOSW (ORCPT ); Mon, 19 Jul 2021 10:18:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 272AA611ED; Mon, 19 Jul 2021 14:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626706741; bh=nFiVBD9s1F0BKiFDeyhGID7OC5rzFoiX0HeTvFie4L0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeZyeVZuNzlMaHPbrStN5hV5GO64sZMbDC5aFeQQgQg9ImaXvU2dDIEESAG2gALVo HWLruCouRYoz3orQ1JEfGcEZaLb3Y1bDH2Zpu+G4/O9yhWjA5x5ntA9ouWzle4k0Pj B1DWr98lZfPKjPlDbmMu8+dTmdgVW6qT2Lp6LcoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Richard Fitzgerald , Petr Mladek , Sasha Levin Subject: [PATCH 4.4 044/188] random32: Fix implicit truncation warning in prandom_seed_state() Date: Mon, 19 Jul 2021 16:50:28 +0200 Message-Id: <20210719144923.344948711@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144913.076563739@linuxfoundation.org> References: <20210719144913.076563739@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 cc1e71334e53..e20339c78a84 100644 --- a/include/linux/prandom.h +++ b/include/linux/prandom.h @@ -93,7 +93,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