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