File 0019-Add-kernel-version-dependent-check-for-getting-lengt.patch of Package crash
From b8e1f2735b8dd1303aeb2affa309a2a409a82d38 Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Mon, 26 Jul 2021 09:58:54 +0800
Subject: [PATCH] Add kernel version dependent check for getting length of
log_end
For kernels(>=2.4.9.11 [1] && <3.5 [2]), log_end was involved in the kernel sources.
For kernels(>=2.6.25 [3]), log_end was defined as:
static unsigned log_end;
For kernels(<2.6.25), log_end was defined as:
static unsigned long log_end;
Previously, the length of log_end is determined by get_symbol_length, but it can
be a regression when the returned length is 0 for some cases and value unchecked:
crash> help -t
...
help: invalid size request: 0 type: "log_end"
To solve the above issue, let's add a kernel version dependent check to get its
value appropriately when the length of the 'log_end' returns a value of zero.
[1]: https://elixir.bootlin.com/linux/2.4.9.11/source/kernel/printk.c#L74
[2]: https://elixir.bootlin.com/linux/v3.5/source/kernel/printk.c
[3]: https://elixir.bootlin.com/linux/v2.6.25/source/kernel/printk.c#L104
Signed-off-by: Tao Liu <ltao@redhat.com>
---
kernel.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel.c b/kernel.c
index a559f93..a8be7bb 100644
--- a/kernel.c
+++ b/kernel.c
@@ -5106,6 +5106,10 @@ dump_log(int msg_flags)
if ((len = get_symbol_length("log_end")) == sizeof(int)) {
get_symbol_data("log_end", len, &tmp);
log_end = (ulong)tmp;
+ } else if (len == 0) {
+ THIS_KERNEL_VERSION >= LINUX(2,6,25) ?
+ get_symbol_data("log_end", sizeof(unsigned), &log_end) :
+ get_symbol_data("log_end", sizeof(unsigned long), &log_end);
} else
get_symbol_data("log_end", len, &log_end);
--
2.33.1