projects/aports·blob master · refs

56 lines · 1.7 KiB

1From d1396f7688ebde917429b6177a6f0cecfa0c839c Mon Sep 17 00:00:00 2001
2From: Natanael Copa <[email protected]>
3Date: Thu, 14 Jul 2022 13:23:51 +0200
4Subject: [PATCH 3/5] kexec: add kexec_load_disabled boot option
5
6Make kexec_load disabled by default and add a boot option to enable it:
7kexec_load_disabled=0
8---
9 init/main.c | 8 +++++---
10 kernel/kexec_core.c | 11 ++++++++++-
11 2 files changed, 15 insertions(+), 4 deletions(-)
12
13diff --git a/init/main.c b/init/main.c
14index 821df1f05e9c..38caf1550306 100644
15--- a/init/main.c
16+++ b/init/main.c
17@@ -557,9 +557,11 @@ static int __init unknown_bootoption(char *param, char *val,
18 repair_env_string(param, val);
19
20 /* Handle bootloader identifier */
21- for (int i = 0; bootloader[i]; i++) {
22- if (strstarts(param, bootloader[i]))
23- return 0;
24+ if (!strstarts(param, "kexec_load_disabled=")) {
25+ for (int i = 0; bootloader[i]; i++) {
26+ if (strstarts(param, bootloader[i]))
27+ return 0;
28+ }
29 }
30
31 /* Handle obsolete-style parameters */
32diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
33index c0caa14880c3..e3af6628f098 100644
34--- a/kernel/kexec_core.c
35+++ b/kernel/kexec_core.c
36@@ -885,7 +885,16 @@ static struct kexec_load_limit load_limit_panic = {
37
38 struct kimage *kexec_image;
39 struct kimage *kexec_crash_image;
40-static int kexec_load_disabled;
41+static int kexec_load_disabled = 1;
42+
43+static int __init kexec_load_disabled_setup(char *str)
44+{
45+ unsigned long disabled;
46+ if (!kstrtoul(str, 0, &disabled))
47+ kexec_load_disabled = disabled ? 1 : 0;
48+ return 1;
49+}
50+__setup("kexec_load_disabled=", kexec_load_disabled_setup);
51
52 #ifdef CONFIG_SYSCTL
53 static int kexec_limit_handler(const struct ctl_table *table, int write,
54--
552.51.2
56