From: Cheng Yongkang <teel4res@gmail.com>
To: Benjamin LaHaise <ben@communityfibre.ca>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] fs/aio: io_setup integer wrap can exhaust global aio quota
Date: Thu, 22 Oct 2026 09:01:03 -0700 (PDT) [thread overview]
Message-ID: <179268485745.64118.8307604514392982010@gmail.com> (raw)
In-Reply-To: <20261022154852.GQ8374@kvack.org>
Hi Ben,
Here is the exact path, step by step, with the values at each line of
v7.3 fs/aio.c (commit 08ab31164c55). Precondition: root has set
fs.aio-max-nr to 2147483649 (0x80000001); fs.aio-nr is 0.
The caller does io_setup(0x80000001, &ctx).
1. Line 796: max_reqs = nr_events;
max_reqs = 0x80000001
2. Line 807: nr_events = max(nr_events, num_possible_cpus() * 4);
nr_events = 0x80000001
3. Line 808: nr_events *= 2;
0x80000001 * 2 = 0x100000002, which does not fit in
32 bits, so nr_events = 2
4. Line 811: if (nr_events > 0x10000000U / sizeof(struct io_event))
2 > 8388608 is false, so no return
5. Line 816: if (!nr_events || max_reqs > aio_max_nr)
nr_events is 2, and 0x80000001 > 0x80000001 is false,
so no return
6. Line 845: aio_setup_ring(ctx, nr_events) with nr_events = 2
succeeds and builds a one-page ring (127 slots)
7. Line 856: if (aio_nr + ctx->max_reqs > aio_max_nr || ...)
0 + 0x80000001 > 0x80000001 is false, so no error
8. Line 862: aio_nr += ctx->max_reqs;
aio_nr = 0x80000001 <-- aio_nr is updated here
9. Line 868: err = ioctx_add_table(ctx, mm);
returns 0 <-- ioctx_add_table() is called
10. Line 877: return ctx;
io_setup() returns 0 and the context is live.
You can check it in under a minute:
# sysctl -w fs.aio-max-nr=2147483649
# cat /proc/sys/fs/aio-nr
0
... run io_setup(0x80000001, &ctx) ...
# cat /proc/sys/fs/aio-nr
2147483649
If aio_nr were never updated, the second read would be 0. It is
2147483649. The context returned in step 10 also works with
io_submit() and io_getevents(), which is only possible if
ioctx_add_table() installed it.
The early return you describe is real, but it is step 5 with the
default fs.aio-max-nr of 65536. That is not the configuration in
the report.
I am not asking you to take a patch. I only want the record to be
accurate: on this path, aio_nr is updated and ioctx_add_table() is
called.
Thanks,
Cheng
prev parent reply other threads:[~2026-10-22 16:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 9:17 Cheng Yongkang
2026-10-22 15:23 ` Benjamin LaHaise
2026-10-22 15:44 ` Cheng Yongkang
2026-10-22 15:48 ` Benjamin LaHaise
2026-10-22 16:01 ` Cheng Yongkang [this message]
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=179268485745.64118.8307604514392982010@gmail.com \
--to=teel4res@gmail.com \
--cc=ben@communityfibre.ca \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®