Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4879259pjb; Mon, 27 Jul 2020 07:27:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaEuz7KEZwsXsiuJWfOZprPbEO93FtVu89A3g0bM0d23mgxvYyxQ9+HtC7Aoa7DDebbe4v X-Received: by 2002:a05:6402:683:: with SMTP id f3mr3263951edy.71.1595860039114; Mon, 27 Jul 2020 07:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860039; cv=none; d=google.com; s=arc-20160816; b=MIAKaZGRsfc5XAtyeyl7bAQqDpCPzNlhEyStWqRnqYR71iRgg6R3ceMMzgQbLFwaRc 1vbKNofmFzs3mU9kFuIxujZiUCXNzDPhpg9C5AKob9rTq0LS31HKQ7EQEKgepjvskV9h o/CPtB9loRVsEz4erKFdIuLjlsiqlNlNhM4O2vfJVpRS8MNLIdfXM1rNTo7fHSflruBI ssxTNxOxC8iMECqY6EZcKTjfkcaPFPQCxoNlFqxa89PLVc6qpOb7BbxHIWHuTueC1QmM Q2cxBP2vdyeozk8U4QXqrkmoXc/sRMouEkniecZzzrT4EglvcEZjz+GxLMaxN1NdyTZ9 9lnA== 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=anW6K6Dh+ohekOa4VdiXEofJ252MHhhmLYtTwiJwo2Q=; b=zOKWZ/UxRIuaeMJYRRJNhbZF/VsCPzssgT8tLibDOpCnkU/83y5r7Yc9m4gse9YNIE +RHr+nR1F9/IKebUQuDmNQ97snjPqdjkqndCzUa253A9yDOhoYi94cksDcxqQ26cgPnp dbx1ch0MDeMGb0dtllGEJW+Znf9MQw5ulst9dQnTbB35Jvmd8pDzfEDIbG71PbmA3zEi KGW7a2EJG3rNFFmlh+Nx6J48+MBgk/MwHPJy/mSNyhIfDG4nocRcWUO/MQKpAEfg6L8h 2t+K54iN1qPUvhWojlQ77RdD12zT/nzqrjOT3fsrLea29UMmpPpsiGoFWo9QMfrds6vg bAXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nqTHJ1WT; 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 i5si5868861edd.112.2020.07.27.07.26.57; Mon, 27 Jul 2020 07:27:19 -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=nqTHJ1WT; 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 S1732117AbgG0OXg (ORCPT + 99 others); Mon, 27 Jul 2020 10:23:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732106AbgG0OXd (ORCPT ); Mon, 27 Jul 2020 10:23:33 -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 ADF942070A; Mon, 27 Jul 2020 14:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859813; bh=Fdxxx/6s/07AQaFKa9HaHxd0Er/Fjo+qamSOf3sgGZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqTHJ1WTEUp4OcDKrvPp/cbz+RPsDPm0Au2OqLDr7/jxrNubHYgGS0NYHEyoPRdD+ LZZrUgpI0XVVpYAitAIrXhV/gt3wzbAJqiFJdrzF8VQERFNp1rFRfTsGwIkI5CMQzZ Q2HcSRT7mtPAZtarws06+IJjY2ZPEWw4wHfGc7IM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Novikov , Guenter Roeck , Sasha Levin Subject: [PATCH 5.7 114/179] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow Date: Mon, 27 Jul 2020 16:04:49 +0200 Message-Id: <20200727134938.207084422@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@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: Evgeny Novikov [ Upstream commit bc4071aafcf4d0535ee423b69167696d6c03207d ] aspeed_create_fan() reads a pwm_port value using of_property_read_u32(). If pwm_port will be more than ARRAY_SIZE(pwm_port_params), there will be a buffer overflow in aspeed_create_pwm_port()->aspeed_set_pwm_port_enable(). The patch fixes the potential buffer overflow. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Link: https://lore.kernel.org/r/20200703111518.9644-1-novikov@ispras.ru Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/aspeed-pwm-tacho.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 33fb54845bf6d..3d8239fd66ed6 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -851,6 +851,8 @@ static int aspeed_create_fan(struct device *dev, ret = of_property_read_u32(child, "reg", &pwm_port); if (ret) return ret; + if (pwm_port >= ARRAY_SIZE(pwm_port_params)) + return -EINVAL; aspeed_create_pwm_port(priv, (u8)pwm_port); ret = of_property_count_u8_elems(child, "cooling-levels"); -- 2.25.1