Skip to content

Commit 2535e0d

Browse files
joshtripletttorvalds
authored andcommitted
fs: make binfmt support for #! scripts modular and removable
Add a new configuration option CONFIG_BINFMT_SCRIPT to configure support for interpreted scripts starting with "#!"; allow compiling out that support, or building it as a module. Embedded systems running exclusively compiled binaries could leave this support out, and systems that don't need scripts before mounting the root filesystem can build this as a module. Signed-off-by: Josh Triplett <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d6d67e7 commit 2535e0d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

fs/Kconfig.binfmt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ config CORE_DUMP_DEFAULT_ELF_HEADERS
6565
This config option changes the default setting of coredump_filter
6666
seen at boot time. If unsure, say Y.
6767

68+
config BINFMT_SCRIPT
69+
tristate "Kernel support for scripts starting with #!"
70+
default y
71+
help
72+
Say Y here if you want to execute interpreted scripts starting with
73+
#! followed by the path to an interpreter.
74+
75+
You can build this support as a module; however, until that module
76+
gets loaded, you cannot run scripts. Thus, if you want to load this
77+
module from an initramfs, the portion of the initramfs before loading
78+
this module must consist of compiled binaries only.
79+
80+
Most systems will not boot if you say M or N here. If unsure, say Y.
81+
6882
config BINFMT_FLAT
6983
bool "Kernel support for flat binaries"
7084
depends on !MMU && (!FRV || BROKEN)

fs/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
3434
obj-$(CONFIG_BINFMT_AOUT) += binfmt_aout.o
3535
obj-$(CONFIG_BINFMT_EM86) += binfmt_em86.o
3636
obj-$(CONFIG_BINFMT_MISC) += binfmt_misc.o
37-
38-
# binfmt_script is always there
39-
obj-y += binfmt_script.o
40-
37+
obj-$(CONFIG_BINFMT_SCRIPT) += binfmt_script.o
4138
obj-$(CONFIG_BINFMT_ELF) += binfmt_elf.o
4239
obj-$(CONFIG_COMPAT_BINFMT_ELF) += compat_binfmt_elf.o
4340
obj-$(CONFIG_BINFMT_ELF_FDPIC) += binfmt_elf_fdpic.o

0 commit comments

Comments
 (0)