diff --git a/kdump-avoid-endless-loop-on-EAI_AGAIN.patch b/kdump-avoid-endless-loop-on-EAI_AGAIN.patch new file mode 100644 index 0000000..c55c5ab --- /dev/null +++ b/kdump-avoid-endless-loop-on-EAI_AGAIN.patch @@ -0,0 +1,102 @@ +From: Petr Pavlu +Date: Thu Mar 25 12:48:54 2021 +0100 +Subject: Avoid an endless loop when resolving a hostname fails with EAI_AGAIN +References: bsc#1183070 +Upstream: merged +Git-commit: 716883423f45acf3271c200353dce074d6ffc5be + +Method Routable::resolve() invokes function getaddrinfo() to obtain a +network address for a given hostname. This operation can fail with the +error code EAI_AGAIN to indicate that the name server encountered a +temporary failure. Routable::resolve() reacts to this situation by +calling getaddrinfo() again which can result in an endless loop if the +function continues to return this error code. It is not guaranteed that +the underlying reason for EAI_AGAIN will go away in some bounded time. + +The patch removes the EAI_AGAIN loop in Routable::resolve() and updates +the retry code in Routable::check() to repeatedly attempt resolving a +hostname until it succeeds or a specified timeout for network operations +is reached. + +--- + kdumptool/routable.cc | 38 ++++++++++++++++++++++++++++++-------- + 1 file changed, 30 insertions(+), 8 deletions(-) + +--- a/kdumptool/routable.cc ++++ b/kdumptool/routable.cc +@@ -17,6 +17,7 @@ + * 02110-1301, USA. + */ + ++#include + #include + + #include +@@ -36,6 +37,8 @@ + #include "stringutil.h" + #include "debug.h" + ++using std::min; ++ + //{{{ NetLink ------------------------------------------------------------------ + + #define NETLINK_DEF_RECV_MAX 1024 +@@ -470,9 +473,7 @@ bool Routable::resolve(void) + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_RAW; +- do { +- res = getaddrinfo(raw_host.c_str(), NULL, &hints, &m_ai); +- } while (res == EAI_AGAIN); ++ res = getaddrinfo(raw_host.c_str(), NULL, &hints, &m_ai); + + if (res == 0) + return true; +@@ -480,7 +481,8 @@ bool Routable::resolve(void) + if (res == EAI_SYSTEM) + throw KSystemError("Name resolution failed", errno); + +- if (res != EAI_NONAME && res != EAI_FAIL && res != EAI_NODATA) ++ if (res != EAI_NONAME && res != EAI_FAIL && res != EAI_NODATA && ++ res != EAI_AGAIN) + throw KGaiError("Name resolution failed", res); + + return false; +@@ -489,13 +491,33 @@ bool Routable::resolve(void) + // ----------------------------------------------------------------------------- + bool Routable::check(int timeout) + { ++ // Resolve the target hostname. An attempt is made regularly until the ++ // hostname can be resolved or a specified timeout for network operations ++ // is reached. ++ struct timespec tstop; ++ clock_gettime(CLOCK_MONOTONIC, &tstop); ++ tstop.tv_sec += timeout; ++ ++ while (!resolve()) { ++ struct timespec tsnow; ++ clock_gettime(CLOCK_MONOTONIC, &tsnow); ++ int interval = (tstop.tv_sec - tsnow.tv_sec) * 1000; ++ interval += (tstop.tv_nsec - tsnow.tv_nsec) / 1000000L; ++ if (interval <= 0) ++ return false; ++ ++ // Sleep, at most for 1 second. ++ struct timespec wait_period; ++ interval = min(interval, 1000); ++ wait_period.tv_sec = interval / 1000; ++ wait_period.tv_nsec = (interval % 1000) * 1000 * 1000; ++ nanosleep(&wait_period, NULL); ++ } ++ ++ // Check there is an existing route. + NetLink nl(RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_ROUTE); + nl.setTimeout(timeout); + +- while (!resolve()) +- if (nl.waitRouteChange() != 0) +- return false; +- + while (!hasRoute()) + if (nl.waitRouteChange() != 0) + return false; diff --git a/kdump-do-not-iterate-past-end-of-string.patch b/kdump-do-not-iterate-past-end-of-string.patch new file mode 100644 index 0000000..d794624 --- /dev/null +++ b/kdump-do-not-iterate-past-end-of-string.patch @@ -0,0 +1,27 @@ +From: Petr Tesarik +Date: Fri May 28 11:30:48 2021 +0200 +Subject: URLParser::extractAuthority(): Do not iterate past end of string +References: bsc#1186037 +Upstream: merged +Git-commit: 208ed364ac926f800f37874d08e5b2c26547974e + +If there is no '/', '?' or '#' at the end of the authority part of +the URL, kdumptool must not crash. + +Signed-off-by: Petr Tesarik + +--- + kdumptool/urlparser.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kdumptool/urlparser.cc ++++ b/kdumptool/urlparser.cc +@@ -117,7 +117,7 @@ string URLParser::extractAuthority(strin + + it += 2; + string::iterator const start = it; +- while (*it != '/' && *it != '?' && *it != '#') ++ while (it != end && *it != '/' && *it != '?' && *it != '#') + ++it; + + return string(start, it); diff --git a/kdump-fix-incorrect-exit-code-checking.patch b/kdump-fix-incorrect-exit-code-checking.patch new file mode 100644 index 0000000..6e496f7 --- /dev/null +++ b/kdump-fix-incorrect-exit-code-checking.patch @@ -0,0 +1,40 @@ +Author: Petr Tesarik +Date: Tue May 25 12:48:08 2021 +0200 +Subject: Fix incorrect exit code checking after "local" with assignment +References: bsc#1184616 LTC#192282 +Upstream: merged +Git-commit: 33abc7c481f62c23727505eafa354253088dae8d + +The "local" keyword cannot be combined with the assignment if the +exit status is needed later. The exit status of the whole +statement is that of the "local" built-in (always zero), +regardless of the the exit status of the assignment. + +Acked-by: Petr Tesarik + +--- + init/load.sh | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/init/load.sh ++++ b/init/load.sh +@@ -312,7 +312,8 @@ function load_kdump_fadump() + # Find the desired kernel and initrd + function find_kernel() + { +- local output=$($KDUMPTOOL find_kernel) ++ local output ++ output=$($KDUMPTOOL find_kernel) + test $? -eq 0 || return 1 + + kdump_kernel=$(echo "$output" | grep ^Kernel | cut -f 2) +@@ -325,7 +326,8 @@ function find_kernel() + # Rebuild the kdump initramfs if necessary + function rebuild_kdumprd() + { +- local output=$(mkdumprd -K "$kdump_kernel" -I "$kdump_initrd" 2>&1) ++ local output ++ output=$(mkdumprd -K "$kdump_kernel" -I "$kdump_initrd" 2>&1) + if [ $? -ne 0 ] ; then + echo "$output" + return 1 diff --git a/kdump-install-real-resolv.conf.patch b/kdump-install-real-resolv.conf.patch new file mode 100644 index 0000000..d4894fc --- /dev/null +++ b/kdump-install-real-resolv.conf.patch @@ -0,0 +1,36 @@ +From: Petr Pavlu +Date: Thu Mar 25 12:43:32 2021 +0100 +Subject: Install /etc/resolv.conf using its resolved path +References: bsc#1183070 +Upstream: merged +Git-commit: b8439e03d4479f3ffa4b42961a5da18f4b819122 + +Resolve /etc/resolv.conf first to install directly the target file if it +is a symlink. This simplifies the setup and avoids any problems when the +real resolv.conf could be in a location that gets hidden by a mount done +in the kdump environment, for instance, /etc/resolv.conf -> +/run/netconfig/resolv.conf with tmpfs getting mounted on /run. + +--- + init/module-setup.sh | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/init/module-setup.sh ++++ b/init/module-setup.sh +@@ -308,7 +308,15 @@ install() { + + inst_multiple makedumpfile makedumpfile-R.pl kdumptool \ + $KDUMP_REQUIRED_PROGRAMS +- inst_simple /etc/resolv.conf ++ ++ # Install /etc/resolv.conf to provide initial DNS configuration. The file ++ # is resolved first to install directly the target file if it is a symlink. ++ # The real resolv.conf could be in a location that gets hidden by a mount ++ # done in the kdump environment, for instance, /etc/resolv.conf -> ++ # /run/netconfig/resolv.conf with tmpfs getting mounted on /run. ++ local resolv=$(realpath /etc/resolv.conf) ++ inst_simple "$resolv" /etc/resolv.conf ++ + inst_simple /usr/share/zoneinfo/UTC + inst_simple /etc/localtime + } diff --git a/kdump.changes b/kdump.changes index 5561790..86a7456 100644 --- a/kdump.changes +++ b/kdump.changes @@ -1,3 +1,25 @@ +------------------------------------------------------------------- +Fri May 28 10:33:45 UTC 2021 - Petr Tesařík + +- Fix use of DNS in the panic environment (bsc#1183070): + * kdump-avoid-endless-loop-on-EAI_AGAIN.patch: Avoid an endless + loop when resolving a hostname fails with EAI_AGAIN. + * kdump-install-real-resolv.conf.patch: Install /etc/resolv.conf + using its resolved path. + +------------------------------------------------------------------- +Fri May 28 09:51:58 UTC 2021 - Petr Tesařík + +- kdump-fix-incorrect-exit-code-checking.patch: Fix incorrect exit + code checking after "local" with assignment (bsc#1184616, + LTC#192282) + +------------------------------------------------------------------- +Fri May 28 09:36:47 UTC 2021 - Petr Tesařík + +- kdump-do-not-iterate-past-end-of-string.patch: Fix a crash caused + by iterating past end of string (bsc#1186037). + ------------------------------------------------------------------- Thu Apr 8 08:38:03 UTC 2021 - Petr Tesařík diff --git a/kdump.spec b/kdump.spec index 19276c2..b695308 100644 --- a/kdump.spec +++ b/kdump.spec @@ -37,6 +37,10 @@ Patch9: %{name}-use-pbl.patch Patch10: %{name}-on-error-option-yesno.patch Patch11: %{name}-mounts.cc-Include-sys-ioctl.h.patch Patch12: %{name}-Add-bootdev-to-dracut-command-line.patch +Patch13: %{name}-do-not-iterate-past-end-of-string.patch +Patch14: %{name}-fix-incorrect-exit-code-checking.patch +Patch15: %{name}-avoid-endless-loop-on-EAI_AGAIN.patch +Patch16: %{name}-install-real-resolv.conf.patch BuildRequires: asciidoc BuildRequires: cmake BuildRequires: gcc-c++ @@ -93,6 +97,10 @@ after a crash dump has occured. %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 %build export CXXFLAGS="%{optflags} -std=c++11"