| 1 | From d1396f7688ebde917429b6177a6f0cecfa0c839c Mon Sep 17 00:00:00 2001
|
| 2 | From: Natanael Copa <[email protected]>
|
| 3 | Date: Thu, 14 Jul 2022 13:23:51 +0200
|
| 4 | Subject: [PATCH 3/5] kexec: add kexec_load_disabled boot option
|
| 5 |
|
| 6 | Make kexec_load disabled by default and add a boot option to enable it:
|
| 7 | kexec_load_disabled=0
|
| 8 | ---
|
| 9 | init/main.c | 8 +++++---
|
| 10 | kernel/kexec_core.c | 11 ++++++++++-
|
| 11 | 2 files changed, 15 insertions(+), 4 deletions(-)
|
| 12 |
|
| 13 | diff --git a/init/main.c b/init/main.c
|
| 14 | index 821df1f05e9c..38caf1550306 100644
|
| 15 | |
| 16 | |
| 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 */
|
| 32 | diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
|
| 33 | index c0caa14880c3..e3af6628f098 100644
|
| 34 | |
| 35 | |
| 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 | --
|
| 55 | 2.51.2
|
| 56 |
|