public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dmitry Vyukov <[email protected]>
To: Hristo Venev <[email protected]>
Cc: Jens Axboe <[email protected]>,
	Necip Fazil Yildiran <[email protected]>,
	[email protected]
Subject: Re: [PATCH] io_uring: fix sq array offset calculation
Date: Fri, 17 Jul 2020 15:48:32 +0200	[thread overview]
Message-ID: <CACT4Y+bgTCMXi3eU7xV+W0ZZNceZFUWRTkngojdr0G_yuY8w9w@mail.gmail.com> (raw)
In-Reply-To: <CACT4Y+Y36NYmsn1nA16YFzLDU_Gt1xWZF+ZXvbJr9y-0qqP+DQ@mail.gmail.com>

On Sat, Jul 11, 2020 at 6:16 PM Dmitry Vyukov <[email protected]> wrote:
>
> On Sat, Jul 11, 2020 at 5:52 PM Hristo Venev <[email protected]> wrote:
> >
> > On Sat, 2020-07-11 at 17:31 +0200, Dmitry Vyukov wrote:
> > > Looking at the code more, I am not sure how it may not corrupt
> > > memory.
> > > There definitely should be some combinations where accessing
> > > sq_entries*sizeof(u32) more memory won't be OK.
> > > May be worth adding a test that allocates all possible sizes for
> > > sq/cq
> > > and fills both rings.
> >
> > The layout (after the fix) is roughly as follows:
> >
> > 1. struct io_rings - ~192 bytes, maybe 256
> > 2. cqes - (32 << n) bytes
> > 3. sq_array - (4 << n) bytes
> >
> > The bug was that the sq_array was offset by (4 << n) bytes. I think
> > issues can only occur when
> >
> >     PAGE_ALIGN(192 + (32 << n) + (4 << n) + (4 << n))
> >     !=
> >     PAGE_ALIGN(192 + (32 << n) + (4 << n))
> >
> > It looks like this never happens. We got lucky.
>
> Interesting. CQ entries are larger and we have at least that many of
> them as SQ entries. I guess this + power-of-2-pages can make it never
> overflow.

Hi Jens,

I see this patch is in block/for-5.9/io_uring
Is this tree merged into linux-next? I don't see it in linux-next yet.
Or is it possible to get it into 5.8?

The reason I am asking is that we have an intern (Necip in CC) working
on significantly extending io_uring coverage in syzkaller:
https://github.com/google/syzkaller/pull/1926
Unfortunately we had to hardcode offset computation logic b/c the
intended way of using io_uring for normal programs represents an
additional obstacle for the fuzzer and the relations between syscalls
and writes to shared memory are even hard to express for the fuzzer.
We want to hardcode this new updated way of computing offsets, but
this means we probably won't get good coverage until the intern term
ends (+ may be good to discover some io_uring bugs before the
release).

If it won't get into linux-next/mainline until 5.9, it's not a big
deal, but I wanted to ask.

  reply	other threads:[~2020-07-17 13:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-11  9:31 [PATCH] io_uring: fix sq array offset calculation Dmitry Vyukov
2020-07-11  9:37 ` Hristo Venev
2020-07-11 15:15 ` Jens Axboe
2020-07-11 15:31   ` Dmitry Vyukov
2020-07-11 15:36     ` Jens Axboe
2020-07-11 15:47       ` Jens Axboe
2020-07-11 15:52     ` Hristo Venev
2020-07-11 15:55       ` Jens Axboe
2020-07-11 15:56       ` Hristo Venev
2020-07-11 16:16       ` Dmitry Vyukov
2020-07-17 13:48         ` Dmitry Vyukov [this message]
2020-07-17 14:05           ` Jens Axboe
2020-07-17 14:08             ` Jens Axboe
2020-07-17 14:08             ` Dmitry Vyukov

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=CACT4Y+bgTCMXi3eU7xV+W0ZZNceZFUWRTkngojdr0G_yuY8w9w@mail.gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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