From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 936E346A5FF; Tue, 21 Jul 2026 15:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648911; cv=none; b=Wp0/BZdGYB6hHovFSpRkfjaMecKURtOXN3Z7q//W7YCVn/JiWSLMZg6d4ltiEtm48qnr8di9rthJAyD7OYopsF7jwWRwMJjiKeBshihMTUjxFFx0AQ8OKcfB70IP+2ZU/jODzG8ANko9XFjWm5zx/7vO9FlDVGl0A1e2cNvePPk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784648911; c=relaxed/simple; bh=Nz1aujF9RQt6vvCbu4u+IXW6a9qfniAhrGVE6gZD0Jw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mcVwwldCKeyALUb3eVncvAjr4VXr0p47xI/4qh/arS+zANZqceWKmHO/OAwG9zDSgkjHijv9915dSuTU4Qq1YGsCNkv2/fxOXFEqqYPUeZ6XJ8L3RNjBnIApvCbmVgxN2JRQjNC9VnKM26nbKPam5KcaNkzVg59VY5SLJmytiYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nOqQy72c; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nOqQy72c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA8361F000E9; Tue, 21 Jul 2026 15:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784648910; bh=lm28tb2daByJ/+abuPGrs3v7XT1B73NeWh66Iv197D0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nOqQy72ci8wqMOUIzEF1ad9zIZGJPtNaG8M5YcN8XwNDuf+6/co0yW5rwaSFzDy++ IDbkUaNYmKMR4TFKROxUsHxXKnZCNgNXcEUf1YWQUGCNB7on9stDJnQqKNi0uNXbU0 33NYtDpX5OG3EY0C+Tq2OUCIUWncb+Xf9xR3uamw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, zhoumin , Tony Luck , Sasha Levin Subject: [PATCH 7.1 0379/2077] EDAC/{skx_common,skx}: Fix UBSAN shift-out-of-bounds in skx_get_dimm_info Date: Tue, 21 Jul 2026 17:00:52 +0200 Message-ID: <20260721152601.631797653@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: zhoumin [ Upstream commit c63ed6e1f5fe648a4a099b6717f679999be482ef ] When the skx_get_dimm_attr() helper returns -EINVAL, skx_get_dimm_info() does not validate these return values before using them in a shift operation: size = ((1ull << (rows + cols + ranks)) * banks) >> (20 - 3); If all three values are -22, the shift exponent becomes -66, triggering a UBSAN shift-out-of-bounds error: UBSAN: shift-out-of-bounds in drivers/edac/skx_common.c shift exponent -66 is negative Fixes: 88a242c98740 ("EDAC, skx_common: Separate common code out from skx_edac") Signed-off-by: zhoumin Signed-off-by: Tony Luck Link: https://patch.msgid.link/tencent_2A0CC835A18366643CBD2865B169948AB409@qq.com Signed-off-by: Sasha Levin --- drivers/edac/skx_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c index a9557c8344bc13..f15de0ea96c87e 100644 --- a/drivers/edac/skx_common.c +++ b/drivers/edac/skx_common.c @@ -466,6 +466,9 @@ int skx_get_dimm_info(u32 mtr, u32 mcmtr, u32 amap, struct dimm_info *dimm, rows = numrow(mtr); cols = imc->hbm_mc ? 6 : numcol(mtr); + if (ranks < 0 || rows < 0 || cols < 0) + return 0; + if (imc->hbm_mc) { banks = 32; mtype = MEM_HBM2; -- 2.53.0