Home | History | Annotate | Download | only in procfs
History log of /src/sys/miscfs/procfs/procfs_cmdline.c
RevisionDateAuthorComments
 1.33  18-May-2024  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.32  27-Sep-2019  christos Instead of casting to size_t, cast to uintmax_t to prevent truncation
(pointed out by chuq). In all these cases uio_offset can't be negative.
 1.31  26-Sep-2019  christos fix sign-compare issues: uio->uio_offset (off_t) is compared with (size_t):
cast the offset to size_t.
 1.30  31-Dec-2017  christos branches: 1.30.4;
rename some "cmdline" stuff now that it is used to print environment too
 1.29  31-Dec-2017  christos Add an environ node
 1.28  04-Mar-2011  joerg Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.27  28-Apr-2008  martin branches: 1.27.22; 1.27.28; 1.27.30;
Remove clause 3 and 4 from TNF licenses
 1.26  17-Feb-2007  pavel branches: 1.26.38; 1.26.40; 1.26.42;
Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
 1.25  09-Feb-2007  ad branches: 1.25.2;
Merge newlock2 to head.
 1.24  28-Dec-2006  elad PR/32877: Geoff C. Wing: mount_procfs(8) doesn't null-terminate cmdline
output

Patch applied, thanks!
 1.23  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.22  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21  01-Mar-2006  yamt branches: 1.21.14; 1.21.16;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.20  11-Dec-2005  christos branches: 1.20.2; 1.20.4; 1.20.6;
merge ktrace-lwp.
 1.19  26-Feb-2005  perry branches: 1.19.4;
nuke trailing whitespace
 1.18  22-Apr-2004  itojun branches: 1.18.4; 1.18.6;
sprintf -> snprintf
 1.17  29-Jun-2003  fvdl branches: 1.17.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.16  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.15  07-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.14  09-May-2002  thorpej Move code shared by procfs and the kernel proper out of procfs and
into the kernel proper (renaming functions from procfs_* to process_*).
 1.13  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.12  10-Nov-2001  lukem add RCSIDs
 1.11  28-Sep-2000  eeh branches: 1.11.2; 1.11.4; 1.11.8;
Add support for variable end of user stacks needed to support COMPAT_NETBSD32:

`struct vmspace' has a new field `vm_minsaddr' which is the user TOS.

PS_STRINGS is deprecated in favor of curproc->p_pstr which is derived
from `vm_minsaddr'.

Bump the kernel version number.
 1.10  26-Sep-2000  thorpej PHOLD/PRELE around uvm_io() to user address space is unnecessary. There
is nothing in the U-area that we need.
 1.9  28-Jun-2000  mrg <vm/vm.h> -> <uvm/uvm_extern.h>
 1.8  01-Jun-2000  simonb branches: 1.8.2;
Fix a possible kernel memory leak - if the cmdline of a process was
requested after it had started to exit but before it became a zombie
a page of kernel memory wouldn't be free'd.
 1.7  16-May-2000  simonb branches: 1.7.2;
Apply patch from Robert Elz in PR kern/10113. This fixes two problems
with procfs's cmdline - from the PR:

The cmdline implementation in procfs is bogus. It's possible that
part of the fix is a workaround of a UVM problem - that is, when
(internally) accessing the top of the process VM (the end of the
args) a request for I/0 of a PAGE_SIZE'd block starting at less
than a PAGE_SIZE from the end of the mem space returns EINVAL
rather than the data that is available. Whether this is a bug
in UVM or not depends upon how it is defined to work, and I was
unable to determine that. (Simon Burge found that problem, and
provided the basis of the workaround/fix).

Then, the cmdline function is unable to read more than one
page of args, and a good thing too, as the way it is written
attempting to get more than that would reference into lala land.

And, on an attempt to read a lot of data when the above is
fixed, most of the data won't be returned, only the final block
of any read.

Tested on alpha, pmax, i386 and sparc.
 1.6  22-Jul-1999  thorpej branches: 1.6.2;
Rework the process exit path, in preparation for making process exit
and PID allocation MP-safe. A new process state is added: SDEAD. This
state indicates that a process is dead, but not yet a zombie (has not
yet been processed by the process reaper).

SDEAD processes exist on both the zombproc list (via p_list) and deadproc
(via p_hash; the proc has been removed from the pidhash earlier in the exit
path). When the reaper deals with a process, it changes the state to
SZOMB, so that wait4 can process it.

Add a P_ZOMBIE() macro, which treats a proc in SZOMB or SDEAD as a zombie,
and update various parts of the kernel to reflect the new state.
 1.5  27-Apr-1999  thorpej Fix excessive memory usage, and fix handling of SZOMB processes. PR #7164,
Jaromir Dolecek.
 1.4  24-Mar-1999  mrg branches: 1.4.2;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.3  13-Mar-1999  thorpej malloc the arg temporary buffer, rather than declaring it as an automatic
array of ARG_MAX size. ARG_MAX is currently 256k, which causes a rather
serious stack overflow (kernel stacks are not very large, usually 8k).

Fixes memory corruption problems observed after accessig /proc/1/cmdline
during tests. Problem in my case manifested itself as massive lossage
in ffs_sync(), resulting in a crash, and sometimes, pooched file systems.

XXX This could, and probably should, be rewritten to use a much smaller
temporary buffer, and a loop around uiomove().
 1.2  13-Mar-1999  thorpej Some changes to `cmdline' to make it work properly:
- Don't error out on P_SYSTEM or SZOMB processes; instead, do what ps(1)
would do, i.e. the p_comm in parenthesis.
- Use uvm_io() (or procfs_rwmem() if !UVM) to read the target process's
psstrings and argument vector. Using copyin() is problematic, because
it operates on the current processes! That is, the old code would
always get the `cmdline' of the process reading the file, not that of
the target process.
 1.1  12-Mar-1999  christos PR/7143: Jaromir Docelek: Add procfs/cmdline from Linux emulation
 1.4.2.2  01-Jun-2000  he Pull up revision 1.8 (requested by simonb):
Fix a possible kernel memory leak - if the command line of a
process was requested after it had started to exit but before it
became a zombie a page of kernel memory would not be freed.
 1.4.2.1  27-Apr-1999  perry branches: 1.4.2.1.2;
pullup 1.4->1.5 (thorpej)
 1.4.2.1.2.2  02-Aug-1999  thorpej Update from trunk.
 1.4.2.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.6.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.7.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.1  18-Oct-2000  tv Pullup by patch [eeh]:
Support userspace at multiple addresses by making PSSTRINGS variable (using
p_psstr), and fix stackgap_init() appropriately.
 1.11.8.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.11.4.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.4  11-Nov-2002  nathanw Catch up to -current
 1.11.2.3  20-Jun-2002  nathanw Catch up to -current.
 1.11.2.2  08-Jan-2002  nathanw Catch up to -current.
 1.11.2.1  14-Nov-2001  nathanw Catch up to -current.
 1.17.2.5  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.17.2.2  03-Aug-2004  skrll Sync with HEAD
 1.17.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.18.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.4.1  29-Apr-2005  kent sync with -current
 1.19.4.3  26-Feb-2007  yamt sync with head.
 1.19.4.2  30-Dec-2006  yamt sync with head.
 1.19.4.1  21-Jun-2006  yamt sync with head.
 1.20.6.1  22-Apr-2006  simonb Sync with head.
 1.20.4.1  09-Sep-2006  rpaulo sync with head
 1.20.2.1  15-Jan-2006  yamt convert procfs.
 1.21.16.2  10-Dec-2006  yamt sync with head.
 1.21.16.1  22-Oct-2006  yamt sync with head
 1.21.14.3  12-Jan-2007  ad Sync with head.
 1.21.14.2  18-Nov-2006  ad Sync with head.
 1.21.14.1  17-Nov-2006  ad Checkpoint work in progress.
 1.25.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.26.42.1  16-May-2008  yamt sync with head.
 1.26.40.1  18-May-2008  yamt sync with head.
 1.26.38.1  02-Jun-2008  mjf Sync with HEAD.
 1.27.30.1  05-Mar-2011  bouyer Sync with HEAD
 1.27.28.1  06-Jun-2011  jruoho Sync with HEAD.
 1.27.22.1  05-Mar-2011  rmind sync with head
 1.30.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed