Home | History | Annotate | Download | only in procfs
History log of /src/sys/miscfs/procfs/procfs.h
RevisionDateAuthorComments
 1.87  01-Jul-2024  christos Add linux POSIX message queue support (Ricardo Branco)
 1.86  12-May-2024  christos branches: 1.86.2;
PR/58227: Ricardo Branco: Add support for proc/sysvipc in Linux emulator
 1.85  12-May-2024  christos PR/58240: Ricardo Branco: Add support for proc/self/limits as used by Linux
 1.84  17-Jan-2024  hannken Using the exechook to revoke procfs nodes is racy and may deadlock:

one thread runs doexechooks() -> procfs_revoke_vnodes() and wants to suspend
the file system for vgone(), while another thread runs a forced unmount,
has the file system suspended, tries to disestablish the exechook and
waits for doexechooks() to complete.

Establish/disestablish the exechook on module load/unload instead
mount/unmount and use the hashmap to access all procfs nodes for this pid.

May fix PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"
 1.83  17-Jan-2024  hannken Add a hashmap to access all procfs nodes by pid.
 1.82  19-Jan-2022  martin branches: 1.82.4;
Now that an inline function dereferences it, make sure struct proc
is declared by including sys/proc.h here.
 1.81  17-Jan-2022  bouyer If the calling process is running under linux emulation, make /proc/xxx/fd/
return only symlinks pointing to the original file in the filesystem,
instead of a hard link. This matches the linux behavior, and some
linux programs relies on it (they unconditionally call readlink() on
/proc/xxx/fd/yy and don't deal with it returning EINVAL).
Proposed on tech-kern@ in
http://mail-index.netbsd.org/tech-kern/2022/01/11/msg027877.html
 1.80  29-Apr-2020  riastradh Put forward declaration a little further forward to unbreak build.
 1.79  29-Apr-2020  thorpej If the procfs mount is marked as linux-compat, then allow proc lookup
by any LWP ID in the proc, not just the canonical PID.
 1.78  17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.77  26-Sep-2019  christos branches: 1.77.2;
Rewrite the procfs_fileno as an inline function to make it more clear what
it does...
 1.76  25-Apr-2019  mlelstv Restore mapping of file id to pid/type/fd.
Use 64bit file id to allow for 32bit fd and 25-26bit pid.
 1.75  30-Mar-2019  christos add a node for the process resource limits.
 1.74  31-Dec-2017  christos branches: 1.74.4;
rename some "cmdline" stuff now that it is used to print environment too
 1.73  31-Dec-2017  christos Add an environ node
 1.72  28-Aug-2017  kamil Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed
PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).

Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>
 1.71  30-Mar-2017  christos branches: 1.71.6;
add an auxv node.
 1.70  27-Jul-2014  hannken branches: 1.70.4; 1.70.8; 1.70.12;
Change procfs from hashlist to vcache.
- Key is (type, pid, fd)
- Remove argument "p" from procfs_allocvp(). It is only used
when "type == PFSfd". Lookup the proc with proc_find() when
procfs_loadvnode() needs it.
- Use a vfs_vnode_iterator for procfs_revoke_vnodes().
 1.69  05-Apr-2014  christos branches: 1.69.2;
On my 24 proc box I got ENOSPC, so make the routine return the size it wants
and try again.
 1.68  28-May-2012  christos branches: 1.68.2; 1.68.4;
add a task process subdirectory for emul linux
 1.67  27-Sep-2011  christos branches: 1.67.2; 1.67.6;
define PROCFS_MAXNAMLEN and use it.
 1.66  04-Sep-2011  jmcneill PR# kern/45021: Please support /emul/linux/proc/version

Add /proc/version for procfs with -o linux. The version reported depends
on the emulation type of the calling process:

$ cat /proc/version
NetBSD version 5.99.55 (netbsd@localhost) (gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)) NetBSD 5.99.55 (GENERIC) #39: Sun Sep 4 09:10:05 EDT 2011

$ /emul/linux/bin/cat /proc/version
Linux version 2.6.18 (linux@localhost) (gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)) #0 Wed Mar 3 03:03:03 PST 2010

$ /emul/linux32/bin/cat /proc/version
Linux version 2.6.18 (linux32@localhost) (gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)) #0 Wed Mar 3 03:03:03 PST 2010
 1.65  28-Jun-2008  rumble Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
 1.64  24-May-2007  agc branches: 1.64.28; 1.64.32; 1.64.34; 1.64.36;
Extend the Linux emulation of /proc to include

/proc/stat
/proc/loadavg and
/proc/<pid>/statm.

These are only present when -o linux is specified as a mount option
to procfs.

Factor out some common code so that it can be used by a number of
functions.

XXX The values returned in the statm emulation need to be verified.
 1.63  09-Feb-2007  ad branches: 1.63.6; 1.63.8;
Merge newlock2 to head.
 1.62  29-Oct-2006  christos add an "emul" file node.
 1.61  25-Oct-2006  christos 1. fix procfs_validfile{,_linux} to test for NULL pointers properly.
2. make "exe" entry be a symlink to the executable, instead of pointing
directly to the vnode of the executable.
3. factor out commonly used code.
 1.60  20-Sep-2006  manu Emulate Linux's /proc/devices
 1.59  11-Dec-2005  christos branches: 1.59.20; 1.59.22;
merge ktrace-lwp.
 1.58  01-Oct-2005  atatat Add "cwd" and "root" symlinks to each process's directory. The cwd
link points to the process's current working directory, and the root
link points to the process's root directory. What else would you
expect?

For directories that are out of reach (caller is in a chroot, target
process is in a different chroot, etc), the links point to "/"
instead.
 1.57  30-Aug-2005  xtraeme Remove __P()
 1.56  20-Sep-2004  jdolecek branches: 1.56.12;
add 'mounts' file for -o linux, which lists all currently mounted
filesystems; Linux glibc statvfs() uses this to get some of mount flags,
and this file is also useful as /emul/linux/etc/mtab (via symlink)
 1.55  27-Aug-2004  skrll Do previous slightly differently - just pass a struct lwp * and derive the
struct proc *.

OK'd by Jaromir.
 1.54  21-Aug-2004  jdolecek fix process used for /proc/<pid>/stat contents - it should be process
<pid>, not the current process looking at the information
 1.53  20-May-2004  atatat Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.52  10-Dec-2003  drochner branches: 1.52.2;
a little bit more namespace sanity
 1.51  03-Oct-2003  yamt terminate snprintb 'new' format strings correctly.
(fixes overrun in mount_*)
 1.50  27-Sep-2003  mycroft Put pfsnode in the #ifdef _KERNEL too, so this actually compiles.
 1.49  27-Sep-2003  darcy Changes as discussed with itojun on tech-kern. I have modified the enums
to have KFS or PFS differentiators. Further I have wrapped the enum in
procfs in "#ifdef _KERNEL" as it is done in kernfs.

To see the discussion go to http://mail-index.NetBSD.org/tech-kern/2003/09/
and look for "Mismatched enums in include files" in the list.
 1.48  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.47  29-Jun-2003  fvdl branches: 1.47.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.46  29-Jun-2003  thorpej Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.45  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.44  28-May-2003  christos Add /proc/<pid>/stat for linux compat. j2sdk1.4.2 depends on it.
 1.43  18-Apr-2003  jdolecek change PROCFS_FILENO() to use 5 bits for 'type', since there are more than
16 types nowadays (i.e. Pfd is 17)
 1.42  17-Apr-2003  jdolecek use fd_getfile() in procfs_getfp(), and FILE_USE()/FILE_UNUSE() the
returned file descriptor pointer appropriately
 1.41  25-Feb-2003  jrf This addresses PR kerm/19989. Thanks to hamajima@nagoya.ydc.co.jp for submitting this patch which enables /proc/uptime for linux emul. Patch reviewed by atatat@netbsd.org and tron@netbsd.org, approved by tron@netbsd.org.
 1.40  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.39  03-Jan-2003  christos Implement /proc/<pid>/fd/<n>. This is work in progress. Questionable things:
- Is it ok to convert DTYPE_PIPE to VFIFO and DTYPE_SOCKET to VSOCK?
- XXX: Avoid locking issue in ls -Rl /proc by avoiding curproc
- Does I/O to pipes work?
- XXX: Are there security implications?
 1.38  21-Sep-2002  christos MNT_GETARGS support
 1.37  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.36  05-Dec-2001  thorpej * Allow machine-dependent code to specify hooks for ptrace(2)
(__HAVE_PTRACE_MACHDEP) and procfs (__HAVE_PROCFS_MACHDEP).
These changes will allow platforms like x86 (XMM) and PowerPC
(AltiVec) to export extended register sets in a sane manner.

* Use __HAVE_PTRACE_MACHDEP to export x86 XMM registers (standard
FP + SSE/SSE2) using PT_{GET,SET}XMMREGS (in the machdep
ptrace request space).
* Use __HAVE_PROCFS_MACHDEP to export x86 XMM registers via
/proc/N/xmmregs in procfs.
 1.35  15-Sep-2001  chs add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl. file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value. the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.
 1.34  29-Mar-2001  fvdl branches: 1.34.2; 1.34.4;
For -o linux mounts, add some code to emulate /proc/#/maps.
Needs NAMECACHE_ENTER_REVERSE to include filenames.
 1.33  25-Jan-2001  jdolecek branches: 1.33.2;
g/c pmnt_mp in struct procfs_args
 1.32  18-Jan-2001  jdolecek constify
 1.31  17-Jan-2001  fvdl Add a few linux-style files, only enabled when -o linux is specified
for the mount. Currently these are /proc/cpuinfo and /proc/meminfo.
The former only does something on i386 right now.
 1.30  24-Nov-2000  chs remove dead code and other misc cleanup.
 1.29  16-Mar-2000  jdolecek branches: 1.29.4;
Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading. This fixes random panics
when LKM for filesystem using pools was loaded and unloaded several
times.

For each leaf filesystem, add appropriate vfs_done routine.
 1.28  25-Jan-2000  fvdl At mount/unmount time, add an exec hook to revoke all vnodes iff the
process is about to exec a sugid binary.

To speed up things, use hashing for vnode allocation, like other filesystems
do. This avoids walking the whole procfs node list in the revoke case too.
 1.27  02-Sep-1999  thorpej branches: 1.27.2;
Make /proc/self a symlink to /proc/curproc. I've observed Linux programs
that expect /proc/self/cmdline to exist.
 1.26  24-Mar-1999  mrg branches: 1.26.2;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.25  13-Mar-1999  thorpej Expose procfs_rwmem(). (This function will go away entirely when we
delete Mach VM.)
 1.24  12-Mar-1999  christos PR/7143: Jaromir Docelek: Add procfs/cmdline from Linux emulation
 1.23  25-Jan-1999  msaitoh Add /proc/#/map. From FreeBSD.
 1.22  09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.21  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.20  27-Aug-1997  thorpej Fix a reversed argument which caused procfs_checkioperm() to always return
"OK". Add a few comments to avoid further confusion.
 1.19  12-Aug-1997  thorpej Fix the procfs hole described on current-users, similar to a fix for
FreeBSD by Sean Eric Fagan, but a bit different. This makes the checks
in the same places as sef's FreeBSD patch, but does not hardcode the
"kmem" group into the kernel, and also does a check identical to the
(3) and (4) checks in the NetBSD ptrace(2):

(1) it's not owned by you, or is set-id on exec (unless
you're root), or

(2) it's init, which controls the security level of the
entire system, and the system was not compiled with
permanently insecure mode turned on.
 1.18  08-May-1997  mycroft branches: 1.18.4;
Pass the vnode type to vaccess(), and use it when checking VEXEC. Make sure
that the mode bits passed to vaccess() and returned by foo_getattr() contain
only permission bits.
 1.17  12-Feb-1996  christos close PR/2063: procfs_rw prototyped twice with different prototypes
 1.16  09-Feb-1996  christos miscfs prototype changes
 1.15  09-Feb-1996  mycroft Fix vop_link, vop_symlink, and vop_remove semantics in several ways:
* Change the argument names to vop_link so they actually make sense.
* Implement vop_link and vop_symlink for all file systems, so they do proper
cleanup.
* Require the file system to decide whether or not linking and unlinking of
directories is allowed, and disable it for all current file systems.
 1.14  09-Oct-1995  mycroft Add support for cookies, mostly from Greg Hudson.
 1.13  29-Mar-1995  briggs KERNEL -> _KERNEL
 1.12  29-Oct-1994  cgd light clean; make sure headers are properly included, types are OK, etc.
 1.11  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.10  15-Jun-1994  mycroft Minor update from JSP after merging my changes.
 1.9  08-Jun-1994  mycroft Update to 4.4-Lite fs code, with local changes.
 1.8  12-Apr-1994  cgd be a bit smarter about determining if files shouldn't be seen by the user.
Also, DON'T allow a lookup to succeed on a file that's not visible!
 1.7  06-Feb-1994  ws If you add files, be sure to have enough bits to encode an inode number!
 1.6  28-Jan-1994  cgd make a fpregs file.
 1.5  20-Jan-1994  ws Make procfs really work for debugging.
Implement not & notepg files in procfs.
 1.4  11-Jan-1994  ws Fix ugliness left over from my last mod
 1.3  09-Jan-1994  ws Bug fixes and enhancements:
Make NFS serving work (BUT DON'T USE "attach" TO /proc/*/ctl FOR NOW!!!)
Make `curproc' a symbolic link
Add `.' and `..' entries to the directories.
Return better guesses on the size of the files.
 1.2  05-Jan-1994  cgd fix UFS vs 'real' fs type mixups
 1.1  05-Jan-1994  cgd branches: 1.1.1;
add new procfs code, from Jan-Simon Pendry, jsp@sequent.com.
This is pretty-much "virgin", so that diffs can be done later.
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.1  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.18.4.2  28-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.18.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.26.2.1  01-Feb-2000  he Pull up revision 1.28 (via patch, requested by fvdl):
Close procfs security hole. Fixes SA#2000-001.
 1.27.2.5  21-Apr-2001  bouyer Sync with HEAD
 1.27.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.27.2.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.27.2.2  08-Dec-2000  bouyer Sync with HEAD.
 1.27.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.29.4.1  30-Mar-2001  he Pull up revision 1.31 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.33.2.10  07-Jan-2003  thorpej Sync with HEAD.
 1.33.2.9  15-Oct-2002  nathanw Make _validfoo() routines go back to taking a proc.
 1.33.2.8  06-Oct-2002  thorpej Sync with HEAD.
 1.33.2.7  20-Jun-2002  nathanw Catch up to -current.
 1.33.2.6  01-Apr-2002  nathanw procfs_domem() should take proc *, proc *; not proc *, lwp *.
 1.33.2.5  09-Jan-2002  nathanw Adapt procfs_machdep_rw() to LWPs.
 1.33.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.33.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.33.2.2  09-Apr-2001  nathanw Catch up with -current.
 1.33.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.34.4.1  01-Oct-2001  fvdl Catch up with -current.
 1.34.2.3  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.34.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.34.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.47.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.47.2.7  24-Sep-2004  skrll Sync with HEAD.
 1.47.2.6  21-Sep-2004  skrll Fix the sync with head I botched.
 1.47.2.5  18-Sep-2004  skrll Sync with HEAD.
 1.47.2.4  24-Aug-2004  skrll Undo part of the ktrace/lwp changes. In particular:
* Remove the "lwp *" argument that was added to vget(). Turns out
that nothing actually used it!
* Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(),
and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted
above, didn't use it).
* Remove all of the "lwp *" arguments to internal functions that were added
just to appease the above.
 1.47.2.3  18-Aug-2004  skrll Revert to passing struct proc for {exit,exec}hook.
 1.47.2.2  03-Aug-2004  skrll Sync with HEAD
 1.47.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.52.2.1  23-May-2004  tron Pull up revision 1.53 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.56.12.4  03-Sep-2007  yamt sync with head.
 1.56.12.3  26-Feb-2007  yamt sync with head.
 1.56.12.2  30-Dec-2006  yamt sync with head.
 1.56.12.1  21-Jun-2006  yamt sync with head.
 1.59.22.2  10-Dec-2006  yamt sync with head.
 1.59.22.1  22-Oct-2006  yamt sync with head
 1.59.20.2  18-Nov-2006  ad Sync with head.
 1.59.20.1  17-Nov-2006  ad Checkpoint work in progress.
 1.63.8.1  11-Jul-2007  mjf Sync with head.
 1.63.6.1  08-Jun-2007  ad Sync with head.
 1.64.36.1  03-Jul-2008  simonb Sync with head.
 1.64.34.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.64.32.1  04-May-2009  yamt sync with head.
 1.64.28.1  29-Jun-2008  mjf Sync with HEAD.
 1.67.6.1  02-Jun-2012  mrg sync to latest -current.
 1.67.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.67.2.1  30-Oct-2012  yamt sync with head
 1.68.4.1  18-May-2014  rmind sync with head
 1.68.2.2  03-Dec-2017  jdolecek update from HEAD
 1.68.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.2.1  10-Aug-2014  tls Rebase.
 1.70.12.1  21-Apr-2017  bouyer Sync with HEAD
 1.70.8.1  26-Apr-2017  pgoyette Sync with HEAD
 1.70.4.1  28-Aug-2017  skrll Sync with HEAD
 1.71.6.1  12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #713):

sys/modules/procfs/Makefile: revision 1.4
sys/miscfs/procfs/procfs_vfsops.c: revision 1.98
bin/ps/ps.1: revision 1.108
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.32
sys/miscfs/procfs/procfs_vnops.c: revision 1.198
sys/kern/sys_ptrace_common.c: revision 1.23
sys/kern/sys_ptrace_common.c: revision 1.24
sbin/mount_procfs/mount_procfs.8: revision 1.36
sys/kern/sys_ptrace_common.c: revision 1.25
sys/kern/sys_ptrace.c: revision 1.5
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.30
sys/sys/proc.h: revision 1.342
sys/kern/sys_ptrace_common.c: revision 1.26
sys/miscfs/procfs/procfs_ctl.c: file removal
sys/kern/sys_ptrace_common.c: revision 1.27
sys/miscfs/procfs/procfs_subr.c: revision 1.109
sys/kern/sys_ptrace_common.c: revision 1.28
sys/secmodel/extensions/secmodel_extensions.c: revision 1.8
sys/kern/sys_ptrace_common.c: revision 1.29
sys/sys/ptrace.h: revision 1.62
sys/compat/netbsd32/netbsd32_signal.c: revision 1.45
share/man/man9/kauth.9: revision 1.109
sys/miscfs/procfs/files.procfs: revision 1.12
sys/compat/netbsd32/netbsd32.h: revision 1.115
sys/miscfs/procfs/procfs.h: revision 1.72
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.5
sys/kern/kern_sig.c: revision 1.337
sys/sys/kauth.h: revision 1.75
sys/sys/sysctl.h: revision 1.224
sys/kern/sys_ptrace_common.c: revision 1.30
sys/kern/sys_ptrace_common.c: revision 1.31
sys/kern/sys_ptrace_common.c: revision 1.32
sys/kern/sys_ptrace_common.c: revision 1.33
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.20
sys/kern/sys_ptrace_common.c: revision 1.34
sys/kern/sys_ptrace_common.c: revision 1.36
sys/kern/kern_proc.c: revision 1.207
sys/kern/kern_exit.c: revision 1.269
doc/TODO.ptrace: revision 1.29

Make {s,g}et{db,fp,}regs work again for PK_32 processes
XXX: pullup-8

add disgusting magic to handle compat_netbsd32 as a module.

use process_*reg32 instead of struct *reg32.

Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed

PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).
Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>

untangle the mess:
- factor out common code
- break each ptrace subcall to its own sub-function
.. more to come ...
- reduce ifdef ugliness by moving it up top.
- factor out PT_IO and make PT_{READ,WRITE}_{I,D} use it
- factor out PT_DUMPCORE
- factor out sendsig code
.. more to come ...

handle siginfo requests for ptrace32

ptrace: Partially undo PT_{READ,WRITE}_{I,D} and unbreak these commands

The refactored code did not work and was generating EFAULT.

Sponsored by <The NetBSD Foundation>

Merge the code back; the problem was that since we are reading/writing
to a kernel address for PT_{READ,WRITE}_{I,D} we need the kernel vmspace.
provide separate read and write functions to accomodate register functions
that need a size argument.

don't ignore error from copyout_piod

Use the proper process (the tracee) to get information about lwps and
registers and the tracer for vmspace.

Add new sysctl(3) entry: security.models.extensions.user_set_dbregs

Model this new sysctl(3) entry after "user_set_cpu_affinity" in the same
level of sysctl(3) switches.

Allow to read unconditionally Debug Registers (no change here). This is
convenient as even if a user of a debugger does not use hardware assisted
watchpoints/breakpoints, a debugger can still prompt these values to store
in an internal cache with context of registers. Reading them should have
no security concerns.

Add a paranoid MI switch that prohibits by default setting these registers
by a regular user (non-superuser). Make this switch disabled by default.
There are enough reserved bits out there to allow using them
unconditionally on hardened hosts.

Features shipped with Debug Registers are optional features in debuggers.
There is no reduction in elementary functionality.

Reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.74.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.74.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.74.4.1  10-Jun-2019  christos Sync with HEAD
 1.77.2.1  17-Jan-2020  ad Sync with head.
 1.82.4.1  18-Apr-2024  martin Pull up following revision(s) (requested by hannken in ticket #668):

sys/miscfs/procfs/procfs.h: revision 1.83
sys/miscfs/procfs/procfs.h: revision 1.84
sys/kern/vfs_mount.c: revision 1.104
sys/miscfs/procfs/procfs_vnops.c: revision 1.230
sys/kern/init_main.c: revision 1.547
sys/kern/kern_hook.c: revision 1.15
sys/miscfs/procfs/procfs_vfsops.c: revision 1.112
sys/miscfs/procfs/procfs_vfsops.c: revision 1.113
sys/miscfs/procfs/procfs_vfsops.c: revision 1.114
sys/miscfs/procfs/procfs_subr.c: revision 1.117

Print dangling vnode before panic() to help debug.

PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"
Protect kernel hooks exechook, exithook and forkhook with rwlock.

Lock as writer on establish/disestablish and as reader on list traverse.

For exechook ride "exec_lock" as it is already take as reader when
traversing the list. Add local locks for exithook and forkhook.

Move exec_init before signal_init as signal_init calls exechook_establish()
that needs "exec_lock".

PR kern/39913 "exec, fork, exit hooks need locking"

Add a hashmap to access all procfs nodes by pid.

Using the exechook to revoke procfs nodes is racy and may deadlock:
one thread runs doexechooks() -> procfs_revoke_vnodes() and wants to suspend
the file system for vgone(), while another thread runs a forced unmount,
has the file system suspended, tries to disestablish the exechook and
waits for doexechooks() to complete.

Establish/disestablish the exechook on module load/unload instead
mount/unmount and use the hashmap to access all procfs nodes for this pid.

May fix PR kern/57775 ""panic: unmount: dangling vnode" while umounting procfs"

Remove all procfs nodes for this process on process exit.
 1.86.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed