Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp584248iog; Mon, 13 Jun 2022 08:35:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPb4uXVdUPD9cPT+mOCrjkOJhb/XUeVbFZ4ftUKygNtRkEXoys+4wXw6khB+rZRgedUrdm X-Received: by 2002:a05:6a00:2304:b0:4fa:7eb1:e855 with SMTP id h4-20020a056a00230400b004fa7eb1e855mr196179pfh.14.1655134541699; Mon, 13 Jun 2022 08:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134541; cv=none; d=google.com; s=arc-20160816; b=QtyrEdo4IvxRazGONjW/lH37j8DZA2kumEvdwVFwImrhcCftC17hPRBIZzB7y9YBZM HsHR/opv4dCgeoYObp03IVyJP9sowHFp8ZADl476CMC4qZuKMS0Tz6KK8hCqJlMny3KE lUrdxwMcTkmHhpNmQNzAJt6w3XqZaMBiHNYKrTpgj/bMKpg9HCcnGDOSXw1TYmxz4mVh pqYT2QTtEO6cLkELWu/JC39vXZG/qgMEVR3xU8vVgeMKqWwPH5ODUGrsOuqj2sSXpGLl 5WoJtHpk837mS6rmlBs34hPnD8J3XpPdKg0C84hioVOFn2aQ6mZ5dWbT0emQH1vw7dt/ BJ+Q== 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=8zJ3bl7fFyHOrc4bz59pN8xoHYuewzCvMg10Xra/EBY=; b=ZR2wv+nGRGITp4i82PDOYB1fCTPo5UYd4+/W+KGGcX/tU88B2hWfSks73rXB2qacfN kgKHYCCO5XBJU3XLkv39bfks8PRuiW7LSfoVJvJ32nzEYI3aSoN7HDcQZheFWg88u3n6 h9XtNhb7s9Af/p8tFUVgDTYOHWh+OmVrHQg82g2YcBOJHTWrcKcD86ycHeAIJzcic3cq 2FnIA1W97cHaioFHDoM1PsXqOPXojjXDvvZ7cVtrxbVE4iZBvFn4aSd3HkZDvKtPVpzE TEpb7l9deH4Ko+rg9YcXPfAbDBwssWLuhNZIHM+kbcJNkTBbYu4qP/S5vf0PbD4roxUt VaBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qco+fW4n; 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 mu7-20020a17090b388700b001e2734dc84csi15860046pjb.184.2022.06.13.08.35.29; Mon, 13 Jun 2022 08:35:41 -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=qco+fW4n; 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 S1357287AbiFMMAW (ORCPT + 99 others); Mon, 13 Jun 2022 08:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357763AbiFMLzR (ORCPT ); Mon, 13 Jun 2022 07:55:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B962F39D; Mon, 13 Jun 2022 03:55:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id D9127B80D3F; Mon, 13 Jun 2022 10:55:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D94FC34114; Mon, 13 Jun 2022 10:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117749; bh=aBryxu95SUys3cofpp8Jd6WioAKJmUtwiJY8HRaHZ2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qco+fW4nyyk8BWdLwncfMdTtVg3rr2TndtTX00+hBr6JbrFfcu05b0x3pWEuCAo9k BkfazBuAk+dAzFZ188g7aUH1jT0h4ODKwbP7x/gpQ4y5ONCPl7/+9bw4GWUa/nFD03 /mKClNtS1jbsAiNqPXX5ChbgQwLll66+im9/Y7hQ= 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 4.19 118/287] firmware: arm_scmi: Fix list protocols enumeration in the base protocol Date: Mon, 13 Jun 2022 12:09:02 +0200 Message-Id: <20220613094927.457190992@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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,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 From: Cristian Marussi [ Upstream commit 8009120e0354a67068e920eb10dce532391361d0 ] While enumerating protocols implemented by the SCMI platform using BASE_DISCOVER_LIST_PROTOCOLS, the number of returned protocols is currently validated in an improper way since the check employs a sum between unsigned integers that could overflow and cause the check itself to be silently bypassed if the returned value 'loop_num_ret' is big enough. Fix the validation avoiding the addition. Link: https://lore.kernel.org/r/20220330150551.2573938-4-cristian.marussi@arm.com Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol") Signed-off-by: Cristian Marussi Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c index 204390297f4b..95d892db0dff 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -164,7 +164,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle, break; loop_num_ret = le32_to_cpu(*num_ret); - if (tot_num_ret + loop_num_ret > MAX_PROTOCOLS_IMP) { + if (loop_num_ret > MAX_PROTOCOLS_IMP - tot_num_ret) { dev_err(dev, "No. of Protocol > MAX_PROTOCOLS_IMP"); break; } -- 2.35.1