Skip to content

[GIT PULL] register: avoid overshooting the file descriptor limit - #1638

Open
vpfkfl753 wants to merge 1 commit into
axboe:masterfrom
vpfkfl753:fix-register-nofile-limit
Open

[GIT PULL] register: avoid overshooting the file descriptor limit#1638
vpfkfl753 wants to merge 1 commit into
axboe:masterfrom
vpfkfl753:fix-register-nofile-limit

Conversation

@vpfkfl753

Copy link
Copy Markdown

File registration adds the requested table size to the current soft limit. With soft=64, hard=96 and a request for 80 files, the resulting limit of 144 is rejected and registration returns -EMFILE, even though 80 is allowed.

Set the soft limit to the requested size. The regression covers regular, tagged and sparse tables in separate child processes and checks that the hard limit is unchanged.

The new test fails in all three modes before the fix. Afterward, it and file-register, file-update, file-verify, file-exit-unreg, and io_uring_register pass on Linux 7.0.0-28-generic with GCC 13.3.


git request-pull output:

The following changes since commit 4cf73437863c2e492d2a1d0f24330f391c0f075b:

  test/iowait.t: Skip if system is not quiesced for too long (2026-08-31 17:00:18 -0600)

are available in the Git repository at:

  https://github.com/vpfkfl753/liburing.git fix-register-nofile-limit

for you to fetch changes up to 5730376586eb6bade05116a59f5e255c132bda04:

  register: avoid overshooting the file descriptor limit (2026-09-08 21:21:03 +0900)

----------------------------------------------------------------
Sungwon Woo (1):
      register: avoid overshooting the file descriptor limit

 src/register.c              |  2 +-
 test/Makefile               |  1 +
 test/file-register-nofile.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 test/file-register-nofile.c

Click to show/hide pull request guidelines

Pull Request Guidelines

  1. To make everyone easily filter pull request from the email
    notification, use [GIT PULL] as a prefix in your PR title.
[GIT PULL] Your Pull Request Title
  1. Follow the commit message format rules below.
  2. Follow the Linux kernel coding style (see: https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst).

Commit message format rules:

  1. The first line is title (don't be more than 72 chars if possible).
  2. Then an empty line.
  3. Then a description (may be omitted for truly trivial changes).
  4. Then an empty line again (if it has a description).
  5. Then a Signed-off-by tag with your real name and email. For example:
Signed-off-by: Foo Bar <foo.bar@gmail.com>

The description should be word-wrapped at 72 chars. Some things should
not be word-wrapped. They may be some kind of quoted text - long
compiler error messages, oops reports, Link, etc. (things that have a
certain specific format).

Note that all of this goes in the commit message, not in the pull
request text. The pull request text should introduce what this pull
request does, and each commit message should explain the rationale for
why that particular change was made. The git tree is canonical source
of truth, not github.

Each patch should do one thing, and one thing only. If you find yourself
writing an explanation for why a patch is fixing multiple issues, that's
a good indication that the change should be split into separate patches.

If the commit is a fix for an issue, add a Fixes tag with the issue
URL.

Don't use GitHub anonymous email like this as the commit author:

123456789+username@users.noreply.github.com

Use a real email address!

Commit message example:

src/queue: don't flush SQ ring for new wait interface

If we have IORING_FEAT_EXT_ARG, then timeouts are done through the
syscall instead of by posting an internal timeout. This was done
to be both more efficient, but also to enable multi-threaded use
the wait side. If we touch the SQ state by flushing it, that isn't
safe without synchronization.

Fixes: https://github.com/axboe/liburing/issues/402
Signed-off-by: Jens Axboe <axboe@kernel.dk>

By submitting this pull request, I acknowledge that:

  1. I have followed the above pull request guidelines.
  2. I have the rights to submit this work under the same license.
  3. I agree to a Developer Certificate of Origin (see https://developercertificate.org for more information).

File registration retries -EMFILE after raising RLIMIT_NOFILE. The
helper adds nr to rlim_cur even though nr is the table size, not an
increment. With a soft limit of 64, a hard limit of 96 and nr=80, it
requests a soft limit of 144. setrlimit fails and all three registration
helpers still return -EMFILE.

Set the soft limit to nr. Add a regression for regular, tagged and
sparse tables, with each case in a child process so the reduced hard
limit does not affect the parent.

Tested on Linux 7.0.0-28-generic: file-register-nofile, file-register,
file-update, file-verify, file-exit-unreg and io_uring_register pass.
All three new cases fail with -EMFILE before the fix.

Signed-off-by: Sungwon Woo <vpfkfl753@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant