[Crash-utility] [hacklet] handle kernel > 5.12 rename of task_struct.state

Mike Galbraith efault at gmx.de
Fri Jul 2 04:05:30 UTC 2021


Greetings fellow crash users.  The hacklet below keeps crash working
(for the nonce) into the 5.14 kernel cycle.  I doubt it's applicable (despite being kinda sorta disguised as a patch just in case;), but it should serve as a bandaid until the real deal comes along.

Handle kernel rename of task_struct.state to __state

Kernels post 5.13 renamed task->state to task->__state.  Check the
validity of 'state', and upon failure, rashly presume that "__state"
exists, and isn't going to change again any time soon.

Signed-off-by: Mike Galbraith <efault at gmx.de>
---
 task.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/task.c
+++ b/task.c
@@ -296,7 +296,10 @@ task_init(void)
 		tt->flags |= THREAD_INFO;
 	}

-        MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "state");
+	if (VALID_MEMBER(task_struct_state))
+        	MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "state");
+	else /* post linux 5.13 */
+        	MEMBER_OFFSET_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");





More information about the Crash-utility mailing list