Skip to content

Commit 7599316

Browse files
axboeSasha Levin
authored andcommitted
io_uring/fdinfo: annotate racy sq/cq head/tail reads
[ Upstream commit f024d3a ] 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>
1 parent bfb51bb commit 7599316

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

io_uring/fdinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m)
117117
seq_printf(m, "SqMask:\t0x%x\n", sq_mask);
118118
seq_printf(m, "SqHead:\t%u\n", sq_head);
119119
seq_printf(m, "SqTail:\t%u\n", sq_tail);
120-
seq_printf(m, "CachedSqHead:\t%u\n", ctx->cached_sq_head);
120+
seq_printf(m, "CachedSqHead:\t%u\n", data_race(ctx->cached_sq_head));
121121
seq_printf(m, "CqMask:\t0x%x\n", cq_mask);
122122
seq_printf(m, "CqHead:\t%u\n", cq_head);
123123
seq_printf(m, "CqTail:\t%u\n", cq_tail);
124-
seq_printf(m, "CachedCqTail:\t%u\n", ctx->cached_cq_tail);
124+
seq_printf(m, "CachedCqTail:\t%u\n", data_race(ctx->cached_cq_tail));
125125
seq_printf(m, "SQEs:\t%u\n", sq_tail - sq_head);
126126
sq_entries = min(sq_tail - sq_head, ctx->sq_entries);
127127
for (i = 0; i < sq_entries; i++) {

0 commit comments

Comments
 (0)