Page MenuHomeFreeBSD

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

Authored by jhb on Nov 22 2019, 6:07 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 OK
Unit
No Unit Test Coverage
Build Status
Buildable 27791
Build 25976: arc lint + arc unit

Event Timeline

sys/amd64/cloudabi64/cloudabi64_sysvec.c
67–68

I would use sizeof(tcbptr) there.

sys/amd64/linux/linux_sysvec.c
347

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
260

Same.

sys/compat/freebsd32/freebsd32_misc.c
3206

Same,

sys/i386/linux/linux_sysvec.c
326

Same.

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

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