Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3294520rwa; Tue, 23 Aug 2022 02:10:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5zXMxb8Zh6t1r4SUxqvxKlXr8NbxgOXLYGh1dlBQC3C2w0/mSCbNiaGNyv7fwmGpJW7q8f X-Received: by 2002:a17:907:1c1b:b0:73d:6a20:5664 with SMTP id nc27-20020a1709071c1b00b0073d6a205664mr8925713ejc.583.1661245805318; Tue, 23 Aug 2022 02:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245805; cv=none; d=google.com; s=arc-20160816; b=W6y5/GrS5YCkz10h96mAk9WNHItADpk7EMXnmUj6pJW8cJNVLeVWipIv2G/+W5fM4O n++AZwrIQ6MQXKkVxLOWrPMM80BDNZdyxsJjK1BRWE6aZERAqCGM+hHHcQyG/hU4fCCj Q4nIIUUASW0LyAPebL/fuukxiWfb0LImACMv3OqtaelGMI0brS3GcGSwwxzWSeTQcYhL sNuCAVM6nOrAb7BpVpa/SDnD/g+Nj59VRajijq4NjPqSD8CSqnHLO/+qn6HQoIYy0U3N XZEQX0q7Xg+yLsTwv78nWJu1j1v5f9TTKdScC/Vwlu9E5oJYoA2QHQAUsVe029KHIhW/ 1HJQ== 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=7lVgZAH5ExE0toDNsWH02jTiBnmtuY3GrE4iduY/tA4=; b=PWTndj8DyYPDEQ5xAPZrDURmlFcT9Jfcz5Uhp+bs7XP4WxVVQS65ONSGWtDaFTxvU4 pvQDW1QBJsyDYvKIwveXDiStB0h7YZ50joZjvUdnNvcV5r4cVgEwF05VPs21Q9I0Uv0h O++EQKBZW18ur/vKefW1/uHN4hfsBDaEtz04JycDlVGgBoEkhwBqePhd/qlNhXS9qVPl sqQa6HnJB/YkdC1kq+FMXGNgaxRPU80sPGp4UAXH2xqPcwgKSGyWAfeF79z7MTNA2yWa +I3UyAi2DAiZeduRQE0zfVB+dhYzinNkmGKKhAz/kzwnqtb3A/nxEIGb8qD21yWmHS93 ljzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="d1I/Ilwy"; 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 ds9-20020a170907724900b007387740b9c5si11002837ejc.22.2022.08.23.02.09.37; Tue, 23 Aug 2022 02:10:05 -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="d1I/Ilwy"; 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 S1347711AbiHWJEE (ORCPT + 99 others); Tue, 23 Aug 2022 05:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240492AbiHWJCw (ORCPT ); Tue, 23 Aug 2022 05:02:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A796CF49; Tue, 23 Aug 2022 01:28:50 -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 C1359B81C35; Tue, 23 Aug 2022 08:27:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 368B3C433D6; Tue, 23 Aug 2022 08:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243261; bh=3agTiGGPSeveg7MES/sVEGH2c78Dw29TGthGj9XVZyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1I/IlwyiWsNRT69Lz+GcnSoR4ewM2DulbNkmv8PlPB1Kjk9Jq2gJFn/xvsk4Nj4t hjyTDWNVi8+ZUPjHLipjH+wyrV3OW0mW/uqIpt3NqrFQIIOD1diy/KctnQ9H/hEA/G rr5Q1NSSbv8Kwa4S0783itwE2737UOJB4g57k34Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rustam Subkhankulov , Jakub Kicinski Subject: [PATCH 5.19 220/365] net: dsa: sja1105: fix buffer overflow in sja1105_setup_devlink_regions() Date: Tue, 23 Aug 2022 10:02:01 +0200 Message-Id: <20220823080127.381447830@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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: Rustam Subkhankulov commit fd8e899cdb5ecaf8e8ee73854a99e10807eef1de upstream. If an error occurs in dsa_devlink_region_create(), then 'priv->regions' array will be accessed by negative index '-1'. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Rustam Subkhankulov Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region") Link: https://lore.kernel.org/r/20220817003845.389644-1-subkhankulov@ispras.ru Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/sja1105/sja1105_devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/dsa/sja1105/sja1105_devlink.c +++ b/drivers/net/dsa/sja1105/sja1105_devlink.c @@ -93,7 +93,7 @@ static int sja1105_setup_devlink_regions region = dsa_devlink_region_create(ds, ops, 1, size); if (IS_ERR(region)) { - while (i-- >= 0) + while (--i >= 0) dsa_devlink_region_destroy(priv->regions[i]); return PTR_ERR(region); }