Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3418458rwa; Tue, 23 Aug 2022 04:34:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR6aWQU57jxvbuY4xmSpaJFgIgJsy+XDZVYryXlVTTxPku4WtFiAdWc17jmSYUqQYmuZ+2mm X-Received: by 2002:a05:6402:254a:b0:446:d52a:6c8 with SMTP id l10-20020a056402254a00b00446d52a06c8mr3319837edb.107.1661254143898; Tue, 23 Aug 2022 04:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254143; cv=none; d=google.com; s=arc-20160816; b=zPWW+H58GXUSbBOtvUeH5f+3HMUWH+cc/rY1pQ5hVj1BOsMABEIZP2IYD1LTmfq2nn rf8x4Y33Fs4/lzI2nYYFD1nKAmhFS0N5J/J5bxWYW5de0SH2cTgKKXBfMc3qxMXnMGUQ LQo1F7po6Ie8jNICxIKhQbZHZrp+78SDfZtreh6F8o429JbmRNTaRkA2nC7bqn25J3wU yPVI2qzhFA/SS1vCiLrbSsBzFe/6aqoV3Wnp0ZdkfsM68n5kFw849aamAWAhuUzR/1w5 vjKtpYmRuTRk8elk2m34XKaTyWlT9D+gxibZQN3cKNVVE3WabNIp8An1OHP7FLd1DwSw bDkg== 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=MeB05cUm7TW3YBFhGJAlkpzh7Ik0Q9id6ymvCGvCk5VxECl7Eupghf8K5LrOgZF+m+ pCRSnrUiUSCWwuGrN1L8rGLOSM+H/2NoHjT2UfmyvkHwtTY39mZFc/5QK/7e1/t1caot jgTb78vMk9xfaphC8vskF4rhm3Us5xoqqHtfjAqvDs11XOL2TztyVZYK+ZPQiWqRSMJe vW7n2yeq+rfh/pygspIz+xbsDKx5RjnUVXxx0SamD0n7n0cY0g2qR3f4IpYFRGLokP3G vVNZ2RshyuplWtlikR/4IYSVrCkPPqeiH3lvra58YRauT57WT2ZQYvlyP6KhmGf0XayA EOBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="WC/9+XQ6"; 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 z23-20020a50cd17000000b0043d373fd120si2051805edi.47.2022.08.23.04.28.38; Tue, 23 Aug 2022 04:29:03 -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="WC/9+XQ6"; 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 S1353204AbiHWKNJ (ORCPT + 99 others); Tue, 23 Aug 2022 06:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352708AbiHWKGI (ORCPT ); Tue, 23 Aug 2022 06:06:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4B8323; Tue, 23 Aug 2022 01:52:33 -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 E08A3B81C3B; Tue, 23 Aug 2022 08:52:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F2D2C433D6; Tue, 23 Aug 2022 08:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244750; bh=3agTiGGPSeveg7MES/sVEGH2c78Dw29TGthGj9XVZyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WC/9+XQ6a8nwH14d1oTE99k25s80OCLpg+OZXYMmaa3kX2CfJUrf7za1QaC/vMo0v IsiE/Zgxabh4//o9vz/6K86F5X2m16w5y/z4VDJoal1gGSohHmT+InB62VgC6UFN/N GStmgp1ajd/ksolOpEyX7NFhOC7bGEBx5O8nL4NM= 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.15 143/244] net: dsa: sja1105: fix buffer overflow in sja1105_setup_devlink_regions() Date: Tue, 23 Aug 2022 10:25:02 +0200 Message-Id: <20220823080103.948882163@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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); }