Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3551720pxj; Mon, 24 May 2021 09:11:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuhaAC+TqLrbCjWejRLJTFsQHGl0NCYsfbLxTSA/optWV5Ci4LC/PEYozxFGm/OzkPiUrs X-Received: by 2002:a05:6e02:2192:: with SMTP id j18mr18004181ila.223.1621872701957; Mon, 24 May 2021 09:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872701; cv=none; d=google.com; s=arc-20160816; b=O0HhgU54hQ5RSo1YRpO/oMgNGuhrcOPbxOih0UwlhA1BfiwxhvCUVi2rlwgVD+zq1S E8IcclfiZ3Pr5TlXkBWSDG/GLSnEVrqGTla/pnN+KDkIY+H6gXw9v0/3R1DKQJFoOnbt Ji68OWfVR1UxZTUCC/OGyshSCbQvtkNBINp8N3oUORE6h5FBP+ODG+9q41VPN3v3T4qk nXs4LHJ5YvsuqG54rguQz5wAAdEIzurnDlNlb5ifd8eivoz/FxWnGdicvMi+7vzcb59R TIwgdE3k23BEo5dFQ3tEf9S29TTFuztY/r1/Ps4japSwFP8hyFOZx01k6FDzoM81YpVP 7zgw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t7oD8o6YlaId7lQcSwE01onDIVJknueiqM/7K/h1GH8=; b=IjnpaH/q5RHrcLm6bW/5nLFcn6MoJK8oSYVWaHa6BTr08AEeMBQwrwhhM0oVzUHvZx bh3/KLRGwwntYWhqXKBqLza2u+J0h5U3zaa1oDgg8oQFI48up1kZeimsLlIJhRWlleLM 0NOIOzcXPyK2rON/AC77v8xCsPpHSnWFVv7wHrFA5ghNkqR66UQLZTJOrWOOiRgz7Gfz 8EpHjqgsdKArjPYYXGNirgcunG2la9kaITtTfiAHur9wlJwIMk0EHSlp2wz67q+fEx1i URoK28lC8Px2EEDuLQV2CiY1gMiktwa7E3XT6Ffnpicu8T27nfHQ5bc3x6XNyO20y68g DKyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=VwOAs05e; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 19si14965392ilg.27.2021.05.24.09.11.29; Mon, 24 May 2021 09:11:41 -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=@cirrus.com header.s=PODMain02222019 header.b=VwOAs05e; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238554AbhEXQKL (ORCPT + 99 others); Mon, 24 May 2021 12:10:11 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:30500 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235234AbhEXQCR (ORCPT ); Mon, 24 May 2021 12:02:17 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14OFuU53001137; Mon, 24 May 2021 10:59:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=t7oD8o6YlaId7lQcSwE01onDIVJknueiqM/7K/h1GH8=; b=VwOAs05eR0Ez7q86KKN0qZmQ045AZ7G9ZPT/5FDRR/+kRW0BjIbwXmFhYUCRv4qA5NoH +r1ovh1gMEsPc3rasPlmvbCYOxIDRvMvKsp2w1hnlyXz+6+POyLrZv68EI6qhQKRs+hK V7mYuuDIqeMRQEnaU6koZbBpDLc0C3KdJgrrVuQsOGEnets2uDWVInpemS0ZaarL65lg Q/5P5fYMFrUwY0bDNUO5y59ld7MfJM6Jn9IEf1Wfwny21Ogt9RlJ0LjZrgW8wDpZpfcK 8rqvleo+hxnDpYjdNxVsPBdUhVAz1fKux4+tTj52ij8PsfdDqte3j5EGbJkNt7pBpI6g SQ== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 38r7ck8h1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 24 May 2021 10:59:47 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 24 May 2021 16:59:45 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Mon, 24 May 2021 16:59:45 +0100 Received: from AUSNPC0LSNW1-debian.cirrus.com (AUSNPC0LSNW1.ad.cirrus.com [198.61.64.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C8A0B11D7; Mon, 24 May 2021 15:59:43 +0000 (UTC) From: Richard Fitzgerald To: , , , , , , , , CC: , , , Richard Fitzgerald Subject: [PATCH 2/2] random32: Fix implicit truncation warning in prandom_seed_state() Date: Mon, 24 May 2021 16:59:41 +0100 Message-ID: <20210524155941.16376-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210524155941.16376-1-rf@opensource.cirrus.com> References: <20210524155941.16376-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 8qiPNsruat1m2se0mdfX6nMFVPN21Zr7 X-Proofpoint-ORIG-GUID: 8qiPNsruat1m2se0mdfX6nMFVPN21Zr7 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=857 adultscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105240096 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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.20.1