stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Zekun Shen <bruceshenzk@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 38/43] atlantic: Fix buff_ring OOB in aq_ring_rx_clean
Date: Mon, 10 Jan 2022 08:23:35 +0100	[thread overview]
Message-ID: <20220110071818.634747403@linuxfoundation.org> (raw)
In-Reply-To: <20220110071817.337619922@linuxfoundation.org>

From: Zekun Shen <bruceshenzk@gmail.com>

[ Upstream commit 5f50153288452e10b6edd69ec9112c49442b054a ]

The function obtain the next buffer without boundary check.
We should return with I/O error code.

The bug is found by fuzzing and the crash report is attached.
It is an OOB bug although reported as use-after-free.

[    4.804724] BUG: KASAN: use-after-free in aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.805661] Read of size 4 at addr ffff888034fe93a8 by task ksoftirqd/0/9
[    4.806505]
[    4.806703] CPU: 0 PID: 9 Comm: ksoftirqd/0 Tainted: G        W         5.6.0 #34
[    4.809030] Call Trace:
[    4.809343]  dump_stack+0x76/0xa0
[    4.809755]  print_address_description.constprop.0+0x16/0x200
[    4.810455]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.811234]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.813183]  __kasan_report.cold+0x37/0x7c
[    4.813715]  ? aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.814393]  kasan_report+0xe/0x20
[    4.814837]  aq_ring_rx_clean+0x1e88/0x2730 [atlantic]
[    4.815499]  ? hw_atl_b0_hw_ring_rx_receive+0x9a5/0xb90 [atlantic]
[    4.816290]  aq_vec_poll+0x179/0x5d0 [atlantic]
[    4.816870]  ? _GLOBAL__sub_I_65535_1_aq_pci_func_init+0x20/0x20 [atlantic]
[    4.817746]  ? __next_timer_interrupt+0xba/0xf0
[    4.818322]  net_rx_action+0x363/0xbd0
[    4.818803]  ? call_timer_fn+0x240/0x240
[    4.819302]  ? __switch_to_asm+0x40/0x70
[    4.819809]  ? napi_busy_loop+0x520/0x520
[    4.820324]  __do_softirq+0x18c/0x634
[    4.820797]  ? takeover_tasklets+0x5f0/0x5f0
[    4.821343]  run_ksoftirqd+0x15/0x20
[    4.821804]  smpboot_thread_fn+0x2f1/0x6b0
[    4.822331]  ? smpboot_unregister_percpu_thread+0x160/0x160
[    4.823041]  ? __kthread_parkme+0x80/0x100
[    4.823571]  ? smpboot_unregister_percpu_thread+0x160/0x160
[    4.824301]  kthread+0x2b5/0x3b0
[    4.824723]  ? kthread_create_on_node+0xd0/0xd0
[    4.825304]  ret_from_fork+0x35/0x40

Signed-off-by: Zekun Shen <bruceshenzk@gmail.com>
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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
index 24122ccda614c..72f8751784c31 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
@@ -365,6 +365,10 @@ int aq_ring_rx_clean(struct aq_ring_s *self,
 		if (!buff->is_eop) {
 			buff_ = buff;
 			do {
+				if (buff_->next >= self->size) {
+					err = -EIO;
+					goto err_exit;
+				}
 				next_ = buff_->next,
 				buff_ = &self->buff_ring[next_];
 				is_rsc_completed =
@@ -388,6 +392,10 @@ int aq_ring_rx_clean(struct aq_ring_s *self,
 			    (buff->is_lro && buff->is_cso_err)) {
 				buff_ = buff;
 				do {
+					if (buff_->next >= self->size) {
+						err = -EIO;
+						goto err_exit;
+					}
 					next_ = buff_->next,
 					buff_ = &self->buff_ring[next_];
 
-- 
2.34.1




  parent reply	other threads:[~2022-01-10  7:37 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  7:22 [PATCH 5.10 00/43] 5.10.91-rc1 review Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 5.10 01/43] f2fs: quota: fix potential deadlock Greg Kroah-Hartman
2022-01-10  7:22 ` [PATCH 5.10 02/43] selftests: x86: fix [-Wstringop-overread] warn in test_process_vm_readv() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 03/43] tracing: Fix check for trace_percpu_buffer validity in get_trace_buf() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 04/43] tracing: Tag trace_percpu_buffer as a percpu pointer Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 05/43] ieee802154: atusb: fix uninit value in atusb_set_extended_addr Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 06/43] i40e: Fix to not show opcode msg on unsuccessful VF MAC change Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 07/43] iavf: Fix limit of total number of queues to active queues of VF Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 08/43] RDMA/core: Dont infoleak GRH fields Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 09/43] netrom: fix copying in user data in nr_setsockopt Greg Kroah-Hartman
2022-01-10 10:07   ` Pavel Machek
2022-01-10 10:14     ` Dan Carpenter
2022-01-10  7:23 ` [PATCH 5.10 10/43] RDMA/uverbs: Check for null return of kmalloc_array Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 11/43] mac80211: initialize variable have_higher_than_11mbit Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 12/43] sfc: The RX page_ring is optional Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 13/43] i40e: fix use-after-free in i40e_sync_filters_subtask() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 14/43] i40e: Fix for displaying message regarding NVM version Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 15/43] i40e: Fix incorrect netdevs real number of RX/TX queues Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 16/43] ftrace/samples: Add missing prototypes direct functions Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 17/43] ipv4: Check attribute length for RTA_GATEWAY in multipath route Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 18/43] ipv4: Check attribute length for RTA_FLOW " Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 19/43] ipv6: Check attribute length for RTA_GATEWAY " Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 20/43] ipv6: Check attribute length for RTA_GATEWAY when deleting " Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 21/43] lwtunnel: Validate RTA_ENCAP_TYPE attribute length Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 22/43] batman-adv: mcast: dont send link-local multicast to mcast routers Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 23/43] sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 24/43] net: ena: Fix undefined state when tx request id is out of bounds Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 25/43] net: ena: Fix error handling when calculating max IO queues number Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 26/43] xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocate Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 27/43] power: supply: core: Break capacity loop Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 28/43] power: reset: ltc2952: Fix use of floating point literals Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 29/43] rndis_host: support Hytera digital radios Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 30/43] phonet: refcount leak in pep_sock_accep Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 31/43] power: bq25890: Enable continuous conversion for ADC at charging Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 32/43] ipv6: Continue processing multipath route even if gateway attribute is invalid Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 33/43] ipv6: Do cleanup if attribute validation fails in multipath route Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 34/43] usb: mtu3: fix interval value for intr and isoc Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 35/43] scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown() Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 36/43] ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 37/43] net: udp: fix alignment problem in udp4_seq_show() Greg Kroah-Hartman
2022-01-10  7:23 ` Greg Kroah-Hartman [this message]
2022-01-10  7:23 ` [PATCH 5.10 39/43] mISDN: change function names to avoid conflicts Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 40/43] drm/amd/display: Added power down for DCN10 Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 41/43] ipv6: raw: check passed optlen before reading Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 42/43] ARM: dts: gpio-ranges property is now required Greg Kroah-Hartman
2022-01-10  7:23 ` [PATCH 5.10 43/43] Input: zinitix - make sure the IRQ is allocated before it gets enabled Greg Kroah-Hartman
2022-01-10 11:49 ` [PATCH 5.10 00/43] 5.10.91-rc1 review Jon Hunter
2022-01-10 19:10 ` Fox Chen
2022-01-10 19:50 ` Florian Fainelli
2022-01-10 22:56 ` Shuah Khan
2022-01-10 23:50 ` Guenter Roeck
2022-01-11  3:34 ` Samuel Zou
2022-01-11  5:26 ` Naresh Kamboju
2022-01-11 12:37 ` Sudip Mukherjee

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=20220110071818.634747403@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bruceshenzk@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).