Fix for handling task_struct state member changes(kernels >= 5.14-rc1)

Release crash-7.3.0-5

Resolves: rhbz#1981715

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
This commit is contained in:
Lianbo Jiang 2021-07-22 10:52:20 +08:00
parent c53e8d98a2
commit 96dfbb4af8
2 changed files with 82 additions and 1 deletions

View File

@ -0,0 +1,76 @@
From 8f8314dcaad34983d1d7b8f828a9dad65ae4073d Mon Sep 17 00:00:00 2001
From: Alexander Egorenkov <egorenar@linux.ibm.com>
Date: Tue, 29 Jun 2021 08:39:00 +0200
Subject: [PATCH] Handle task_struct state member changes for kernels >=
5.14-rc1
Kernel commit 2f064a59a11ff9bc22e52e9678bc601404c7cb34 ("sched: Change
task_struct::state") renamed the member state of task_struct to __state
and its type changed from long to unsigned int. Without the patch,
crash fails to start up with the following error:
crash: invalid structure member offset: task_struct_state
FILE: task.c LINE: 5929 FUNCTION: task_state()
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
defs.h | 1 +
symbols.c | 1 +
task.c | 10 +++++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/defs.h b/defs.h
index 68d29bd28719..a3f6aa3a7ad5 100644
--- a/defs.h
+++ b/defs.h
@@ -2300,6 +2300,7 @@ struct size_table { /* stash of commonly-used sizes */
long printk_info;
long printk_ringbuffer;
long prb_desc;
+ long task_struct_state;
};
struct array_table {
diff --git a/symbols.c b/symbols.c
index 370d4c3e8ac0..af1741f44777 100644
--- a/symbols.c
+++ b/symbols.c
@@ -10672,6 +10672,7 @@ dump_offset_table(char *spec, ulong makestruct)
SIZE(page_cache_bucket));
fprintf(fp, " pt_regs: %ld\n", SIZE(pt_regs));
fprintf(fp, " task_struct: %ld\n", SIZE(task_struct));
+ fprintf(fp, " task_struct_state: %ld\n", SIZE(task_struct_state));
fprintf(fp, " task_struct_flags: %ld\n", SIZE(task_struct_flags));
fprintf(fp, " task_struct_policy: %ld\n", SIZE(task_struct_policy));
fprintf(fp, " thread_info: %ld\n", SIZE(thread_info));
diff --git a/task.c b/task.c
index 36cf259e5d7b..672b41697e75 100644
--- a/task.c
+++ b/task.c
@@ -297,6 +297,11 @@ task_init(void)
}
MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "state");
+ MEMBER_SIZE_INIT(task_struct_state, "task_struct", "state");
+ if (INVALID_MEMBER(task_struct_state)) {
+ MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "__state");
+ MEMBER_SIZE_INIT(task_struct_state, "task_struct", "__state");
+ }
MEMBER_OFFSET_INIT(task_struct_exit_state, "task_struct", "exit_state");
MEMBER_OFFSET_INIT(task_struct_pid, "task_struct", "pid");
MEMBER_OFFSET_INIT(task_struct_comm, "task_struct", "comm");
@@ -5926,7 +5931,10 @@ task_state(ulong task)
if (!tt->last_task_read)
return 0;
- state = ULONG(tt->task_struct + OFFSET(task_struct_state));
+ if (SIZE(task_struct_state) == sizeof(ulong))
+ state = ULONG(tt->task_struct + OFFSET(task_struct_state));
+ else
+ state = UINT(tt->task_struct + OFFSET(task_struct_state));
exit_state = VALID_MEMBER(task_struct_exit_state) ?
ULONG(tt->task_struct + OFFSET(task_struct_exit_state)) : 0;
--
2.30.2

View File

@ -4,7 +4,7 @@
Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles
Name: crash
Version: 7.3.0
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3
Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz
Source1: http://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz
@ -25,6 +25,7 @@ Patch4: 0001-arm64-rename-ARM64_PAGE_OFFSET_ACTUAL-to-ARM64_FLIP_.patch
Patch5: 0002-arm64-assign-page_offset-with-VA_BITS-kernel-configu.patch
Patch6: 0003-arm64-use-dedicated-bits-to-record-the-VA-space-layo.patch
Patch7: 0004-arm64-implement-switchable-PTOV-VTOP-for-kernels-5.1.patch
Patch8: 0001-Handle-task_struct-state-member-changes-for-kernels-.patch
%description
The core analysis suite is a self-contained tool that can be used to
@ -52,6 +53,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%build
# This package has an internal copy of GDB which has broken configure code for
@ -83,6 +85,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash
%{_includedir}/*
%changelog
* Thu Jul 22 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.0-5
- Fix for handling task_struct state member changes(kernels >= 5.14-rc1)
* Wed Jul 07 2021 Lianbo Jiang <lijiang@redhat.com> - 7.3.0-4
- Fix memory layout for aarch64