Page MenuHomeFreeBSD

Handle padding in struct ptrace_xstate_info.
ClosedPublic

Authored by kib on Mar 22 2018, 2:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 28 2024, 6:19 AM
Unknown Object (File)
Dec 21 2023, 2:35 PM
Unknown Object (File)
Dec 20 2023, 2:15 AM
Unknown Object (File)
Dec 11 2023, 10:45 PM
Unknown Object (File)
Dec 7 2023, 1:04 AM
Unknown Object (File)
Oct 28 2023, 2:25 AM
Unknown Object (File)
May 23 2023, 6:51 AM
Unknown Object (File)
Dec 22 2022, 11:03 AM
Subscribers

Details

Summary

struct ptrace_xstate_info has 64bit member but ends up with 32bit one. As result, on amd64 there is a 32bit padding at the end, but not on i386.

We must clear the padding before doing the copyout. For compat32 case, we must copyout the structure which does not have the padding at the end.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/amd64/amd64/ptrace_machdep.c
92 ↗(On Diff #40596)

Since we have the thread pointer should this be SV_PROC_FLAG(td->td_proc, SV_ILP32)?

102 ↗(On Diff #40596)

It is more common to put the { after the #endif so you only need one #ifdef.

Since it's only used in one place, I'd personally put the info32 declaration in the if block so there are only two #ifdefs.

kib marked an inline comment as done.Mar 22 2018, 6:16 PM
kib added inline comments.
sys/amd64/amd64/ptrace_machdep.c
102 ↗(On Diff #40596)

Putting info32 declaration in the code contradicts style(9), and I follow this rule. I am aware of commonality of moving the '{' outside, unconditionally creating the useless block, but I do not like it. This is why I did the formatting that way: I consider #ifdefs less evil.

As the compromise, I moved '{' out of ifdef, but did not moved the var declaration.

Use td. Reduce number of #ifdefs.

This revision is now accepted and ready to land.Mar 22 2018, 7:14 PM

Revert use of td->td_proc for SV_ILP32 testing, use curproc. The td pointer passed to the function points to the thread ptrace(2) operates on, not the current thread. When we return the structure, we must follow the caller ABI, not the ABI of the debuggee.

This revision now requires review to proceed.Mar 22 2018, 8:14 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 22 2018, 8:44 PM
This revision was automatically updated to reflect the committed changes.