Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp432448iob; Wed, 18 May 2022 05:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw2ON3Rp2rrhx5Q764JHX2EGfjq4VnzRS0oU7u20JvVHkuO5FjXVxLT6ksqj0EaBlt9rHr X-Received: by 2002:a17:903:1104:b0:15f:bce:1a0c with SMTP id n4-20020a170903110400b0015f0bce1a0cmr26911270plh.149.1652877016490; Wed, 18 May 2022 05:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652877016; cv=none; d=google.com; s=arc-20160816; b=tNVuBH4u7pS+jnfG9pCbtH5cgeaQuR9JERhNPqhBL6QW/kUzIKgGtnczbHYIN2FSvf GEJcBCQg7AIgFF8+QCRiEBd4L79Zr7BTH9+cOo8tEHf7KboFlTToUEgYH1HgP2tFng3U 8oxyJQrcS2PAZRyiI/K/wBICxCcq7wsDFBD1l0clQ3GP0od/VAGGcgmdsjM8xzoop+ff A+XO49xuB45fVuUgAm1oirGGYvZ9mY9mhmFZF/bl0yKqOULlppkMMicvPEbrfRxdDCpu 5oQvUOL9sPHVQVgMhj6SY+DctSAG+8j69Bd19/9GcX67M1052o8NvQSPQjA2/VplQsIt FTKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4m3J/T9Ss83EsHT5umi2Sbm7bO81o3KtASMsVsMoAVg=; b=E8bj1L4vPFEOlZDN6EUbRez76HXgTfkLdwTvxPxzC2LrfFoctVSlw54vDCY89cLf1u tMgkTXRxB0bXhrowKlUjjHmXfkZ995ddvxOvMrLreP2jDzKL+/Xvip6JpgbvWSXhrlRy nqk6q9TGZhmcvORUd29d3agktcihup+pTFypvqO2RlW2C0Z4wHi1Fv8gvNGhGgSjBi36 jVpuaHQz943eTPsYvYk7bqbuiM2YgVburAFCnAcXnizu+xmTLQcndeOgAGJCjWbez9gf VdpPm5g7+Y1k8mGA3Bevh8B9/FjpAnJjiVdbGiGIfZuSFBrIoHR4h/KAIf2cngtXn3Y6 8cVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eT+fQCFu; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j13-20020a170903024d00b0015e8f00a7e0si2782307plh.384.2022.05.18.05.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 05:30:16 -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=@kernel.org header.s=k20201202 header.b=eT+fQCFu; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3714195900; Wed, 18 May 2022 05:29:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236797AbiERM2p (ORCPT + 99 others); Wed, 18 May 2022 08:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236625AbiERM1l (ORCPT ); Wed, 18 May 2022 08:27:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11345135680; Wed, 18 May 2022 05:27:38 -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 4E6166147D; Wed, 18 May 2022 12:27:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A5F5C385AA; Wed, 18 May 2022 12:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652876857; bh=Eh20xBib3bRTCPbaAVbjeIBlp5HWjm1Ir/G+4BMbClg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eT+fQCFurDvPXqOLsiX8jo8WV2IcoA995grZsUEtN1MJd9GmZKXRK0TBPql2lpRYt /xgT7kxC6/wZR+UVtSQ00/k5uzWoR6d9tmoZ7R/mnIF4I3fTdbTdLwQzvMAc+NotFY 2m9shc8J/MgtHxsLSGxV/i2k8Zb3Nh3tcd/DrK0Vd5AgX+z5/9RRw4h3hSvePl1kj7 wufD15Kp1aDl8PNCbSFEOWWarJmiWpvRjP58oGJKoAun6RaXOCwPAbkfnbKTIXkBYO d1H7ni8Q6cb3KRHCVlfGA0wJ0QRiKkwHMqW1Vw4xfpsJ7fEo1vgUpcsohqGVXw/HM2 kpVdOJdvK6/dg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Grant Grundler , Aashay Shringarpure , Yi Chou , Shervin Oloumi , "David S . Miller" , Sasha Levin , irusskikh@marvell.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.17 20/23] net: atlantic: add check for MAX_SKB_FRAGS Date: Wed, 18 May 2022 08:26:33 -0400 Message-Id: <20220518122641.342120-20-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518122641.342120-1-sashal@kernel.org> References: <20220518122641.342120-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: Grant Grundler [ Upstream commit 6aecbba12b5c90b26dc062af3b9de8c4b3a2f19f ] Enforce that the CPU can not get stuck in an infinite loop. Reported-by: Aashay Shringarpure Reported-by: Yi Chou Reported-by: Shervin Oloumi Signed-off-by: Grant Grundler Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index bc1952131799..8201ce7adb77 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -363,6 +363,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self, continue; if (!buff->is_eop) { + unsigned int frag_cnt = 0U; buff_ = buff; do { bool is_rsc_completed = true; @@ -371,6 +372,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, err = -EIO; goto err_exit; } + + frag_cnt++; next_ = buff_->next, buff_ = &self->buff_ring[next_]; is_rsc_completed = @@ -378,7 +381,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, next_, self->hw_head); - if (unlikely(!is_rsc_completed)) { + if (unlikely(!is_rsc_completed) || + frag_cnt > MAX_SKB_FRAGS) { err = 0; goto err_exit; } -- 2.35.1