Skip to content

Commit a11e097

Browse files
Nikolay BorisovKAGA-KOKO
authored andcommitted
x86: Make IA32_EMULATION boot time configurable
Distributions would like to reduce their attack surface as much as possible but at the same time they'd want to retain flexibility to cater to a variety of legacy software. This stems from the conjecture that compat layer is likely rarely tested and could have latent security bugs. Ideally distributions will set their default policy and also give users the ability to override it as appropriate. To enable this use case, introduce CONFIG_IA32_EMULATION_DEFAULT_DISABLED compile time option, which controls whether 32bit processes/syscalls should be allowed or not. This option is aimed mainly at distributions to set their preferred default behavior in their kernels. To allow users to override the distro's policy, introduce the 'ia32_emulation' parameter which allows overriding CONFIG_IA32_EMULATION_DEFAULT_DISABLED state at boot time. Signed-off-by: Nikolay Borisov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6138228 commit a11e097

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,12 @@
18931893
0 -- machine default
18941894
1 -- force brightness inversion
18951895

1896+
ia32_emulation= [X86-64]
1897+
Format: <bool>
1898+
When true, allows loading 32-bit programs and executing 32-bit
1899+
syscalls, essentially overriding IA32_EMULATION_DEFAULT_DISABLED at
1900+
boot time. When false, unconditionally disables IA32 emulation.
1901+
18961902
icn= [HW,ISDN]
18971903
Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
18981904

arch/x86/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,15 @@ config IA32_EMULATION
29542954
64-bit kernel. You should likely turn this on, unless you're
29552955
100% sure that you don't have any 32-bit programs left.
29562956

2957+
config IA32_EMULATION_DEFAULT_DISABLED
2958+
bool "IA32 emulation disabled by default"
2959+
default n
2960+
depends on IA32_EMULATION
2961+
help
2962+
Make IA32 emulation disabled by default. This prevents loading 32-bit
2963+
processes and access to 32-bit syscalls. If unsure, leave it to its
2964+
default value.
2965+
29572966
config X86_X32_ABI
29582967
bool "x32 ABI for 64-bit mode"
29592968
depends on X86_64

arch/x86/entry/common.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/nospec.h>
2020
#include <linux/syscalls.h>
2121
#include <linux/uaccess.h>
22+
#include <linux/init.h>
2223

2324
#ifdef CONFIG_XEN_PV
2425
#include <xen/xen-ops.h>
@@ -97,7 +98,13 @@ static __always_inline int syscall_32_enter(struct pt_regs *regs)
9798
}
9899

99100
#ifdef CONFIG_IA32_EMULATION
100-
bool __ia32_enabled __ro_after_init = true;
101+
bool __ia32_enabled __ro_after_init = !IS_ENABLED(CONFIG_IA32_EMULATION_DEFAULT_DISABLED);
102+
103+
static int ia32_emulation_override_cmdline(char *arg)
104+
{
105+
return kstrtobool(arg, &__ia32_enabled);
106+
}
107+
early_param("ia32_emulation", ia32_emulation_override_cmdline);
101108
#endif
102109

103110
/*

0 commit comments

Comments
 (0)