Page MenuHomeFreeBSD

Export argc, argv, envc, envv, and ps_strings in auxargs.
ClosedPublic

Authored by brooks on Apr 13 2020, 10:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 5 2024, 2:14 PM
Unknown Object (File)
Dec 27 2023, 3:07 PM
Unknown Object (File)
Dec 23 2023, 12:13 AM
Unknown Object (File)
Dec 13 2023, 1:17 AM
Unknown Object (File)
Dec 3 2023, 8:12 AM
Unknown Object (File)
Sep 23 2023, 1:43 PM
Unknown Object (File)
Sep 21 2023, 8:55 AM
Unknown Object (File)
Jul 11 2023, 4:07 PM
Subscribers

Details

Summary

Make ps_strings in struct image_params into a pointer.


Export argc, argv, envc, envv, and ps_strings in auxargs.

This simplifies discovery of these values, potentially with reducing the
number of syscalls we need to make at runtime. Longer term, we wish to
convert the startup process to pass an auxargs pointer to _start() and
use that rather than walking off the end of envv. This is cleaner,
more C-friendly, and for systems with strong bounds (e.g. CHERI)
necessary.


Add procstat support for new AT_ flags.

This includes argc, argv, envc, envv, and ps_strings.


Support AT_PS_STRINGS in _elf_aux_info().

This will be used by setproctitle().


Attempt to use AT_PS_STRINGS to get the ps_strings pointer.

This saves a system call and avoids one of the (relatively rare) cases
of the kernel exporting pointers via sysctl.

As a temporary measure, keep the sysctl support to allow limited
compatability with old kernels.

Fail gracefully if ps_strings can't be found (should never happen).

Diff Detail

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

Event Timeline

brooks retitled this revision from Make ps_strings in struct image_params into a pointer. to Export argc, argv, envc, envv, and ps_strings in auxargs..Apr 13 2020, 10:57 PM
brooks edited the summary of this revision. (Show Details)

Note that this will be committed in five commits (change ps_strings type, add and export new values, procstat support, _elf_aux_info, setproctitle).

My immediate motivation is to avoid further CheriBSD flag days as new AT_ values are added, but I do intend to pursue updating the _start() API at a later date which simplifies startup code in the long term.

Could you please extract two changes into separate commits:

  1. change of the impg ps_strings type
  2. addition of AUXARGS_ENTRY_PTR

Then the rest would be much cleaner.

sys/kern/imgact_elf.c
1352 ↗(On Diff #70526)

Should this line become AUXARGS_ENTRY_PTR ?
Same for all other pointer types ?

In D24407#536889, @kib wrote:

Could you please extract two changes into separate commits:

  1. change of the impg ps_strings type
  2. addition of AUXARGS_ENTRY_PTR

Then the rest would be much cleaner.

You can see my current commit breakdown at https://github.com/brooksdavis/freebsd/commits/D24407-new-AT_-flags

I think the one change you're suggesting is adding AUXARGS_ENTRY_PTR without users before the second commit.

sys/kern/imgact_elf.c
1352 ↗(On Diff #70526)

There's another pass to be done to make these be pointers in struct image_params and switch to AUXARGS_ENTRY_PTR. I'm happy to do that, but perhaps as a followup.

Successful amd64 CI build https://cirrus-ci.com/task/5249932466585600

I've also done make tinderbox.

In D24407#536889, @kib wrote:

Could you please extract two changes into separate commits:

  1. change of the impg ps_strings type
  2. addition of AUXARGS_ENTRY_PTR

Then the rest would be much cleaner.

You can see my current commit breakdown at https://github.com/brooksdavis/freebsd/commits/D24407-new-AT_-flags

This is almost what I want.

Anyway, I do not insist.

sys/kern/imgact_elf.c
1352 ↗(On Diff #70526)

No, I mean that all AT auxv that have pointer values, can be changed to AUXARGS_ENTRY_PTR without a change to the value type in imgp.

Changing the types in impg is orthogonal.

This revision is now accepted and ready to land.Apr 15 2020, 1:38 AM

How does this relate to D16111?

It doesn't except that D16111 caused all CheriBSD users a flag day due to this patch not being merged.