Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2204166iof; Tue, 7 Jun 2022 23:07:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9l+JpaCw3kHCl5NOh7KMD4WjV8kxrcMIo8xYUm8X3v1SpmRllWjFi8LhjcbWu/I3nrEPX X-Received: by 2002:a17:90a:4a0b:b0:1df:7168:9888 with SMTP id e11-20020a17090a4a0b00b001df71689888mr71262886pjh.16.1654668466915; Tue, 07 Jun 2022 23:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668466; cv=none; d=google.com; s=arc-20160816; b=YJYGZpB58yI+a0rM3PZ2Sj3a6UeNK1EP5XPRAHcSkQgKAXKcGqp8bY0dfu11NYKrQ0 jFVMTAXBOBSdR617XdFsSo5i7OwMfb7X5oq5xn33c7Ot51w4pwGJ0EJnw7zAPhaYt0di 6VXRdu1iauiI0DPfTmPu0d8vy/QAGccf4XOT+IIXNYaanHmiJ5Ww5JSRyjpdmxzDU3hd TKA1UDxoT+HFDxz2PMBXAkHMRjunmejmq8PAVo6jFD5GD8XdU8zGiLiDP0IA8+nwn7wX GwVrSNoxREvxPyOqQQhY+fjY3MUcK786XsJVK+e2Aw8VCTOXtUdCGRR/354fXfIFMfp6 Zcmw== 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=FjD4vs/RAwLUEoVxv9+kWsgNVMJPA56dd/OLIduceCs=; b=cOypPkckYvZ79C3NqwlXO+MpvXc5YHq09HURKFekftWF4YIHnIDwt0si9NnVsXpR8K bVBCmyQxi56tjtWcGoBZpBNjzY6NUJGInrFr08BS2kr4jeoDPtgWWMdGaB6/xSkwP7Fh XArs82pcRBrvToyM3le65dTZyGxSqkzALbSFMXNyFLwxl1EPS9uSjbtyobG3aE6sRhKH x6aVuTMwudLPXL8Fc5blD1TuiaZi0hgCjLgzpl6ecS7RuOW4hXp3lb5pRfJooRHoOGID tedOyK+EBs9GIEY8Qts4WwdknoxkFJOfGVrRJ3apVFQHqZznSJFFLDaEgbNn4hP0rYXX PB6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FXoOAfpz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i2-20020a17090aee8200b001df4ea7a026si28996608pjz.34.2022.06.07.23.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:07:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FXoOAfpz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 06B4C2B72E0; Tue, 7 Jun 2022 22:31:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386836AbiFHB0x (ORCPT + 99 others); Tue, 7 Jun 2022 21:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383440AbiFGWCG (ORCPT ); Tue, 7 Jun 2022 18:02:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6A524E034; Tue, 7 Jun 2022 12:14:21 -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 B37E861923; Tue, 7 Jun 2022 19:14:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C59A5C385A2; Tue, 7 Jun 2022 19:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629261; bh=Kw55ogd+UksAEvHHk1V0dss2Rjc0d6qyG+RxuJsUNVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXoOAfpzTps+iNTT4DkF2bvxKxShqQkddaa26NT3gnmUgSZPY/+17IztoNv48zpMK 9tcPv+Zp5QcYk4+FOFerUPCcz5CDGw+DnRtBOsvzUesB3/0RmPO+LTp4Quc5hsrMKc /eW0TFEY/HVvncpeyOZrlr3oZz8aIXRw0IOTayH0= 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.18 590/879] firmware: arm_scmi: Fix list protocols enumeration in the base protocol Date: Tue, 7 Jun 2022 19:01:48 +0200 Message-Id: <20220607165019.976475398@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 f5219334fd3a..3fe172c03c24 100644 --- a/drivers/firmware/arm_scmi/base.c +++ b/drivers/firmware/arm_scmi/base.c @@ -197,7 +197,7 @@ scmi_base_implementation_list_get(const struct scmi_protocol_handle *ph, 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