From: Nikolay Borisov <nik.borisov@suse.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, mohocko@suse.com, jslaby@suse.cz,
Nikolay Borisov <nik.borisov@suse.com>
Subject: [PATCH v4 6/6] x86: Make IA32_EMULATION boot time configurable
Date: Fri, 23 Jun 2023 14:14:09 +0300 [thread overview]
Message-ID: <20230623111409.3047467-7-nik.borisov@suse.com> (raw)
In-Reply-To: <20230623111409.3047467-1-nik.borisov@suse.com>
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 <nik.borisov@suse.com>
---
Documentation/admin-guide/kernel-parameters.txt | 6 ++++++
arch/x86/Kconfig | 9 +++++++++
arch/x86/entry/common.c | 9 ++++++++-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9e5bab29685f..99ff94e963b8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1865,6 +1865,12 @@
0 -- machine default
1 -- force brightness inversion
+ ia32_emulation= [X86-64]
+ Format: <bool>
+ When true, allows loading 32-bit programs and executing 32-bit
+ syscalls, essentially overriding IA32_EMULATION_DEFAULT_DISABLED at
+ boot time. When false, unconditionally disables IA32 emulation.
+
icn= [HW,ISDN]
Format: <io>[,<membase>[,<icn_id>[,<icn_id2>]]]
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 53bab123a8ee..15f313399ed4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3038,6 +3038,15 @@ config IA32_EMULATION
64-bit kernel. You should likely turn this on, unless you're
100% sure that you don't have any 32-bit programs left.
+config IA32_EMULATION_DEFAULT_DISABLED
+ bool "IA32 emulation disabled by default"
+ default n
+ depends on IA32_EMULATION
+ help
+ Make IA32 emulation disabled by default. This prevents loading 32-bit
+ processes and access to 32-bit syscalls. If unsure, leave it to its
+ default value.
+
config X86_X32_ABI
bool "x32 ABI for 64-bit mode"
depends on X86_64
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index ef5a154a7413..b5dd1e226c99 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -19,6 +19,7 @@
#include <linux/nospec.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
+#include <linux/init.h>
#ifdef CONFIG_XEN_PV
#include <xen/xen-ops.h>
@@ -97,7 +98,13 @@ static __always_inline int syscall_32_enter(struct pt_regs *regs)
}
#ifdef CONFIG_IA32_EMULATION
-bool __ia32_enabled = true;
+bool __ia32_enabled = !IS_ENABLED(CONFIG_IA32_EMULATION_DEFAULT_DISABLED);
+
+static int ia32_emulation_override_cmdline(char *arg)
+{
+ return kstrtobool(arg, &__ia32_enabled);
+}
+early_param("ia32_emulation", ia32_emulation_override_cmdline);
#endif
/*
--
2.34.1
next prev parent reply other threads:[~2023-06-23 11:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 11:14 [PATCH v4 0/6] Make IA32_EMULATION boot time overridable Nikolay Borisov
2023-06-23 11:14 ` [PATCH v4 1/6] x86: Introduce ia32_enabled() Nikolay Borisov
2023-06-30 11:18 ` Thomas Gleixner
2023-06-30 11:44 ` Thomas Gleixner
2023-09-14 11:27 ` [tip: x86/entry] " tip-bot2 for Nikolay Borisov
2023-06-23 11:14 ` [PATCH v4 2/6] x86/entry: Rename ignore_sysret() Nikolay Borisov
2023-09-14 11:27 ` [tip: x86/entry] " tip-bot2 for Nikolay Borisov
2023-06-23 11:14 ` [PATCH v4 3/6] x86/entry: Compile entry_SYSCALL32_ignore() unconditionally Nikolay Borisov
2023-09-14 11:27 ` [tip: x86/entry] " tip-bot2 for Nikolay Borisov
2023-06-23 11:14 ` [PATCH v4 4/6] x86/elf: Make loading of 32bit processes depend on ia32_enabled() Nikolay Borisov
2023-09-14 11:27 ` [tip: x86/entry] " tip-bot2 for Nikolay Borisov
2023-06-23 11:14 ` [PATCH v4 5/6] x86/entry: Make IA32 syscalls' availability " Nikolay Borisov
2023-09-14 11:27 ` [tip: x86/entry] " tip-bot2 for Nikolay Borisov
2023-06-23 11:14 ` Nikolay Borisov [this message]
2023-09-14 11:27 ` [tip: x86/entry] x86: Make IA32_EMULATION boot time configurable tip-bot2 for Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230623111409.3047467-7-nik.borisov@suse.com \
--to=nik.borisov@suse.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mohocko@suse.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®