Page MenuHomeFreeBSD

Use uintptr_t instead of register_t * for the stack base.
ClosedPublic

Authored by jhb on Nov 22 2019, 6:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 25 2023, 3:56 AM
Unknown Object (File)
Dec 20 2023, 6:12 AM
Unknown Object (File)
Dec 14 2023, 12:40 PM
Unknown Object (File)
Dec 11 2023, 12:56 PM
Unknown Object (File)
Sep 25 2023, 9:47 AM
Unknown Object (File)
Sep 21 2023, 6:21 PM
Unknown Object (File)
Aug 30 2023, 3:36 PM
Unknown Object (File)
Aug 30 2023, 3:30 PM

Details

Summary
  • Use ustringp for the location of the argv and environment strings and allow destp to travel further down the stack for the stackgap and auxv regions.
  • Update the Linux copyout_strings variants to move destp down the stack as was done for the native ABIs in r263349.
  • Stop allocating a space for a stack gap in the Linux ABIs. This used to hold translated system call arguments, but hasn't been used since r159992.

Tested on: amd64 (amd64, i386, linux64), i386 (i386, linux)

Test Plan
  • booted amd64 and i386
  • tested i386 binaries on amd64 (freebsd32)

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27718
Build 25917: arc lint + arc unit

Event Timeline

sys/amd64/cloudabi64/cloudabi64_sysvec.c
67

I would use sizeof(tcbptr) there.

sys/amd64/linux/linux_sysvec.c
346

This is really unsafe. May be introduce temp variable of uintptr_t type, or change vectp type to uintptr_t.

It seems that all of vectp/stringp/destp can be uintptr_t. They cannot be dereferenced since they contain userspace addresses.

sys/amd64/linux32/linux32_sysvec.c
110

Fix indent ?

sys/arm64/linux/linux_sysvec.c
259

Same.

sys/compat/freebsd32/freebsd32_misc.c
3203

Same,

sys/i386/linux/linux_sysvec.c
325

Same.

jhb marked an inline comment as done.Nov 22 2019, 7:43 PM
jhb added inline comments.
sys/amd64/linux/linux_sysvec.c
346

The main reason the code uses a pointer is to do pointer arithmetic e.g.

vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;

However, I can look at rewriting most of this to use a uintptr_t directly. I think we might already do that some in CheriBSD (and this series of reviews is driven by cleaning up some local changes we have in CheriBSD).

  • Use sizeof(tcbptr).
  • Use ustringp for the location of the argv and environment strings
  • Stop allocating a space for a stack gap in the Linux ABIs.
This revision is now accepted and ready to land.Nov 27 2019, 12:18 PM