Messages in this thread Patch in this message | | | Date | Wed, 30 Mar 2022 02:21:14 -0400 | From | "Jason A. Donenfeld" <> | Subject | Re: [PATCH 4/4] file: Fix file descriptor leak in copy_fd_bitmaps() |
| |
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
| |