Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp830733rwb; Mon, 26 Sep 2022 06:27:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Fa8QN5LPEm3gqW2jLIbJwUQ8sUr2Wv9yvgJxX01mPKifE8Zx86so6ZMyEav0MpsvV6XJ/ X-Received: by 2002:aa7:c610:0:b0:44e:9a0f:753a with SMTP id h16-20020aa7c610000000b0044e9a0f753amr22074471edq.140.1664198854150; Mon, 26 Sep 2022 06:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198854; cv=none; d=google.com; s=arc-20160816; b=Kfy41F77qV5XWDxhSAezS+6JepHe6GKjQJGVcpokAMjr9xw2Gx6uvs8RtN7LeRrm7r /VlQZqfkGAUSTsR+sta6Pcpw15OnKiMN/oi0eIBE+/t6exqWSSvUqejVGKF9y7E56Kni Y5G1KPEEovoFVVa31o1rqjGww5WRwWxPtALZwMQ+CDLX8XoItzLwbJwbcnzKL840TEyh RIHszmz7SXVJJJf2qGukbsFg4Q5RAPMfnppk+yrnbYz/othG1jSMpMhqhd0ZyPNBWsEv nvv9v41CZl4CuRn2AZxJbaNaagxCOfEullnXtxXn/OdVsa1peNL30R2dlcugdFIR9m9y QItQ== 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=YocBdHC32oQyrsGMlMQpFiit7EvlFfy1+4U/w1WfMB4=; b=AU/bUqhU+lKrfpi8tNbpwD/KVav2PpfHfqAJQXO5OYaBwdfDYzjmyjuiZZ2ewZobQk yuY/KPrJ34ePVVvJK5et8jcyfeZhLAeBq6aC67IS/t43TxcY2R8Ggs3t0lfseVhT5d9x uaKT9EswralkoPlFHy163cxJSETG9N33VjhNguwVUoPr14aqd9ckWsPjpVrQuvCT09oq j9QxKDUCPFsvb17Zj7DtDqoK20kCD4WbrZrHvnukCXmlUNCNjST4mkgsDv3gIUhwLg03 1AiviYhLga/AWL77JKY2xCiKGipReUW22ATzjXux7RpFSnzb+mYs2HJOBhqfaawTYHt8 0Q9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u8NCbVYG; 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 h30-20020a0564020e9e00b00456ff7eddb3si5677779eda.534.2022.09.26.06.27.01; Mon, 26 Sep 2022 06:27:34 -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=u8NCbVYG; 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 S238712AbiIZLrB (ORCPT + 99 others); Mon, 26 Sep 2022 07:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238593AbiIZLoG (ORCPT ); Mon, 26 Sep 2022 07:44:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B757B72EE5; Mon, 26 Sep 2022 03:46:29 -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 8A80C60B4A; Mon, 26 Sep 2022 10:46:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89234C433D6; Mon, 26 Sep 2022 10:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189189; bh=oHJrHC5swQbQx3rRPj9uqKWfZmoJftkitufj0CnE7hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8NCbVYG91ui20vQr2PP5099jwegd6AvStthRmuXdsACykrqxYd04yoeNhANxiGze nBZc4+c2XFZgO82fShGW1eB15Vf7dbC5z7jYgWClpsxgzeWi50BvWYitOrrbIWUN4Y 0PrbTO2YjsQMLKNGDg1G5P360zMFmqvc93xvGo90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Sasha Levin Subject: [PATCH 5.19 071/207] firmware: arm_scmi: Harden accesses to the reset domains Date: Mon, 26 Sep 2022 12:11:00 +0200 Message-Id: <20220926100809.774457281@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@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: Cristian Marussi [ Upstream commit e9076ffbcaed5da6c182b144ef9f6e24554af268 ] Accessing reset domains descriptors by the index upon the SCMI drivers requests through the SCMI reset operations interface can potentially lead to out-of-bound violations if the SCMI driver misbehave. Add an internal consistency check before any such domains descriptors accesses. Link: https://lore.kernel.org/r/20220817172731.1185305-5-cristian.marussi@arm.com Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla Stable-dep-of: b75c83d9b961 ("firmware: arm_scmi: Fix the asynchronous reset requests") Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/reset.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c index 673f3eb498f4..b0494165b1cb 100644 --- a/drivers/firmware/arm_scmi/reset.c +++ b/drivers/firmware/arm_scmi/reset.c @@ -166,8 +166,12 @@ static int scmi_domain_reset(const struct scmi_protocol_handle *ph, u32 domain, struct scmi_xfer *t; struct scmi_msg_reset_domain_reset *dom; struct scmi_reset_info *pi = ph->get_priv(ph); - struct reset_dom_info *rdom = pi->dom_info + domain; + struct reset_dom_info *rdom; + if (domain >= pi->num_domains) + return -EINVAL; + + rdom = pi->dom_info + domain; if (rdom->async_reset) flags |= ASYNCHRONOUS_RESET; -- 2.35.1