Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5090766rwb; Wed, 17 Aug 2022 10:52:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Pk5lJw9m6lE0Kl2dDrmWSjRa0XDKFxYT17XHj5hqVn+kvlDH/wVPcuLAZHcs7FDc4W336 X-Received: by 2002:a62:30c7:0:b0:52f:9a31:5935 with SMTP id w190-20020a6230c7000000b0052f9a315935mr26699921pfw.14.1660758769365; Wed, 17 Aug 2022 10:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660758769; cv=none; d=google.com; s=arc-20160816; b=J6/FW8m8Z4Qxwih0vi0Jxkw0lhqU2rN3s2/qnAmf5qerD/kMz+qEHR/u8aAvY0cdx+ fcJiUvb4EZPOKDbq5wfspGmYpGjVOVpcq66flHKvpq6mpQa3dSBe3FCvzK0jL+4hC+zd LfsuPbWRlE2DJl9sA2zK6HPMq2jAydZk2yxLtXRsRoXf+sT2/mbATj+oyPyOLqThYZsX ktM99h2lGg+MOTkCc7GgJnH+LS4BS6cFACDRgyd+zah2R6/9KqzTEY+6Ols2ZJWTa+LU tilMFE1ZFUk2COiYTGKhygnzeUh0Wxx2C9BIS2xk+nERRb3uhnzAmCwkt/pFQ/i9q79A wVrQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f/8Pq0XP8uP5jiiYD5jXj8MZZmTBgr0CaV7VyHpSmi4=; b=CS7jZMA8d8ngWMe3ZOgZVQNeeExqB7bjQklIjC8wyBn+ytXdKJOKF4dHJMcZ9A7NB8 5vOBPo0WRFEjsvsTfI9wmFc0iVjoiTApJN1F/QNDg9mmxhTOVt87eYDiWEJ/4jrkYMi5 +ojyxlHuYTsAHQj4Xx4QqveDB8nMQCx+XUdfRGTX9yx6DN5gRcmSzh7Vfuh5g6mVw3XK 4yC8RauId4j9s3LhC8q1e9kwFKMI5ajSz+RXrmu0xuAz+EZAFlgpVxv32p/RUVMxTxzm UsNvGnf38Q9AAoIbfz9MDPc2NkdaBzw6rhS+Nl5+6zQT1ipU5/YN1Ma3226uvXz8VRvX whoA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a170902ef5200b0016f12cc0ed0si316388plx.208.2022.08.17.10.52.37; Wed, 17 Aug 2022 10:52:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241198AbiHQR2K (ORCPT + 99 others); Wed, 17 Aug 2022 13:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241051AbiHQR15 (ORCPT ); Wed, 17 Aug 2022 13:27:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D1A8A1D30 for ; Wed, 17 Aug 2022 10:27:56 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5DCC8113E; Wed, 17 Aug 2022 10:27:57 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2EC03F66F; Wed, 17 Aug 2022 10:27:55 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, cristian.marussi@arm.com Subject: [PATCH 4/6] firmware: arm_scmi: Harden accesses to Reset domains Date: Wed, 17 Aug 2022 18:27:29 +0100 Message-Id: <20220817172731.1185305-5-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817172731.1185305-1-cristian.marussi@arm.com> References: <20220817172731.1185305-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Accessing Reset domains descriptors by index upon 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 in front of such domains descriptors accesses. Fixes: 95a15d80aa0de ("firmware: arm_scmi: Add RESET protocol in SCMI v2.0") Signed-off-by: Cristian Marussi --- 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.32.0