From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Grant Grundler <grundler@chromium.org>,
Aashay Shringarpure <aashay@google.com>,
Yi Chou <yich@google.com>,
Shervin Oloumi <enlightened@google.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
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 [thread overview]
Message-ID: <20220518122641.342120-20-sashal@kernel.org> (raw)
In-Reply-To: <20220518122641.342120-1-sashal@kernel.org>
From: Grant Grundler <grundler@chromium.org>
[ Upstream commit 6aecbba12b5c90b26dc062af3b9de8c4b3a2f19f ]
Enforce that the CPU can not get stuck in an infinite loop.
Reported-by: Aashay Shringarpure <aashay@google.com>
Reported-by: Yi Chou <yich@google.com>
Reported-by: Shervin Oloumi <enlightened@google.com>
Signed-off-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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
next prev parent reply other threads:[~2022-05-18 12:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220518122641.342120-1-sashal@kernel.org>
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 03/23] mac80211: fix rx reordering with non explicit / psmp ack policy Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 04/23] nl80211: validate S1G channel width Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 05/23] cfg80211: retrieve S1G operating channel number Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 06/23] selftests: add ping test with ping_group_range tuned Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 14/23] net: fix wrong network header length Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 15/23] nl80211: fix locking in nl80211_set_tx_bitrate_mask() Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 16/23] ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one() Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 17/23] net: stmmac: fix missing pci_disable_device() on error in stmmac_pci_probe() Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 18/23] net: atlantic: fix "frag[0] not initialized" Sasha Levin
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 19/23] net: atlantic: reduce scope of is_rsc_complete Sasha Levin
2022-05-18 12:26 ` Sasha Levin [this message]
2022-05-18 12:26 ` [PATCH AUTOSEL 5.17 21/23] net: atlantic: verify hw_head_ lies within TX buffer ring Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220518122641.342120-20-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aashay@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=enlightened@google.com \
--cc=grundler@chromium.org \
--cc=irusskikh@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=yich@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).