Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Remove the filesystem tracing feature
details: https://anonhg.NetBSD.org/src/rev/fb6ca89527bb
branches: trunk
changeset: 826323:fb6ca89527bb
user: kamil <kamil%NetBSD.org@localhost>
date: Mon Aug 28 00:46:06 2017 +0000
description:
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>
diffstat:
bin/ps/ps.1 | 3 +-
doc/TODO.ptrace | 7 +-
sbin/mount_procfs/mount_procfs.8 | 53 +---
share/man/man9/kauth.9 | 3 +-
sys/compat/linux/arch/arm/linux_ptrace.c | 7 +-
sys/compat/linux/arch/i386/linux_ptrace.c | 13 +-
sys/compat/linux/arch/powerpc/linux_ptrace.c | 13 +-
sys/kern/kern_exit.c | 11 +-
sys/kern/kern_proc.c | 5 +-
sys/kern/kern_sig.c | 7 +-
sys/kern/sys_ptrace_common.c | 20 +-
sys/miscfs/procfs/files.procfs | 3 +-
sys/miscfs/procfs/procfs.h | 6 +-
sys/miscfs/procfs/procfs_ctl.c | 412 ---------------------------
sys/miscfs/procfs/procfs_subr.c | 8 +-
sys/miscfs/procfs/procfs_vfsops.c | 11 +-
sys/miscfs/procfs/procfs_vnops.c | 7 +-
sys/modules/procfs/Makefile | 4 +-
sys/sys/kauth.h | 3 +-
sys/sys/proc.h | 5 +-
sys/sys/sysctl.h | 3 +-
21 files changed, 46 insertions(+), 558 deletions(-)
diffs (truncated from 1049 to 300 lines):
diff -r ef479ddb849a -r fb6ca89527bb bin/ps/ps.1
--- a/bin/ps/ps.1 Sun Aug 27 23:20:54 2017 +0000
+++ b/bin/ps/ps.1 Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ps.1,v 1.107 2017/07/03 21:33:23 wiz Exp $
+.\" $NetBSD: ps.1,v 1.108 2017/08/28 00:46:06 kamil Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@@ -308,7 +308,6 @@
.It Dv "P_EXEC" Ta No "0x00004000 process called" Xr execve 2
.It Dv "P_OWEUPC" Ta No "0x00008000 owe process an addupc() call at next ast"
.\" the routine addupc is not documented in the man pages
-.It Dv "P_FSTRACE" Ta No "0x00010000 tracing via file system"
.It Dv "P_NOCLDWAIT" Ta No "0x00020000 no zombies when children die"
.It Dv "P_32" Ta No "0x00040000 32-bit process (used on 64-bit kernels)"
.It Dv "P_BIGLOCK" Ta No "0x00080000 process needs kernel ``big lock'' to run"
diff -r ef479ddb849a -r fb6ca89527bb doc/TODO.ptrace
--- a/doc/TODO.ptrace Sun Aug 27 23:20:54 2017 +0000
+++ b/doc/TODO.ptrace Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-$NetBSD: TODO.ptrace,v 1.28 2017/04/08 01:08:36 kamil Exp $
+$NetBSD: TODO.ptrace,v 1.29 2017/08/28 00:46:07 kamil Exp $
Items we (currently) plan to finish in the ptrace(2) field:
@@ -8,11 +8,6 @@
- reiterate over FreeBSD tests and add missing ones if applicable
- add PT_DUMPCORE tests in the ATF framework
- add ATF tests for PT_WRITE_I and PIOD_WRITE_I - test mprotect restrictions
- - add tests for the procfs interface covering all functions available on the
- same level as ptrace(2)
- - remove 4.4BSD tracing with /proc, restrict /proc to Linux compat, to be
- superseded with kevent tracing, the original purpose of /proc debugging is
- long gone (performance issues with PT_WRITE_* and PT_READ_*)
- research kevent support for tracing a process over a file descriptor,
this means alternative to wait(2)-based events with passing events over the
kqueue API - signal handlers are global per application and they clash with
diff -r ef479ddb849a -r fb6ca89527bb sbin/mount_procfs/mount_procfs.8
--- a/sbin/mount_procfs/mount_procfs.8 Sun Aug 27 23:20:54 2017 +0000
+++ b/sbin/mount_procfs/mount_procfs.8 Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_procfs.8,v 1.35 2017/07/03 21:33:41 wiz Exp $
+.\" $NetBSD: mount_procfs.8,v 1.36 2017/08/28 00:46:07 kamil Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -90,38 +90,6 @@
corresponding to the process' command line arguments.
For a system or zombie process, this file contains only a string
with the name of the process.
-.It Pa ctl
-a writeonly file which supports a variety of control operations.
-Control commands are written as strings to the
-.Pa ctl
-file.
-The control commands are:
-.Bl -tag -width detach -compact
-.It attach
-stops the target process and arranges for the sending
-process to become the debug control process.
-.It detach
-continue execution of the target process and
-remove it from control by the debug process.
-.It run
-continue running the target process until
-a signal is delivered, a breakpoint is hit, or the
-target process exits.
-.It step
-single step the target process, with no signal delivery.
-.It wait
-wait for the target process to stop.
-The target process must be stopped before
-any of the run, step, or signal commands are allowed.
-.El
-.Pp
-The string can also be the name of a signal, lower case
-and without the
-.Dv SIG
-prefix,
-in which case that signal is delivered to the process
-(see
-.Xr sigaction 2 ) .
.It Pa cwd
A symbolic link that points to the current working directory of the
process.
@@ -226,29 +194,10 @@
all comma separated.
.El
.El
-.Pp
-In a normal debugging environment,
-where the target is fork/exec'd by the debugger,
-the debugger should fork and the child should stop
-itself (with a self-inflicted
-.Dv SIGSTOP
-for example).
-The parent should issue a
-.Dv wait
-and then an
-.Dv attach
-command via the appropriate
-.Pa ctl
-file.
-The child process will receive a
-.Dv SIGTRAP
-immediately after the call to exec (see
-.Xr execve 2 ) .
.Sh FILES
.Bl -tag -width /proc/curproc -compact
.It Pa /proc/#
.It Pa /proc/#/cmdline
-.It Pa /proc/#/ctl
.It Pa /proc/#/cwd
.It Pa /proc/#/exe
.It Pa /proc/#/file
diff -r ef479ddb849a -r fb6ca89527bb share/man/man9/kauth.9
--- a/share/man/man9/kauth.9 Sun Aug 27 23:20:54 2017 +0000
+++ b/share/man/man9/kauth.9 Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: kauth.9,v 1.108 2017/07/03 21:28:48 wiz Exp $
+.\" $NetBSD: kauth.9,v 1.109 2017/08/28 00:46:07 kamil Exp $
.\"
.\" Copyright (c) 2005, 2006 Elad Efrat <elad%NetBSD.org@localhost>
.\" All rights reserved.
@@ -553,7 +553,6 @@
for the target element in the target process, and
.Ar arg2
is the access type, which can be either
-.Dv KAUTH_REQ_PROCESS_PROCFS_CTL ,
.Dv KAUTH_REQ_PROCESS_PROCFS_READ ,
.Dv KAUTH_REQ_PROCESS_PROCFS_RW ,
or
diff -r ef479ddb849a -r fb6ca89527bb sys/compat/linux/arch/arm/linux_ptrace.c
--- a/sys/compat/linux/arch/arm/linux_ptrace.c Sun Aug 27 23:20:54 2017 +0000
+++ b/sys/compat/linux/arch/arm/linux_ptrace.c Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.19 2015/10/13 08:24:35 pgoyette Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.20 2017/08/28 00:46:07 kamil Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.19 2015/10/13 08:24:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.20 2017/08/28 00:46:07 kamil Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -157,8 +157,7 @@
* 3. It is not being traced by _you_, or
* 4. It is not currently stopped.
*/
- if (ISSET(t->p_slflag, PSL_FSTRACE) || t->p_pptr != p ||
- t->p_stat != SSTOP || !t->p_waited) {
+ if (t->p_pptr != p || t->p_stat != SSTOP || !t->p_waited) {
mutex_exit(t->p_lock);
mutex_exit(proc_lock);
error = EBUSY;
diff -r ef479ddb849a -r fb6ca89527bb sys/compat/linux/arch/i386/linux_ptrace.c
--- a/sys/compat/linux/arch/i386/linux_ptrace.c Sun Aug 27 23:20:54 2017 +0000
+++ b/sys/compat/linux/arch/i386/linux_ptrace.c Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.31 2015/10/13 08:24:35 pgoyette Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.32 2017/08/28 00:46:07 kamil Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.31 2015/10/13 08:24:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.32 2017/08/28 00:46:07 kamil Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -197,13 +197,10 @@
goto out;
}
/*
- * 2. It is being traced by procfs (which has different signal
- * delivery semantics),
- * 3. It is not being traced by _you_, or
- * 4. It is not currently stopped.
+ * 2. It is not being traced by _you_, or
+ * 3. It is not currently stopped.
*/
- if (ISSET(t->p_slflag, PSL_FSTRACE) || t->p_pptr != p ||
- t->p_stat != SSTOP || !t->p_waited) {
+ if (t->p_pptr != p || t->p_stat != SSTOP || !t->p_waited) {
mutex_exit(t->p_lock);
mutex_exit(proc_lock);
error = EBUSY;
diff -r ef479ddb849a -r fb6ca89527bb sys/compat/linux/arch/powerpc/linux_ptrace.c
--- a/sys/compat/linux/arch/powerpc/linux_ptrace.c Sun Aug 27 23:20:54 2017 +0000
+++ b/sys/compat/linux/arch/powerpc/linux_ptrace.c Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ptrace.c,v 1.29 2015/10/13 08:24:35 pgoyette Exp $ */
+/* $NetBSD: linux_ptrace.c,v 1.30 2017/08/28 00:46:07 kamil Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.29 2015/10/13 08:24:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.30 2017/08/28 00:46:07 kamil Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -174,13 +174,10 @@
goto out;
}
/*
- * 2. It is being traced by procfs (which has different signal
- * delivery semantics),
- * 3. It is not being traced by _you_, or
- * 4. It is not currently stopped.
+ * 2. It is not being traced by _you_, or
+ * 3. It is not currently stopped.
*/
- if (ISSET(t->p_slflag, PSL_FSTRACE) || t->p_pptr != p ||
- t->p_stat != SSTOP || !t->p_waited) {
+ if (t->p_pptr != p || t->p_stat != SSTOP || !t->p_waited) {
mutex_exit(t->p_lock);
mutex_exit(proc_lock);
error = EBUSY;
diff -r ef479ddb849a -r fb6ca89527bb sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c Sun Aug 27 23:20:54 2017 +0000
+++ b/sys/kern/kern_exit.c Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exit.c,v 1.268 2017/01/09 00:31:30 kamil Exp $ */
+/* $NetBSD: kern_exit.c,v 1.269 2017/08/28 00:46:07 kamil Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.268 2017/01/09 00:31:30 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.269 2017/08/28 00:46:07 kamil Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@@ -469,7 +469,7 @@
if (__predict_false(child->p_slflag & PSL_TRACED)) {
mutex_enter(p->p_lock);
child->p_slflag &=
- ~(PSL_TRACED|PSL_FSTRACE|PSL_SYSCALL);
+ ~(PSL_TRACED|PSL_SYSCALL);
mutex_exit(p->p_lock);
if (child->p_opptr != child->p_pptr) {
struct proc *t = child->p_opptr;
@@ -526,8 +526,7 @@
/* Reload parent pointer, since p may have been reparented above */
new_parent = p->p_pptr;
- if (__predict_false((p->p_slflag & PSL_FSTRACE) == 0 &&
- p->p_exitsig != 0)) {
+ if (__predict_false(p->p_exitsig != 0)) {
exit_psignal(p, new_parent, &ksi);
kpsignal(new_parent, &ksi, NULL);
}
@@ -1159,7 +1158,7 @@
*/
if ((p->p_slflag & PSL_TRACED) != 0 && p->p_opptr != parent) {
mutex_enter(p->p_lock);
- p->p_slflag &= ~(PSL_TRACED|PSL_FSTRACE|PSL_SYSCALL);
+ p->p_slflag &= ~(PSL_TRACED|PSL_SYSCALL);
mutex_exit(p->p_lock);
parent = (p->p_opptr == NULL) ? initproc : p->p_opptr;
proc_reparent(p, parent);
diff -r ef479ddb849a -r fb6ca89527bb sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Sun Aug 27 23:20:54 2017 +0000
+++ b/sys/kern/kern_proc.c Mon Aug 28 00:46:06 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.206 2017/03/30 20:17:11 christos Exp $ */
+/* $NetBSD: kern_proc.c,v 1.207 2017/08/28 00:46:07 kamil Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.206 2017/03/30 20:17:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.207 2017/08/28 00:46:07 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -1560,7 +1560,6 @@
static const u_int sysctl_slflagmap[] = {
PSL_TRACED, P_TRACED,
- PSL_FSTRACE, P_FSTRACE,
Home |
Main Index |
Thread Index |
Old Index