Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp826506rwi; Wed, 19 Oct 2022 03:32:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7gPNX9q17wvGqbjNThZxL9fA33+Q6QfGnc7ewa8INJWDhmvtvZETajw50R/nfSRHOES5oM X-Received: by 2002:a63:f924:0:b0:46b:1a7d:3b91 with SMTP id h36-20020a63f924000000b0046b1a7d3b91mr6736774pgi.133.1666175577226; Wed, 19 Oct 2022 03:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175577; cv=none; d=google.com; s=arc-20160816; b=QeD6mGH5dvgh/6rk0J8Sgx/jEg6FuMw96c0rVAbIcNqv6x4JRxCcV1yVZnCD2rmsns h5yc9dx4kCemNdmT3fOhK6IJ3oRUtk0oyzvkSKBzP+9Ta+MM3EDVdkr83nF/S1nUA/uj NjXA/i4xcNOZ+5LCdlRD1jndd4rQyNLr7gv1ZnxY6JXx0ZsorUAwdKiOi6aMOcfSrHzR nJC6p93pzX3ClrUenE+nUNzEpPM1xM57MoBDqk1OEvcDvu3Zr5GrVJHL9aC74QqlWPY/ Cv0LC/xWNlIlKml6QRYTdvZ/CPoLmvBldsGyaM203D0Px8kXkJOa/6QwFMNpCvaFOkP/ Nnzg== 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=mbeuuKyS1JYr9BJ4A8TldBavJoN2bhxICYGV6ZtSC3g=; b=K0xi1PlDgNiATbAd/m1+/MdhgKs3nGUTYsu5DhcDHZY8wttPaFN9TeFZgLEzlP3hLu T5GgUiXBe9ZxKUGByYl664Mk7fHbpA8JfcxS4+iBsKCI/fZRPkG/n0ehufvjvfnI9LZH uwXRIsdvkeqqMIf4pgfhuMCrynyW1H8FbZg3zpY3dcTOcHerK8uYvmsZK4IlU9tUce6l Q5HxniznropTIUqTU/n6SIgZrKiCwLR1eO2VtoZ+METz1gFBzywxgMg9NAFCTXgTTKeH dVbUAHOxwPbqL+2O5cOagrH1QI710g1VogvWEAMyCIR8KtysSybBwjh9R4tAirhjUCJ2 Csww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VJ6uXsN0; 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 r7-20020a056a00216700b0053e15843f1fsi17030932pff.131.2022.10.19.03.32.45; Wed, 19 Oct 2022 03:32:57 -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=VJ6uXsN0; 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 S231301AbiJSKG1 (ORCPT + 99 others); Wed, 19 Oct 2022 06:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbiJSKFy (ORCPT ); Wed, 19 Oct 2022 06:05:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE29229; Wed, 19 Oct 2022 02:44:19 -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 5B957617EB; Wed, 19 Oct 2022 09:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F2E3C433B5; Wed, 19 Oct 2022 09:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170837; bh=PyVuP224LTfOgKeY7PGhWDcswJIc+RIZ/ujbhn1tRm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJ6uXsN0P5w7KkgvZN2wCYMpmIPGwPYvL/iKnjPgzGgvbqEXhYPB4jH4tBfmsx2E6 f8nE7DiNxjQ1byFgzCdr8/IHEN/5LbQVvy5r7cjf5pCzeG28fM9kn5dqbiyNcldXPv ZAMHwVjcXSH8D7h6RnIEAucV6ZNLotlvcS8qofaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Yongjun , Michael Hennerich , Sebastian Reichel , Sasha Levin Subject: [PATCH 6.0 805/862] power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type() Date: Wed, 19 Oct 2022 10:34:52 +0200 Message-Id: <20221019083325.471951056@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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: Wei Yongjun [ Upstream commit 9d47e01b9d807808224347935562f7043a358054 ] ADP5061_CHG_STATUS_1_CHG_STATUS is masked with 0x07, which means a length of 8, but adp5061_chg_type array size is 4, may end up reading 4 elements beyond the end of the adp5061_chg_type[] array. Signed-off-by: Wei Yongjun Acked-by: Michael Hennerich Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/adp5061.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c index 003557043ab3..daee1161c305 100644 --- a/drivers/power/supply/adp5061.c +++ b/drivers/power/supply/adp5061.c @@ -427,11 +427,11 @@ static int adp5061_get_chg_type(struct adp5061_state *st, if (ret < 0) return ret; - chg_type = adp5061_chg_type[ADP5061_CHG_STATUS_1_CHG_STATUS(status1)]; - if (chg_type > ADP5061_CHG_FAST_CV) + chg_type = ADP5061_CHG_STATUS_1_CHG_STATUS(status1); + if (chg_type >= ARRAY_SIZE(adp5061_chg_type)) val->intval = POWER_SUPPLY_STATUS_UNKNOWN; else - val->intval = chg_type; + val->intval = adp5061_chg_type[chg_type]; return ret; } -- 2.35.1