From 0086c4721650ef776f233697a2aac7011bfe4470f408c5f95707d991fb595962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 13 Mar 2020 14:29:38 +0000 Subject: [PATCH] Accepting request 784673 from home:ptesarik:branches:Kernel:kdump - kexec-tools-reset-getopt-before-falling-back-to-legacy.patch: Reset getopt before falling back to legacy syscall (bsc#1166105). OBS-URL: https://build.opensuse.org/request/show/784673 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=123 --- ...s-fix-kexec_file_load-error-handling.patch | 1 + ...getopt-before-falling-back-to-legacy.patch | 54 +++++++++++++++++++ kexec-tools.changes | 6 +++ kexec-tools.spec | 2 + 4 files changed, 63 insertions(+) create mode 100644 kexec-tools-reset-getopt-before-falling-back-to-legacy.patch diff --git a/kexec-tools-fix-kexec_file_load-error-handling.patch b/kexec-tools-fix-kexec_file_load-error-handling.patch index b635f78..e626fc4 100644 --- a/kexec-tools-fix-kexec_file_load-error-handling.patch +++ b/kexec-tools-fix-kexec_file_load-error-handling.patch @@ -3,6 +3,7 @@ From: Petr Tesarik Date: Thu, 12 Mar 2020 20:12:12 +0100 Upstream: not yet, patch sent 2020-03-12 Subject: Fix kexec_file_load(2) error handling +References: bsc#1166105 The handling of kexec_file_load() error conditions needs some improvement. diff --git a/kexec-tools-reset-getopt-before-falling-back-to-legacy.patch b/kexec-tools-reset-getopt-before-falling-back-to-legacy.patch new file mode 100644 index 0000000..9bcc96a --- /dev/null +++ b/kexec-tools-reset-getopt-before-falling-back-to-legacy.patch @@ -0,0 +1,54 @@ +From dadafc4664c7b78ea1561ccca33986c9639106ec Mon Sep 17 00:00:00 2001 +From: Petr Tesarik +Date: Fri, 13 Mar 2020 14:54:00 +0100 +Upstream: not yet, patch sent 2020-03-13 +Subject: Reset getopt before falling back to legacy syscall +References: bsc#1166105 + +The modules may need to parse the arguments again after +kexec_file_load(2) failed, but getopt is not reset. + +This change fixes the --initrd option on s390x. Without this patch, +it will fail to load the initrd on kernels that do not implement +kexec_file_load(2). + +Signed-off-by: Petr Tesarik +--- + kexec/kexec.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/kexec/kexec.c b/kexec/kexec.c +index 33c1b4b..6601f1f 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -1538,8 +1538,12 @@ int main(int argc, char *argv[]) + if (do_unload) { + if (do_kexec_file_syscall) { + result = kexec_file_unload(kexec_file_flags); +- if (result == EFALLBACK && do_kexec_fallback) ++ if (result == EFALLBACK && do_kexec_fallback) { ++ /* Reset getopt for fallback */ ++ opterr = 1; ++ optind = 1; + do_kexec_file_syscall = 0; ++ } + } + if (!do_kexec_file_syscall) + result = k_unload(kexec_flags); +@@ -1548,8 +1552,12 @@ int main(int argc, char *argv[]) + if (do_kexec_file_syscall) { + result = do_kexec_file_load(fileind, argc, argv, + kexec_file_flags); +- if (result == EFALLBACK && do_kexec_fallback) ++ if (result == EFALLBACK && do_kexec_fallback) { ++ /* Reset getopt for fallback */ ++ opterr = 1; ++ optind = 1; + do_kexec_file_syscall = 0; ++ } + } + if (!do_kexec_file_syscall) + result = my_load(type, fileind, argc, argv, +-- +2.16.4 + diff --git a/kexec-tools.changes b/kexec-tools.changes index a8b0e4a..f473d24 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Mar 13 14:11:55 UTC 2020 - Petr Tesařík + +- kexec-tools-reset-getopt-before-falling-back-to-legacy.patch: + Reset getopt before falling back to legacy syscall (bsc#1166105). + ------------------------------------------------------------------- Fri Mar 13 08:37:58 UTC 2020 - Petr Tesařík diff --git a/kexec-tools.spec b/kexec-tools.spec index 0c53e12..3c1a1b0 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -37,6 +37,7 @@ Patch8: %{name}-build-multiboot2-for-i386.patch Patch9: %{name}-video-capability.patch Patch10: %{name}-SYS_getrandom.patch Patch11: %{name}-fix-kexec_file_load-error-handling.patch +Patch12: %{name}-reset-getopt-before-falling-back-to-legacy.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: systemd-rpm-macros @@ -70,6 +71,7 @@ the loaded kernel after it panics. %patch9 -p1 %patch10 -p1 %patch11 -p1 +%patch12 -p1 %build autoreconf -fvi