Fix: task_struct backwards-compatibility with kernel versions < 5.14 (2)#55
Merged
tanelpoder merged 1 commit intotanelpoder:masterfrom Dec 14, 2024
Merged
Conversation
The state field in task_struct has been renamed to __state in kernel version 5.14. Due to this change, xcapture-bpf.c fails with the following error on kernel versions < 5.14: /virtual/main.c:178:29: error: no member named '__state' in 'struct task_struct'; did you mean 'state'? The state field rename has been backported to the RHEL8 4.18 kernels as well, but the fix in tanelpoder#53 / 55f1e30 did not consider this. Therefore, this fix now also includes a macro that checks for RHEL8 like so: #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) || RHEL_MAJOR >= 8 #define STATE_FIELD __state #else #define STATE_FIELD state #endif ... t->state = curtask->STATE_FIELD;
Owner
|
Cool, thanks for the change and for using the version check macro too (I noticed that the previous approach errored out on 6.8.0, I think my own original code had that issue too) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The state field in task_struct has been renamed to __state in kernel version 5.14.
Due to this change, xcapture-bpf.c fails with the following error on kernel versions < 5.14: /virtual/main.c:178:29: error: no member named '__state' in 'struct task_struct'; did you mean 'state'?
The state field rename has been backported to the RHEL8 4.18 kernels as well, but the fix in #53 / 55f1e30 did not consider this. Therefore, this fix now also includes a macro that checks for RHEL8 like so:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) || RHEL_MAJOR >= 8
#define STATE_FIELD __state
#else
#define STATE_FIELD state
#endif
...
t->state = curtask->STATE_FIELD;