From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Fedor Pchelkin <aissur0002@gmail.com>,
Alexey Khoroshilov <khoroshilov@ispras.ru>,
Eric Biggers <ebiggers@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] file: Fix file descriptor leak in copy_fd_bitmaps()
Date: Wed, 30 Mar 2022 02:21:14 -0400 [thread overview]
Message-ID: <YkP2hKKeMeFrdpBW@zx2c4.com> (raw)
In-Reply-To: <CAHk-=wgPwyQTnSF2s7WSb+KnGn4FTM58NJ+-v-561W7xnDk2OA@mail.gmail.com>
Hi Linus,
On Tue, Mar 29, 2022 at 11:08:55PM -0700, Linus Torvalds wrote:
> So does it help if you just remove that
>
> max_fds = ALIGN(max_fds, BITS_PER_LONG);
>
> and instead make the final return be
>
> return ALIGN(min(count, max_fds), BITS_PER_LONG);
>
> instead?
Yep, that works:
diff --git a/fs/file.c b/fs/file.c
index c01c29417ae6..ee9317346702 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -303,10 +303,9 @@ static unsigned int sane_fdtable_size(struct fdtable *fdt, unsigned int max_fds)
unsigned int count;
count = count_open_files(fdt);
- max_fds = ALIGN(max_fds, BITS_PER_LONG);
if (max_fds < NR_OPEN_DEFAULT)
max_fds = NR_OPEN_DEFAULT;
- return min(count, max_fds);
+ return ALIGN(min(count, max_fds), BITS_PER_LONG);
}
/*
Jason
next prev parent reply other threads:[~2022-03-30 6:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-26 11:40 [PATCH 4/4] file: Fix file descriptor leak in copy_fd_bitmaps() Fedor Pchelkin
2022-03-26 14:17 ` Alexey Khoroshilov
2022-03-26 22:15 ` Linus Torvalds
2022-03-26 22:37 ` Linus Torvalds
2022-03-27 21:54 ` aissur0002
2022-03-27 22:21 ` Linus Torvalds
2022-03-29 10:23 ` Christian Brauner
2022-03-29 14:40 ` Christian Brauner
2022-03-29 21:28 ` Linus Torvalds
2022-03-29 20:44 ` aissur0002
2022-03-29 21:02 ` Linus Torvalds
2022-03-29 22:18 ` Linus Torvalds
2022-03-29 22:23 ` Linus Torvalds
2022-03-30 7:47 ` Christian Brauner
2022-03-30 5:21 ` Jason A. Donenfeld
2022-03-30 6:08 ` Linus Torvalds
2022-03-30 6:21 ` Jason A. Donenfeld [this message]
2022-03-30 6:28 ` Linus Torvalds
2022-03-30 6:43 ` Linus Torvalds
2022-03-29 23:02 ` Alexey Khoroshilov
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=YkP2hKKeMeFrdpBW@zx2c4.com \
--to=jason@zx2c4.com \
--cc=aissur0002@gmail.com \
--cc=brauner@kernel.org \
--cc=ebiggers@kernel.org \
--cc=khoroshilov@ispras.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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