[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wgtH+Nq+LSCdjS4v2=XOnL3wtO2FA5wvWu5n5imCsFFCA@mail.gmail.com>
Date: Tue, 29 Mar 2022 23:28:26 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: Fedor Pchelkin <aissur0002@...il.com>,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
Eric Biggers <ebiggers@...nel.org>,
Christian Brauner <brauner@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
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@...c4.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
Powered by blists - more mailing lists