linux-stable/fs
Al Viro 4edaeba45b alloc_fdtable(): change calling conventions.
[ Upstream commit 1d3b4bec3c ]

First of all, tell it how many slots do we want, not which slot
is wanted.  It makes one caller (dup_fd()) more straightforward
and doesn't harm another (expand_fdtable()).

Furthermore, make it return ERR_PTR() on failure rather than
returning NULL.  Simplifies the callers.

Simplify the size calculation, while we are at it - note that we
always have slots_wanted greater than BITS_PER_LONG.  What the
rules boil down to is
	* use the smallest power of two large enough to give us
that many slots
	* on 32bit skip 64 and 128 - the minimal capacity we want
there is 256 slots (i.e. 1Kb fd array).
	* on 64bit don't skip anything, the minimal capacity is
128 - and we'll never be asked for 64 or less.  128 slots means
1Kb fd array, again.
	* on 128bit, if that ever happens, don't skip anything -
we'll never be asked for 128 or less, so the fd array allocation
will be at least 2Kb.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-08-28 16:31:16 +02:00
..
9p
adfs
affs
afs
autofs
bcachefs
befs
bfs
btrfs btrfs: subpage: keep TOWRITE tag until folio is cleaned 2025-08-28 16:31:07 +02:00
cachefiles
ceph parse_longname(): strrchr() expects NUL-terminated string 2025-08-15 12:13:31 +02:00
coda
configfs
cramfs
crypto fscrypt: Don't use problematic non-inline crypto engines 2025-08-20 18:30:15 +02:00
debugfs debugfs: fix mount options not being applied 2025-08-28 16:31:08 +02:00
devpts
dlm
ecryptfs
efivarfs
efs
erofs erofs: fix large fragment handling 2025-08-01 09:48:45 +01:00
exfat exfat: add cluster chain loop check for dir 2025-08-20 18:30:47 +02:00
exportfs
ext2 ext2: Handle fiemap on empty files to prevent EINVAL 2025-08-20 18:30:21 +02:00
ext4 ext4: preserve SB_I_VERSION on remount 2025-08-28 16:31:07 +02:00
f2fs f2fs: fix to avoid out-of-boundary access in dnode page 2025-08-28 16:30:59 +02:00
fat
freevxfs
fuse
gfs2 gfs2: Set .migrate_folio in gfs2_{rgrp,meta}_aops 2025-08-20 18:30:20 +02:00
hfs hfs: fix not erasing deleted b-tree node issue 2025-08-20 18:30:20 +02:00
hfsplus hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file() 2025-08-20 18:30:19 +02:00
hostfs
hpfs
hugetlbfs
iomap
isofs
jbd2 jbd2: prevent softlockup in jbd2_log_do_checkpoint() 2025-08-28 16:30:59 +02:00
jffs2
jfs jfs: upper bound check of tree index in dbAllocAG 2025-08-20 18:30:42 +02:00
kernfs
lockd
minix
netfs netfs: Fix unbuffered write error handling 2025-08-28 16:31:04 +02:00
nfs NFS: Fix a race when updating an existing write 2025-08-28 16:31:05 +02:00
nfs_common
nfsd NFSD: detect mismatch of file handle and delegation stateid in OPEN op 2025-08-20 18:30:14 +02:00
nilfs2 nilfs2: reject invalid file types when reading inodes 2025-08-01 09:48:43 +01:00
nls
notify fanotify: sanitize handle_type values when reporting fid 2025-08-15 12:13:51 +02:00
ntfs3 fs/ntfs3: correctly create symlink for relative path 2025-08-20 18:30:21 +02:00
ocfs2
omfs
openpromfs
orangefs fs/orangefs: use snprintf() instead of sprintf() 2025-08-20 18:30:41 +02:00
overlayfs ovl: use I_MUTEX_PARENT when locking parent in ovl_create_temp() 2025-08-28 16:31:10 +02:00
proc mm/smaps: fix race between smaps_hugetlb_range and migration 2025-08-20 18:30:17 +02:00
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
smb cifs: Fix oops due to uninitialised variable 2025-08-28 16:31:14 +02:00
squashfs squashfs: fix memory leak in squashfs_fill_super 2025-08-28 16:31:05 +02:00
sysfs
sysv
tests
tracefs tracefs: Add d_delete to remove negative dentries 2025-08-20 18:30:21 +02:00
ubifs
udf udf: Verify partition map count 2025-08-20 18:30:20 +02:00
ufs
unicode
vboxsf
verity
xfs xfs: fully decouple XFS_IBULK* flags from XFS_IWALK* flags 2025-08-28 16:31:04 +02:00
zonefs
aio.c
anon_inodes.c
attr.c
backing-file.c
bad_inode.c
binfmt_elf_fdpic.c
binfmt_elf.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
bpf_fs_kfuncs.c
buffer.c fs/buffer: fix use-after-free when call bh_read() helper 2025-08-28 16:31:08 +02:00
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c
dcache.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c eventpoll: Fix semi-unbounded recursion 2025-08-20 18:30:15 +02:00
exec.c
fcntl.c
fhandle.c
file_table.c
file.c alloc_fdtable(): change calling conventions. 2025-08-28 16:31:16 +02:00
filesystems.c
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fs-writeback.c
fsopen.c
init.c
inode.c
internal.h
ioctl.c
Kconfig
Kconfig.binfmt
kernel_read_file.c
libfs.c better lockdep annotations for simple_recursive_removal() 2025-08-20 18:30:20 +02:00
locks.c
Makefile
mbcache.c
mnt_idmapping.c
mount.h
mpage.c
namei.c
namespace.c use uniform permission checks for all mount propagation changes 2025-08-28 16:31:08 +02:00
nsfs.c
open.c
pidfs.c pidfs: raise SB_I_NODEV and SB_I_NOEXEC 2025-08-20 18:30:21 +02:00
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c netfs: Fix unbuffered write error handling 2025-08-28 16:31:04 +02:00
stack.c
stat.c
statfs.c
super.c
sync.c
sysctls.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c