Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 29 Mar 2022 23:28:26 -0700 | Subject | Re: [PATCH 4/4] file: Fix file descriptor leak in copy_fd_bitmaps() |
| |
On Tue, Mar 29, 2022 at 11:21 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote: > > Yep, that works:
Ok, I'll apply that asap.
I think the "do this better" version is to get rid of count_open_files() and moving all the logic into sane_fdtable_size(), and you end up with something like this:
static unsigned int sane_fdtable_size(struct fdtable *fdt, unsigned int max_fds) { unsigned int i;
max_fds = min(max_fds, fdt->max_fds); i = (max_fds + BITS_PER_LONG - 1) / BITS_PER_LONG; while (i > 0) { if (fdt->open_fds[--i]) break; } return (i + 1) * BITS_PER_LONG; }
but considering that I couldn't even get the simple ALIGN() in the right place, I think going with the obvious version I should have picked originally is the way to go..
Linus
| |