Archive-only list for patches
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	syzbot+3e77fd302e99f5af9394@syzkaller.appspotmail.com,
	Sasha Levin <sashal@kernel.org>,
	asml.silence@gmail.com, io-uring@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.6 10/12] io_uring/fdinfo: annotate racy sq/cq head/tail reads
Date: Tue,  6 May 2025 17:36:45 -0400	[thread overview]
Message-ID: <20250506213647.2983356-10-sashal@kernel.org> (raw)
In-Reply-To: <20250506213647.2983356-1-sashal@kernel.org>

From: Jens Axboe <axboe@kernel.dk>

[ Upstream commit f024d3a8ded0d8d2129ae123d7a5305c29ca44ce ]

syzbot complains about the cached sq head read, and it's totally right.
But we don't need to care, it's just reading fdinfo, and reading the
CQ or SQ tail/head entries are known racy in that they are just a view
into that very instant and may of course be outdated by the time they
are reported.

Annotate both the SQ head and CQ tail read with data_race() to avoid
this syzbot complaint.

Link: https://lore.kernel.org/io-uring/6811f6dc.050a0220.39e3a1.0d0e.GAE@google.com/
Reported-by: syzbot+3e77fd302e99f5af9394@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 io_uring/fdinfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c
index 976e9500f6518..a26cf840e623d 100644
--- a/io_uring/fdinfo.c
+++ b/io_uring/fdinfo.c
@@ -81,11 +81,11 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f)
 	seq_printf(m, "SqMask:\t0x%x\n", sq_mask);
 	seq_printf(m, "SqHead:\t%u\n", sq_head);
 	seq_printf(m, "SqTail:\t%u\n", sq_tail);
-	seq_printf(m, "CachedSqHead:\t%u\n", ctx->cached_sq_head);
+	seq_printf(m, "CachedSqHead:\t%u\n", data_race(ctx->cached_sq_head));
 	seq_printf(m, "CqMask:\t0x%x\n", cq_mask);
 	seq_printf(m, "CqHead:\t%u\n", cq_head);
 	seq_printf(m, "CqTail:\t%u\n", cq_tail);
-	seq_printf(m, "CachedCqTail:\t%u\n", ctx->cached_cq_tail);
+	seq_printf(m, "CachedCqTail:\t%u\n", data_race(ctx->cached_cq_tail));
 	seq_printf(m, "SQEs:\t%u\n", sq_tail - sq_head);
 	sq_entries = min(sq_tail - sq_head, ctx->sq_entries);
 	for (i = 0; i < sq_entries; i++) {
-- 
2.39.5


  parent reply	other threads:[~2025-05-06 21:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 21:36 [PATCH AUTOSEL 6.6 01/12] ASoC: imx-card: Adjust over allocation of memory in imx_card_parse_of() Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 02/12] book3s64/radix: Fix compile errors when CONFIG_ARCH_WANT_OPTIMIZE_DAX_VMEMMAP=n Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 03/12] pinctrl: meson: define the pull up/down resistor value as 60 kOhm Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 04/12] ASoC: cs42l43: Disable headphone clamps during type detection Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 05/12] ASoC: Intel: bytcr_rt5640: Add DMI quirk for Acer Aspire SW3-013 Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 06/12] ALSA: hda/realtek: Add quirk for HP Spectre x360 15-df1xxx Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 07/12] nvme-pci: add quirks for device 126f:1001 Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 08/12] nvme-pci: add quirks for WDC Blue SN550 15b7:5009 Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 09/12] nvmet-tcp: don't restore null sk_state_change Sasha Levin
2025-05-06 21:36 ` Sasha Levin [this message]
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 11/12] cifs: Fix and improve cifs_query_path_info() and cifs_query_file_info() Sasha Levin
2025-05-06 21:36 ` [PATCH AUTOSEL 6.6 12/12] cifs: Fix changing times and read-only attr over SMB1 smb_set_file_info() function 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=20250506213647.2983356-10-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+3e77fd302e99f5af9394@syzkaller.appspotmail.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