linux/include
Christian Brauner b604897764
binfmt_misc: correctly account pre-opened interpreters
An 'F' entry, and every interpreter a 'B' entry binds, holds a file open
from registration until the entry goes away, pinning the file, its inode,
the mount it came from and that mount's superblock. Nothing bounds how
many of those a user namespace can hold. An entry binds at most
BINFMT_MISC_INTERP_MAX interpreters, but nothing caps the entries.

Charge each binding to the user namespace and uid that makes it against a
new UCOUNT_BINFMT_MISC_INTERPRETERS. Going over budget causes -ENOSPC.

A per-instance cap would suck. Instances are keyed on the user
namespace. So any constant is multiplied by the number of namespaces the
caller creates. Creating those is virtually free. A ucount charges the
namespace and every one of its ancestors. And a namespace can raise only
its own limit. So nesting buys nothing.

The knob is /proc/sys/user/max_binfmt_misc_interpreters. Leave it at the
max_threads/2 default fork_init() gives a new type. No existing
configuration comes close to that.

binfmt_misc is tristate, which makes it the first ucount user that can be
built as a module. Export inc_ucount() and dec_ucount(); without them
CONFIG_BINFMT_MISC=m fails to link. Export them to binfmt_misc alone:
charging a ucount type is not something a module has any business doing
in general, and the list is trivial to extend if a second user shows up.
init_user_ns and init_binfmt_misc are already exported for the same
module.

Link: https://patch.msgid.link/20260803-work-binfmt_misc-interplimit-v1-1-4a2435500bd9@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-08-03 23:36:18 +02:00
..
acpi ACPICA: Define acpi_ut_safe_strncpy() as strscpy_pad() alias 2026-07-01 12:29:24 +02:00
asm-generic mm.git review status for mm-hotfixes-stable..mm-nonmm-stable 2026-06-21 13:20:19 -07:00
clocksource
crypto
cxl
drm drm-misc-fixes for v7.2-rc5: 2026-07-24 18:30:29 +10:00
dt-bindings SoC fixes for 7.2 2026-07-17 08:52:09 -07:00
hyperv
keys
kunit
kvm
linux binfmt_misc: correctly account pre-opened interpreters 2026-08-03 23:36:18 +02:00
math-emu
media
memory
misc
net tcp: challenge ACK for non-exact RST in SYN-RECEIVED 2026-07-23 08:27:22 -07:00
pcmcia Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (headers) 2026-07-03 07:38:16 +02:00
ras
rdma
rv
scsi scsi: core: wake eh reliably when using scsi_schedule_eh 2026-07-12 22:21:22 -04:00
soc soc/tegra: pmc: Fixes for v7.2 2026-07-10 14:40:52 +02:00
sound Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (headers) 2026-07-03 07:38:16 +02:00
target
trace mm/memory-failure: trace: change memory_failure_event to ras subsystem 2026-07-09 15:48:56 -07:00
uapi exec: add AT_FLAGS_TRANSPARENT_INTERP 2026-08-03 10:08:45 +02:00
ufs
vdso
video
xen xen: Replace __ASSEMBLY__ with __ASSEMBLER__ in header files 2026-07-01 09:49:52 +02:00
Kbuild