I am sorry, that was my first attempt to contribute to the kernel and I messed up a little bit with the patch tag: it is actually a single, standalone patch and there has been nothing posted previously. Moreover, I should have provided you with the context of discovering the bug: a Syzkaller bug reproducer and CrashReport are attached to the mail. In few words, an error occurs while executing close_range() call with CLOSE_RANGE_UNSHARE flag: in __close_range() the value of max_unshare_fds (later used as max_fds in dup_fd() and copy_fd_bitmaps()) can be an arbitrary number. if (max_fd >= last_fd(files_fdtable(cur_fds))) max_unshare_fds = fd; and not be a multiple of BITS_PER_LONG or BITS_PER_BYTE. In case of Syzkaller reproducer this value equals 69 - three standard file descriptors, 66 pipe descriptors and 1 for /dev/ptmx; nr value used in alloc_fdtable() is 128 (that' okay). But here is the weird place which causes the leak described in the patch. KASAN detected that leak and possibly the location of the leak is in copy_fd_bitmaps(): I experimented with possible solutions and if add_byte logic is implemented, then KASAN does not find any leaks. Of course, the problem can be somewhere else and I don't notice it. On Sat, Mar 26, 2022 at 3:15 PM Linus Torvalds wrote: > Certainly NR_OPEN_DEFAULT, sane_fdtable_size() and max_fds should > always be a multiple of BITS_PER_LONG. I totally agree with you but in the reproducer case the max_fds value does not follow these rules. I think there is probably something wrong in dup_fd() when getting open_files value and passing it to copy_fd_bitmaps().