From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender-of-o53.zoho.eu (sender-of-o53.zoho.eu [136.143.169.53]) (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 94D262AEF5 for ; Wed, 18 Mar 2026 07:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.53 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773820100; cv=pass; b=Wq+9rSZkiepge0+oxdpWwJW4Ez52DjZHMOLpjuwoSC5sGT746P3WyAUawf4eMiRum02tYKoJIBR01Y6AQbxsQiSdiHGzD5uIEE1P9EdEZWqkaDpgGMUm3KtlKarkDPaLALsXbKjzhIIZQJ+ZHkuJTho799dKvg7goVi0RrDoMv0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773820100; c=relaxed/simple; bh=d/FkopeTZTPcUUDNfbiOHnuhe/dEDd6INnI/cHlVAEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uv0lNdMolAESHPe8B9gz99+eGmKdx/+wDVX4CuajHwETd1n4C4JnNfwUb1b5kocpNU63ah9CpIIpSxH46IsoH5qwtxfc/qXk0cc3qboKkQQ/cOR95T7HgiVk3dcZQj3/XhXSRjU6bPsyUIZsfZIm1Z7yno1tQI80iGOTKbEPsR8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=Bn+fQrsV; arc=pass smtp.client-ip=136.143.169.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="Bn+fQrsV" ARC-Seal: i=1; a=rsa-sha256; t=1773820090; cv=none; d=zohomail.eu; s=zohoarc; b=fB50rkATJFuDk/nhNAqysgUaWsbHtRqEsXqXbbQhOib88R2v7iBE/1evrM2lY10OQMIXgQpMzoq1IdRCVrKbg4vq24iMPv0GYhKJ/rrvC3sZlT6DuDu7eUirqyykILX5fBGU5hq3pZupnR7/9uN1BvMIVDxqjYrS0ufGL7gl8Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773820090; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=JKgueNAM/C88TIeionsJTkHQIYU823v+lQ6E8QinU4Q=; b=koJh6p9uEg3wdqjKM02LIKsLWfYXCfbHBvcWBP2ZHiKckGGSrImg2ndNQH2P6NaBOaZVGsTs+CmSgo9/yoZ2ZizcPFMqrMKiigK6ieDm3Dnt6HgGD1STqUYtpsgHFh9iHwsYivNjUCO5aLI+PHGZxASaR0QF3VtZ+sLHLpbl+gY= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773820090; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=JKgueNAM/C88TIeionsJTkHQIYU823v+lQ6E8QinU4Q=; b=Bn+fQrsVCdeb6EBWxmQRGGfdWEf67hBzZyV11mQdZvWEyqFnEwz9JT7myR8UUDbW UXEOAPWGFGhuXB+RDprPfaOboWO941E+HhihXE1nw9IJcy3BrtGHS4d5oHwlhKOQ83O wwjcRju6JatPw0mEsm8HRFSKtIeBx/Argj9p7Bhg= Received: by mx.zoho.eu with SMTPS id 1773820088845562.803101561559; Wed, 18 Mar 2026 08:48:08 +0100 (CET) From: Josh Law To: Andrew Morton Cc: Josh Law , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] lib/bch: fix signed left-shift undefined behavior Date: Wed, 18 Mar 2026 07:48:05 +0000 Message-Id: <20260318074806.16527-2-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260318074806.16527-1-objecting@objecting.org> References: <20260318074806.16527-1-objecting@objecting.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External Use 1u instead of 1 to avoid undefined behavior when left-shifting into the sign bit of a signed int. deg() can return up to 31, and 1 << 31 is UB per C11. Signed-off-by: Josh Law --- lib/bch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bch.c b/lib/bch.c index 9561c0828802..ef733f08082f 100644 --- a/lib/bch.c +++ b/lib/bch.c @@ -392,7 +392,7 @@ static void compute_syndromes(struct bch_control *bch, uint32_t *ecc, for (j = 0; j < 2*t; j += 2) syn[j] ^= a_pow(bch, (j+1)*(i+s)); - poly ^= (1 << i); + poly ^= (1u << i); } } while (s > 0); @@ -612,7 +612,7 @@ static int find_poly_deg2_roots(struct bch_control *bch, struct gf_poly *poly, while (v) { i = deg(v); r ^= bch->xi_tab[i]; - v ^= (1 << i); + v ^= (1u << i); } /* verify root */ if ((gf_sqr(bch, r)^r) == u) { -- 2.34.1