From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2309AC433F5 for ; Wed, 18 May 2022 12:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236900AbiERMdl (ORCPT ); Wed, 18 May 2022 08:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236902AbiERMct (ORCPT ); Wed, 18 May 2022 08:32:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C444A19CB61; Wed, 18 May 2022 05:29:15 -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 34BAC6169A; Wed, 18 May 2022 12:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22769C34118; Wed, 18 May 2022 12:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652876953; bh=rAZen7RQzLM1AtPnxO+QsytUnBXywbtMIxIy+YJqXqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqvcPEp8LDZu1tenJqAJPUWSQLcuFB25uDtayedQJh/llGlkwNihIodh32+CaQlyP YVdwE5h4bCYMSRIQGDvidtUXe2d6Vtie159meyR8KEBePiLkwCHE3uJQg280sJJhcB dYxvcKf9Tq4ceIYQjup/rhio1zLKhU2HI3IKWl9EMGCa4Ufo6OS5KZEt/5EHR0QO4U hoq9W3Ya/9MwGlPrTIpgbDr72hHscKrOARhJlBREfKa8LZgdGgle5BNw9XLxQr55AK nx23ssVpPTv8j+xbeawZ/Dd3+ArgUPGQFmNLsW3/NQU41j8+fMWRx2mWlfV0r/lvPr x1Xae16mjqzCQ== 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.10 10/13] net: atlantic: add check for MAX_SKB_FRAGS Date: Wed, 18 May 2022 08:28:41 -0400 Message-Id: <20220518122844.343220-10-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220518122844.343220-1-sashal@kernel.org> References: <20220518122844.343220-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@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 339efdfb1d49..e9c6f1fa0b1a 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -362,6 +362,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; @@ -370,6 +371,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 = @@ -377,7 +380,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