Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4869847pjb; Mon, 27 Jul 2020 07:15:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiMBczxkpY3UKmDCT4vOANiPO/Rs1I/lJ4qf3Kev02X6OCX8PgriDTLxzv+29A2qzNm2TJ X-Received: by 2002:a17:906:3f82:: with SMTP id b2mr13078358ejj.240.1595859308727; Mon, 27 Jul 2020 07:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859308; cv=none; d=google.com; s=arc-20160816; b=AwfnRCs8iRNqL3PrgsquRvbR6haeC+BzeMIlVzCoPhzOgNowuwxrzfvDyW1QEu4EAD V7q9plnqMgZ5t6+Nhna1NLGmsqIb32tOmmxqco41YEBOwy7L9wfIRb8w/ZinBdFhzYBP 92xOIALVN8rA7uh7ElmLnpxEU34tU/W+ZGCyG19cPjPIKprOyXSw5yjD8wfdcl2xt5W9 wuygoPpiKnmT1n0b74UutnI3ZvWTeZB7L5DsJ8epO7sveTVJ15zD12t2iPtAyxOgywOD auTJVsnHduRDXXLbcAlAi9StXRRdM5XMe/GVJRTEuayRdaFlMLL30YVLDcpGrahnb7L/ gl4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7LYjyz91DOcNM8zxGbHNa2U5KJchEAD6beyMePYFmtw=; b=ZmMY4UKn1GFMkoLgZXqBcmcJQERUW2KvRTR+h6PctbXcnC7l+ChwNathIZkPvTom5L ycqa+rQwMstUOb4uy5+YtIv+5mNjq0jQMa7iKcA1Sp2HEyLmaCWxhsfixRxbiE70ZHtv XTj5pEDyhsuOX2AaoFqOOqJPg9Fed3QDimmSiod/A4wo5A129keLstbZMXodujyb45Ou JO9hWbGTOYeNScZGOjwmyFEtZJ3c1b9fpycH51fS5vLaW92Iftziwl3d7vSBqflwkVw+ 5vA/f7igcmKsozVduo8BEbhvsEaJo/gtaYah0/rYnC7GBNUoIisxVZ7INUd2jy5hKM3i Blfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vAJNYLhs; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c64si1716213edf.114.2020.07.27.07.14.46; Mon, 27 Jul 2020 07:15:08 -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=@kernel.org header.s=default header.b=vAJNYLhs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbgG0OLS (ORCPT + 99 others); Mon, 27 Jul 2020 10:11:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:34770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730000AbgG0OLR (ORCPT ); Mon, 27 Jul 2020 10:11:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B21D21775; Mon, 27 Jul 2020 14:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859076; bh=SAMDObAPKgoZIXKFTKFMdIp+C1FyCwxF1h7AKrbE8qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAJNYLhsXn+tz0SZiHd9iXLKHKQPNFOftrMory1O0kcJ7kT111ERDuENvaORE7BvP adT7yBqzjVi2Rj6jlC5bO3lXqEtQ9uTaHM9ywRg4CIQMk1N1c1PZ8H04F7THW6bYUz j4Mlm3dslyC9qKoXC4+FTUQVf5/CXqVUzopk5LE0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Guenter Roeck , Sasha Levin Subject: [PATCH 4.19 57/86] hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe() Date: Mon, 27 Jul 2020 16:04:31 +0200 Message-Id: <20200727134917.285414070@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cristian Marussi [ Upstream commit 3ce17cd2b94907f6d91b81b32848044b84c97606 ] SMATCH detected a potential buffer overflow in the manipulation of hwmon_attributes array inside the scmi_hwmon_probe function: drivers/hwmon/scmi-hwmon.c:226 scmi_hwmon_probe() error: buffer overflow 'hwmon_attributes' 6 <= 9 Fix it by statically declaring the size of the array as the maximum possible as defined by hwmon_max define. Signed-off-by: Cristian Marussi Reviewed-by: Sudeep Holla Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/scmi-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 91976b6ca3000..91bfecdb3f5ba 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -99,7 +99,7 @@ static enum hwmon_sensor_types scmi_types[] = { [ENERGY] = hwmon_energy, }; -static u32 hwmon_attributes[] = { +static u32 hwmon_attributes[hwmon_max] = { [hwmon_chip] = HWMON_C_REGISTER_TZ, [hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL, [hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL, -- 2.25.1