Page MenuHomeFreeBSD

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

Authored by jhb on Fri, Nov 22, 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

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb created this revision.Fri, Nov 22, 6:07 PM
kib added inline comments.Fri, Nov 22, 7:17 PM
sys/amd64/cloudabi64/cloudabi64_sysvec.c
67 ↗(On Diff #64734)

I would use sizeof(tcbptr) there.

sys/amd64/linux/linux_sysvec.c
346 ↗(On Diff #64734)

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 ↗(On Diff #64734)

Fix indent ?

sys/arm64/linux/linux_sysvec.c
259 ↗(On Diff #64734)

Same.

sys/compat/freebsd32/freebsd32_misc.c
3203 ↗(On Diff #64734)

Same,

sys/i386/linux/linux_sysvec.c
325 ↗(On Diff #64734)

Same.

jhb marked an inline comment as done.Fri, Nov 22, 7:43 PM
jhb added inline comments.
sys/amd64/linux/linux_sysvec.c
346 ↗(On Diff #64734)

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).

jhb updated this revision to Diff 64924.Wed, Nov 27, 1:44 AM
  • 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.
jhb edited the summary of this revision. (Show Details)Wed, Nov 27, 1:47 AM
kib accepted this revision.Wed, Nov 27, 12:18 PM
This revision is now accepted and ready to land.Wed, Nov 27, 12:18 PM
This revision was automatically updated to reflect the committed changes.