aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-05-14 17:47:55 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-05-14 17:47:55 +0000
commit7be8492d5e12242d9a43ec0bbee40fb60fb762df (patch)
treee021dabdc92f4f4f7ddf4498b1d416521fe50177
parent60adae9f9ee274076c940e55e61744591c37cf7d (diff)
downloadsrc-7be8492d5e12242d9a43ec0bbee40fb60fb762df.tar.gz
src-7be8492d5e12242d9a43ec0bbee40fb60fb762df.zip
MF11 361020: Deprecate procfs-based process debugging.
359047: Mark procfs-based process debugging as deprecated for FreeBSD 13. Attempting to use ioctls on /proc/<pid>/mem to control a process will trigger warnings on the console. The <sys/pioctl.h> include file will also now emit a compile-time warning when used from userland. 359054: Fix the workaround to ignore the #warning for GCC. clang and gcc use different warning flags for #warning preprocessor directives. For both 12 and 11, adjust the GCC warning flags to only be added in 4.7 and later since 4.2.1 does not support -Wno-cpp. For 11, add the needed warning suppression to procctl's build. procctl was removed in 12.0. Approved by: re (gjb, kib)
Notes
Notes: svn path=/releng/11.4/; revision=361035
-rw-r--r--lib/libsysdecode/Makefile7
-rw-r--r--sys/fs/procfs/procfs_ioctl.c43
-rw-r--r--sys/sys/pioctl.h4
-rw-r--r--usr.sbin/procctl/Makefile8
4 files changed, 62 insertions, 0 deletions
diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index 9b82a08d7587..9420dd875811 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -123,6 +123,13 @@ CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
# Workaround warning for unused ssi_cables[] in <dev/lmc/if_lmc.h>
CFLAGS.gcc.ioctl.c+= -Wno-unused
+# Ignore deprecation warning in <sys/pioctl.h>
+CFLAGS.clang.ioctl.c+= -Wno-\#warnings
+.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40700
+CFLAGS.gcc.ioctl.c+= -Wno-cpp
+.endif
+
+CFLAGS.clang+= ${CFLAGS.clang.${.IMPSRC}}
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
DEPENDOBJS+= tables.h
diff --git a/sys/fs/procfs/procfs_ioctl.c b/sys/fs/procfs/procfs_ioctl.c
index 0f37f07c3e35..dc5720249300 100644
--- a/sys/fs/procfs/procfs_ioctl.c
+++ b/sys/fs/procfs/procfs_ioctl.c
@@ -69,11 +69,54 @@ procfs_ioctl(PFS_IOCTL_ARGS)
#ifdef COMPAT_FREEBSD6
int ival;
#endif
+ static struct timeval lasttime;
+ static struct timeval interval = { .tv_sec = 1, .tv_usec = 0 };
KASSERT(p != NULL,
("%s() called without a process", __func__));
PROC_LOCK_ASSERT(p, MA_OWNED);
+ switch (cmd) {
+#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
+ case _IOC(IOC_IN, 'p', 1, 0):
+#endif
+#ifdef COMPAT_FREEBSD6
+ case _IO('p', 1):
+#endif
+ case PIOCBIS:
+#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
+ case _IOC(IOC_IN, 'p', 2, 0):
+#endif
+#ifdef COMPAT_FREEBSD6
+ case _IO('p', 2):
+#endif
+ case PIOCBIC:
+#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
+ case _IOC(IOC_IN, 'p', 3, 0):
+#endif
+#ifdef COMPAT_FREEBSD6
+ case _IO('p', 3):
+#endif
+ case PIOCSFL:
+ case PIOCGFL:
+ case PIOCWAIT:
+ case PIOCSTATUS:
+#ifdef COMPAT_FREEBSD32
+ case PIOCWAIT32:
+ case PIOCSTATUS32:
+#endif
+#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
+ case _IOC(IOC_IN, 'p', 5, 0):
+#endif
+#ifdef COMPAT_FREEBSD6
+ case _IO('p', 5):
+#endif
+ case PIOCCONT:
+ if (ratecheck(&lasttime, &interval) != 0)
+ gone_in(13, "procfs-based process debugging");
+ break;
+ }
+
error = 0;
switch (cmd) {
#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
diff --git a/sys/sys/pioctl.h b/sys/sys/pioctl.h
index 93bdbeccd2f8..2af9c402df44 100644
--- a/sys/sys/pioctl.h
+++ b/sys/sys/pioctl.h
@@ -39,6 +39,10 @@
#ifndef _SYS_PIOCTL_H
# define _SYS_PIOCTL_H
+#ifndef _KERNEL
+#warning "<sys/pioctl.h> is deprecated, ptrace() should be used instead"
+#endif
+
# include <sys/ioccom.h>
struct procfs_status {
diff --git a/usr.sbin/procctl/Makefile b/usr.sbin/procctl/Makefile
index 880b93a13fe0..e4d0f1116c65 100644
--- a/usr.sbin/procctl/Makefile
+++ b/usr.sbin/procctl/Makefile
@@ -1,6 +1,14 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= procctl
MAN= procctl.8
+# Ignore deprecation warning in <sys/pioctl.h>
+CFLAGS.clang+= -Wno-\#warnings
+.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40700
+CFLAGS.gcc+= -Wno-cpp
+.endif
+
.include <bsd.prog.mk>