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)
Sat, Nov 2, 4:52 AM
Unknown Object (File)
Oct 24 2024, 8:22 AM
Unknown Object (File)
Oct 7 2024, 9:40 PM
Unknown Object (File)
Oct 4 2024, 7:19 PM
Unknown Object (File)
Oct 4 2024, 6:21 PM
Unknown Object (File)
Oct 2 2024, 4:33 AM
Unknown Object (File)
Oct 1 2024, 11:42 PM
Unknown Object (File)
Oct 1 2024, 9:13 PM
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.