Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4490099rwb; Tue, 6 Sep 2022 08:13:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nz8EeFrImXcE7yUcYJQpqCp8BdH0HNtz3HmYIVx7VnU1YOuKAESkmh6BQz2L+aBD9K5gh X-Received: by 2002:a17:906:58c8:b0:6fe:91d5:18d2 with SMTP id e8-20020a17090658c800b006fe91d518d2mr40338543ejs.190.1662477188819; Tue, 06 Sep 2022 08:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477188; cv=none; d=google.com; s=arc-20160816; b=O2uJ3MFdS1CDMXZDLKnGxdMdqMPzHANNXsb4TDGyCn4BEmNuMlj6rZmOurhiJyV2OR oK7+RWpzrgtJ8PxT/dSObdyhLENYKZ2y5/D97A/3GwSJmufGAYErxm+RkaBf/4FZELYh xzORKWVv4V7g2YYibqIv1FeaPDBaCWaCZ51Ojn31a1De8cIMFJDNxeNMual0snYQGwLN cOxUR8oHc6w68lJ82eKyf/sIHYkt4t3ZZZkpIpcoZM4TUckYu2A5ziVNciWmPxAm9b3f lARqvwTE3Q+ifn1sviVTlXEPOl+GipeFRgMxIAyADbT8ta2wS1W0ocYlG1sZ0Cy6Q1rb /6Eg== 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=Qo7/SUnrAstz5hMtvRqXmeTc/qeqA6uZvPOZvcQQxUQ=; b=XrER9plzCjRmycjzhh4JjskGas69aR1/SzEynPSRqcgB5Y5jJqdaXsULarEGvVwmpj 08Vz+4/1VXIlxfq7E/+RFfUm+Wf6/h4yoPDsknm5AI8Cdn8+mYdlYcUHfb6L2h1redsw B5dVM7JXGxWUnv4ZMor9oU5MCcz2ojOjh4LR8aB3kJQphn62p0DNXe5dWSBL7pdg9Gq+ tt2gjnaxNeWa/zKlNO3K5ZFvvPD1xRorApJIhLoHF2Kdnd1S+43rbJVy7x4JGwekIPDo +guhhm/1Fw/0e48vQ1TjtL+qDfdSOgVPq/prDVVcpZ9TzbqPFDxDS/jY2YVDtYLpchkk NUqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="o/u4hkVM"; 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 t29-20020a056402241d00b0044e9f2b1df9si3539382eda.151.2022.09.06.08.12.43; Tue, 06 Sep 2022 08:13:08 -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="o/u4hkVM"; 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 S240431AbiIFNel (ORCPT + 99 others); Tue, 6 Sep 2022 09:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240652AbiIFNdu (ORCPT ); Tue, 6 Sep 2022 09:33:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06BA7792C3; Tue, 6 Sep 2022 06:33:11 -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 101976154A; Tue, 6 Sep 2022 13:33:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0645FC433D6; Tue, 6 Sep 2022 13:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471190; bh=ZhllgM/u62vQ6ni2nTKw2xtAWribG4BtnEkaGvqdINw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/u4hkVMeKbeZZUQ1tfw0U8M0KZG2ujJhsdVDHO6v2hkCD6BZ47A9JJPV58yOKaS5 n4g9jm3HM4CmJLPCNMMOEKwL5e3UkHGK11IYwPlwXlK6bckaOR8HpVOXlGjcV1dFvc LLI2ivMQ6F6BELlv0bG+wU1InxQatT7UlVl/J7p4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 5.10 29/80] misc: fastrpc: fix memory corruption on probe Date: Tue, 6 Sep 2022 15:30:26 +0200 Message-Id: <20220906132818.163361501@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@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.1 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: Johan Hovold commit 9baa1415d9abdd1e08362ea2dcfadfacee8690b5 upstream. Add the missing sanity check on the probed-session count to avoid corrupting memory beyond the fixed-size slab-allocated session array when there are more than FASTRPC_MAX_SESSIONS sessions defined in the devicetree. Fixes: f6f9279f2bf0 ("misc: fastrpc: Add Qualcomm fastrpc basic driver model") Cc: stable@vger.kernel.org # 5.1 Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220829080531.29681-2-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/fastrpc.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1548,6 +1548,11 @@ static int fastrpc_cb_probe(struct platf of_property_read_u32(dev->of_node, "qcom,nsessions", &sessions); spin_lock_irqsave(&cctx->lock, flags); + if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) { + dev_err(&pdev->dev, "too many sessions\n"); + spin_unlock_irqrestore(&cctx->lock, flags); + return -ENOSPC; + } sess = &cctx->session[cctx->sesscount]; sess->used = false; sess->valid = true;