Page MenuHomeFreeBSD

Fix sysctl kern.proc.args on self if args are long after r325726
AbandonedPublic

Authored by jilles on Jan 1 2018, 10:43 PM.
Tags
None
Referenced Files
F166343068: D13729.diff
Thu, Aug 13, 12:45 AM
Unknown Object (File)
Wed, Aug 12, 5:08 AM
Unknown Object (File)
Tue, Aug 11, 8:28 AM
Unknown Object (File)
Sat, Aug 8, 8:37 PM
Unknown Object (File)
Sat, Aug 8, 11:43 AM
Unknown Object (File)
Fri, Aug 7, 9:20 PM
Unknown Object (File)
Thu, Aug 6, 8:05 PM
Unknown Object (File)
Jun 16 2026, 8:58 PM
Subscribers

Details

Reviewers
mjg
Summary

Since r325726, sysctl kern.proc.args on the current process no longer
works if the arguments are longer than the value of the sysctl
kern.ps_arg_cache_limit.

It looks like the new fast path only works properly if p->p_args is not
NULL. If p->p_args is NULL, this usually means that the arguments are
longer than ps_arg_cache_limit and must be retrieved from (pageable)
process memory and not wired p->p_args->ar_args. It is possible to
duplicate that piece of code as well but that is probably not worth it.
Therefore, skip the fast path if p->p_args is NULL.

This breaks building x11-toolkits/gnustep-gui with log
http://pb2.nyi.freebsd.org/data/111i386-default-PR224618/2017-12-28_12h28m51s/logs/errors/gnustep-gui-0.25.1_3.log

Test Plan

Build and install the kernel, and run

sh -c 'n=$(sysctl -n kern.ps_arg_cache_limit);
exec ps -p "$$" -o "args=$(printf "%0${n}d" 0)"'

The last line of the output should be something like

ps -p 86963 -o args=0000000000000000000000000000000000000000000000000000000000

and not

[ps]

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14046
Build 14233: arc lint + arc unit