# Re: \[PATCH v4 5/8\] powerpc: add exit\_flags field in pt\_regs

- From: Madhavan Srinivasan \<maddy@linux.ibm.com\>
- Date: 2026-07-23 02:38:49 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2026/07/17307281
- Thread: https://ratatoskr.run/linuxppc-dev/2026/01/3383734/t.md

```text

On 7/22/26 12:31 PM, Dmitry V. Levin wrote:
> On Fri, Jan 23, 2026 at 01:09:13PM +0530, Mukesh Kumar Chaurasiya wrote:
>> From: Mukesh Kumar Chaurasiya <redacted>
>>
>> Add a new field `exit_flags` in the pt_regs structure. This field will hold
>> the flags set during interrupt or syscall execution that are required during
>> exit to user mode.
> Apparently, this change breaks PTRACE_GETREGS as the latter has no means
> to communicate the size of struct pt_regs being written to userspace.
We added the exit_flag at the end of the struct so that other element
offsets will not be affected with this change.
> As result, the kernel with this patch will write to userpsace 32 more
> bytes than before, and unless the userspace is re-compiled with the latest
> ptrace.h, 32 bytes of userspace memory after struct pt_regs will be
> overwritten.
We are looking at other options and thanks for reporting this
Maddy
>
> This issue was detected by strace test suite, specifically, the test that
> checks whether the actual number of bytes written by
> ptrace(PTRACE_GETREGS) matches sizeof(struct pt_regs), and that test failed
> with runtime version v7.1 and headers version v7.2-rc1.
>
>> diff --git a/arch/powerpc/include/uapi/asm/ptrace.h b/arch/powerpc/include/uapi/asm/ptrace.h
>> index 01e630149d48..a393b7f2760a 100644
>> --- a/arch/powerpc/include/uapi/asm/ptrace.h
>> +++ b/arch/powerpc/include/uapi/asm/ptrace.h
>> @@ -55,6 +55,8 @@ struct pt_regs
>>   	unsigned long dar;		/* Fault registers */
>>   	unsigned long dsisr;		/* on 4xx/Book-E used for ESR */
>>   	unsigned long result;		/* Result of a system call */
>> +	unsigned long exit_flags;	/* System call exit flags */
>> +	unsigned long __pt_regs_pad[3];	/* Maintain 16 byte interrupt stack alignment */
>>   };
>>   
>>   #endif /* __ASSEMBLER__ */

```
