Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp816445rwb; Mon, 26 Sep 2022 06:17:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kWSz7IHfgfcb+besy9Z+mSPhKzAvM63xv9VXF6lCL/GqX/9+bHVfd7/u+GPmw6Yi8uPDR X-Received: by 2002:a17:90b:33c9:b0:200:9ec2:f2eb with SMTP id lk9-20020a17090b33c900b002009ec2f2ebmr25327019pjb.29.1664198241652; Mon, 26 Sep 2022 06:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198241; cv=none; d=google.com; s=arc-20160816; b=NU9ZdO/QB72IGXB3BBUrpQhCUCZ1ro2S3BjsQh49qR6KLGzMWrnjQpmqZ1oG2CseSV xC1457Gu/BHA/WQqj+kFiYE1VyKK8bNngprVwlykgEbjKgBuU9vR0/IRGsGA/ts/4ALn dS5g4/cx3novcY8mNwJAxA+PgGL8TuLwmfjR4iY633EfrUO/0qGPHANvbPqi5fMeVD+I +GTswTPAf8qtpOqKST/Y3c1VXnAbkrhLOSB/i+si1Jvjqf4PM1wPec4fxDiGxh1hrSYF sqgb4Z4GdIItTHx8I0DwbZeN56V96eDJ3p8VlE+JZYJlt7PFJIUsM6ac9Z8TsFhdB9t7 G3tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OpCW5PrEmWut1NC83FWBuluF2jWAjHjLS551lrbBQJ8=; b=pfcynL5oRObprQAWHKqKdl7KaE8IOCZjd18cdYAM/kq57FzwHNf2vmoKgiwgkexK57 pDOKDqUIcXLlkDbL74DTAb4HqisoGwCQU/CWz5v6lV5x3bxEGzVksQzSmQ4mX5EMWrX/ enOP3kkTY12+FtJEkuZPyZGxUO81AJcvi3FgXONKQlCd68zV10lD0lZCl/AS1tbYSKNY BL7vH3MpLLLBoTXc4NhsKigCmAhiO+Dh6agOrzs4pjyS5aNok3iLYbkRQKaubYrZP7aT 6nElA01fOCbvCjgkLPRPfg3mu39ChMqe8uouyNTwqBIWhnqUR3Zpypp1vkzLEOey0Akv 0TrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sodKVq9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f132-20020a636a8a000000b0043c05e17c63si15356145pgc.90.2022.09.26.06.17.10; Mon, 26 Sep 2022 06:17:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sodKVq9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235396AbiIZK2D (ORCPT + 99 others); Mon, 26 Sep 2022 06:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235740AbiIZKYw (ORCPT ); Mon, 26 Sep 2022 06:24:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4097FE034; Mon, 26 Sep 2022 03:18:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E727060AF0; Mon, 26 Sep 2022 10:17:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD9EBC433D7; Mon, 26 Sep 2022 10:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187448; bh=r8IED6lFpJpupHedByKgtomyHTVDFLhpVTD7qB0qhe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sodKVq9DgNDHnOOr7WAjKzoQj1UZegJEUJvvPM7ZystfZctF4RZR4o+TRTSl0oGGZ 55tOFpiySYEn1FQVOVe6u3CtOYjnl5t6anTgWsWceYwY2afTWvlOMhqpMxnZzXmkYk 00/88hbkC2hMr5MietEsrVIbgHa41woPsmTboGuA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaolei Wang , Mark Brown , Sasha Levin Subject: [PATCH 4.19 11/58] regulator: pfuze100: Fix the global-out-of-bounds access in pfuze100_regulator_probe() Date: Mon, 26 Sep 2022 12:11:30 +0200 Message-Id: <20220926100741.816304962@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaolei Wang [ Upstream commit 78e1e867f44e6bdc72c0e6a2609a3407642fb30b ] The pfuze_chip::regulator_descs is an array of size PFUZE100_MAX_REGULATOR, the pfuze_chip::pfuze_regulators is the pointer to the real regulators of a specific device. The number of real regulator is supposed to be less than the PFUZE100_MAX_REGULATOR, so we should use the size of 'regulator_num * sizeof(struct pfuze_regulator)' in memcpy(). This fixes the out of bounds access bug reported by KASAN. Signed-off-by: Xiaolei Wang Link: https://lore.kernel.org/r/20220825111922.1368055-1-xiaolei.wang@windriver.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/pfuze100-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index 8b1940110561..b1d73a6c7809 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -710,7 +710,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ((pfuze_chip->chip_id == PFUZE3000) ? "3000" : "3001")))); memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators, - sizeof(pfuze_chip->regulator_descs)); + regulator_num * sizeof(struct pfuze_regulator)); ret = pfuze_parse_regulators_dt(pfuze_chip); if (ret) -- 2.35.1