Today ptrace_message is easy to overlook as it not a core part of ptrace_stop. It has been overlooked so much that there are places that set ptrace_message and don't clear it, and places that never set it. So if you get an unlucky sequence of events the ptracer may be able to read a ptrace_message that does not apply to the current ptrace stop. Move setting of ptrace_message into ptrace_stop so that it always gets set before the stop, and always gets cleared after the stop. This prevents non-sense from being reported to userspace and makes ptrace_message more visible in the ptrace helper functions so that kernel developers can see it.
Showing the changes to include/uapi (1 of 3 files). Show all
Unified · Split
| @@ -114,7 +114,7 @@ struct ptrace_rseq_configuration { · 113 unmodified lines | |||
| 114 | 114 | ||
| 115 | /* | 115 | /* |
| 116 | * These values are stored in task->ptrace_message | 116 | * These values are stored in task->ptrace_message |
| 117 | * by ptrace_report_syscall_* to describe the current syscall-stop. | 117 | * by ptrace_stop to describe the current syscall-stop. |
| 118 | */ | 118 | */ |
| 119 | #define PTRACE_EVENTMSG_SYSCALL_ENTRY 1 | 119 | #define PTRACE_EVENTMSG_SYSCALL_ENTRY 1 |
| 120 | #define PTRACE_EVENTMSG_SYSCALL_EXIT 2 | 120 | #define PTRACE_EVENTMSG_SYSCALL_EXIT 2 |