From patchwork Wed Jan 31 08:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 194573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1744605dyb; Wed, 31 Jan 2024 00:24:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3gZR1Z8Rm8HjDY3N+JoyM5rA1dg5QmR9i+GwqN3onZMam+vMonNZdrxie0/9MLM7z6fre X-Received: by 2002:a05:620a:55b0:b0:783:8ba0:9265 with SMTP id vr16-20020a05620a55b000b007838ba09265mr770094qkn.77.1706689493943; Wed, 31 Jan 2024 00:24:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706689493; cv=pass; d=google.com; s=arc-20160816; b=JAde1k5I2Fx9Fgr/4+OWdVq3CM6ULewETbd6lqb2ytSuKs8DDjd1Hpi296gSBAlzen CXYPa0ugX0RE5vRH93Ke7ee/pIY3jBOwJfHb0j3x/zE2ayvcqGbGCSyT0Qmbv5FKfyAr Ndxdk8bN5ux/enVu80YSegfpt5qpZQxbGy9Mv7veg/lrNWudmDyPiWAX4UJklV3SXvlm Fi/R1xocUrEtVNcTav5RcV0Yto3n2rCILeFMgr7GSuPYzAXtnpK9nC8hcY0O/b0l838H bmCMvHQmBZk8FZ08ohcuTq+eB3+XvhwpSOMYZbey6Rw6UgVjUqLyO/FeOuiuDt89qmaX 1yrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=VlKKphLBogbuT0RBIYdtdc5+J5iprMNNjA2TgZhIPr8=; fh=ais+E2aYIU6t5eWHun7pZ1/ONvkuuZRBPIFlv2o/KZo=; b=FfX8Ljf7ACFOInX9mCGUQWWO6wjI7PGyn1YI2G5vNIFAHBG10PqUY7nqesgYailMa5 ux7QM07Bkm+yrk/MyswuuxjRFV7fvR4V8coMOGWYprcJAeSQi9c8XLVHSFXW66eJbdKq Fd3arKkZuEm/Xxf+ORgGQQGbuOj+kkYMkDPRh6WEkfjtk1mH+x0ZARjPtpXFtRsqDH3T Ox4D5DzL2PTFvY09wYBj3J6cwUEA+sjHNQkQIYK12bYlLqswexgMI0OmwhA9lQplpMZV e3dt5lY7jXIoWH4pTQ5EEJioZSdJP/GYHZ+211bWLSstEIYyCSANOzSvI8QBVsVxZMgp vhdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYIjIA42; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-45990-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45990-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCVZfs1DTr/gBsRYTlOTNayteosmF+LgZU6+3N60+orh5R8Ys/5EG617IMAvmtxEclgZZs3UuHZxG+WXgRAqF4RrLTeslg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i4-20020a05620a144400b00781bd7ade5dsi7130100qkl.578.2024.01.31.00.24.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:24:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45990-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYIjIA42; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-45990-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45990-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B9DBF1C26856 for ; Wed, 31 Jan 2024 08:24:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22DA35DF14; Wed, 31 Jan 2024 08:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LYIjIA42" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDA6B5D72A for ; Wed, 31 Jan 2024 08:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706689472; cv=none; b=amuzNjRjpxMoDAN/0vUW+ypNebzJlgQP37h9lM+8ER7V2zhUwaRp+kX5h2+Er4hp7sL3v+KxhQCXmE3xjf+//bbr6H450kEIyiJGaNaH1TUtNDU420g19VSfdHM24mx43NJ1UKTgvjW8NeZWSvBRf1hjmRgask4mbFSd3Syl7kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706689472; c=relaxed/simple; bh=ZnF7iKo/ZFbGkBB2MbsvheyNsQD3je4DZX7Au09k4DA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=XZDg27InLcCf64MipnlRZ2fxfCO5b+vAWqDTxrZNHVMLkJMBsLYHnS1CvqRrgI6INDGbkdo1SfWXbq0Lv0oc1lpAVMSP9Dp0QxUHvtRhmnqaINE1hY0EikjDCXqqjS1r9Og90ooPV7TkvgayNcIcN2MXtnRzLtML8kDRbObRJ6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LYIjIA42; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-33ae7681d03so2307831f8f.1 for ; Wed, 31 Jan 2024 00:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706689469; x=1707294269; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=VlKKphLBogbuT0RBIYdtdc5+J5iprMNNjA2TgZhIPr8=; b=LYIjIA424ArZUH+A6k1TiLRxSqxKvN+2UragETnPzGYK0XyY/A2i7KxJtNErzRIR3q obmGR+XJOmgITikXmLhtGZUIc143UjrT4xqWmBgj9+dYLCKmCTy2d3sa/lhKCbC9srPm ncVoEeAtyexe4Oq12f/ufI3wv5hc5Ofh2Adfgd+KbHgmk9FhZy2bG8fWxNw6UtT8gopP iunBbS+p7MHmkh+rerDWPHLWSSjeMvlAtT8z4nsn7qKKfl3puDlR9QQu8FLIV8VWXy5+ 3HE+2HIhaza176QAbvU0pqs5DvRXu5GegkWeolkthvbrNcr9FQqFKOQ4ZEyjNctmYSEY ycrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706689469; x=1707294269; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VlKKphLBogbuT0RBIYdtdc5+J5iprMNNjA2TgZhIPr8=; b=S/fv1f3E4/740TREZy73qjE5hVgJ/1K0yrkGsBu+p+vO/mmmDdB6UuTahVhb97kV1H 6csWrLAKeqBr1O9MUGwSbFP3Cho7GLg5VMFIRS9F7HhrrMcKG/OvTOvhLsAeQ6Q9tdYw 0RawgssKBlox/vsRFf7CsDngsiooihr7q7/awqV2f7DheiYSm9xxVT7zzdFlItG7GKne aNwdcMn8y43kBXBCyvYr/PmRjRBlSuR1s1iifqXhqZh/CzCynlf9LtuNRuhOFnt3Qd9g J7QPUyZ0ZatVQ9U3ucuoPZUtWoO+uR1Pfom4LTQaniqWnHMH8KPISxFT1UaQG6DjPvLD uH7g== X-Gm-Message-State: AOJu0Ywug5+Ss7x6qpPSRovojJsKtTCtY9CgEySxXN8fIXcbWxcWWUC2 uft1w7B5bFfIv4Bu4248WCpkbb/4f96pP6MruObGfZ4zE4yXTZL/+umnhLkjkkY= X-Received: by 2002:a05:6000:25b:b0:33a:e52b:5a36 with SMTP id m27-20020a056000025b00b0033ae52b5a36mr470161wrz.44.1706689469111; Wed, 31 Jan 2024 00:24:29 -0800 (PST) Received: from localhost ([102.140.226.10]) by smtp.gmail.com with ESMTPSA id bj26-20020a0560001e1a00b0033ae6530969sm10016575wrb.85.2024.01.31.00.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:24:28 -0800 (PST) Date: Wed, 31 Jan 2024 11:24:25 +0300 From: Dan Carpenter To: Muralidhara M K Cc: Yazen Ghannam , Tony Luck , Borislav Petkov , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300() Message-ID: <279c8b5e-6c00-467a-9071-9c67926abea4@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789593642608097784 X-GMAIL-MSGID: 1789593642608097784 Check against ARRAY_SIZE() which is the number of elements instead of sizeof() which is the number of bytes. Otherwise we potentially read beyond the end of the phy_to_log_coh_st_map_mi300[] array. Fixes: 453f0ae79732 ("RAS/AMD/ATL: Add MI300 support") Signed-off-by: Dan Carpenter --- drivers/ras/amd/atl/denormalize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ras/amd/atl/denormalize.c b/drivers/ras/amd/atl/denormalize.c index d5d0e1fda159..49a900e066f1 100644 --- a/drivers/ras/amd/atl/denormalize.c +++ b/drivers/ras/amd/atl/denormalize.c @@ -405,7 +405,7 @@ static const u16 phy_to_log_coh_st_map_mi300[] = { static u16 get_logical_coh_st_fabric_id_mi300(struct addr_ctx *ctx) { - if (ctx->inst_id >= sizeof(phy_to_log_coh_st_map_mi300)) { + if (ctx->inst_id >= ARRAY_SIZE(phy_to_log_coh_st_map_mi300)) { atl_debug(ctx, "Instance ID out of range"); return ~0; }