From: Jens Axboe <axboe@kernel.dk>
To: Eric Dumazet <eric.dumazet@gmail.com>, Hao Xu <haoxu@linux.alibaba.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Eric Dumazet <edumazet@google.com>
Subject: Re: [BUG] About "io_uring: add more uring info to fdinfo for debug"
Date: Thu, 28 Oct 2021 15:40:09 -0600 [thread overview]
Message-ID: <e72cdd44-c027-e51c-8b57-24f39bf21d87@kernel.dk> (raw)
In-Reply-To: <9ac22d4d-c841-651a-fdd5-9fb3a65c57ab@gmail.com>
On 10/28/21 3:24 PM, Eric Dumazet wrote:
> Hi
>
> I was looking at commit 83f84356bc8f2d
> ("io_uring: add more uring info to fdinfo for debug") after receiving
> syzbot reports.
>
> I suspect that the following :
>
> + for (i = cached_sq_head; i < sq_tail; i++) {
> + unsigned int sq_idx = READ_ONCE(ctx->sq_array[i & sq_mask]);
> +
> + if (likely(sq_idx <= sq_mask)) {
> + struct io_uring_sqe *sqe = &ctx->sq_sqes[sq_idx];
> +
> + seq_printf(m, "%5u: opcode:%d, fd:%d, flags:%x, user_data:%llu\n",
> + sq_idx, sqe->opcode, sqe->fd, sqe->flags, sqe->user_data);
> + }
> + }
>
>
> Can loop around ~2^32 times if sq_tail is close to ~0U
>
> I see various READ_ONCE(), which are probably not good enough.
>
> At very minimum I would handling wrapping...
Thanks for reporting this. I think on top of wrapping, the loop should
just be capped at sq_entries as well. There's no point dumping more than
that, ever.
I'll take a stab at this.
--
Jens Axboe
next prev parent reply other threads:[~2021-10-28 21:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 21:24 [BUG] About "io_uring: add more uring info to fdinfo for debug" Eric Dumazet
2021-10-28 21:40 ` Jens Axboe [this message]
2021-10-29 0:13 ` Jens Axboe
2021-10-29 0:43 ` Eric Dumazet
2021-10-29 12:40 ` Jens Axboe
2021-10-29 17:54 ` Hao Xu
2021-10-29 17:56 ` Jens Axboe
2021-10-29 17:58 ` Hao Xu
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=e72cdd44-c027-e51c-8b57-24f39bf21d87@kernel.dk \
--to=axboe@kernel.dk \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=haoxu@linux.alibaba.com \
--cc=linux-kernel@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