svn commit: r359047 - in head: lib/libsysdecode sys/fs/procfs sys/sys

John Baldwin jhb at FreeBSD.org
Tue Mar 17 18:44:05 UTC 2020


Author: jhb
Date: Tue Mar 17 18:44:03 2020
New Revision: 359047
URL: https://svnweb.freebsd.org/changeset/base/359047

Log:
  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.
  
  Reviewed by:	emaste
  MFC after:	1 week
  Relnotes:	yes
  Differential Revision:	https://reviews.freebsd.org/D23822

Modified:
  head/lib/libsysdecode/Makefile
  head/sys/fs/procfs/procfs_ioctl.c
  head/sys/sys/pioctl.h

Modified: head/lib/libsysdecode/Makefile
==============================================================================
--- head/lib/libsysdecode/Makefile	Tue Mar 17 18:17:32 2020	(r359046)
+++ head/lib/libsysdecode/Makefile	Tue Mar 17 18:44:03 2020	(r359047)
@@ -121,6 +121,9 @@ CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
 
 CFLAGS.gcc+=	${CFLAGS.gcc.${.IMPSRC}}
 
+# Ignore deprecation warning in <sys/pioctl.h>
+CFLAGS.ioctl.c+= -Wno-\#warnings
+
 DEPENDOBJS+=	tables.h
 tables.h: mktables
 	sh ${.CURDIR}/mktables ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} ${.TARGET}

Modified: head/sys/fs/procfs/procfs_ioctl.c
==============================================================================
--- head/sys/fs/procfs/procfs_ioctl.c	Tue Mar 17 18:17:32 2020	(r359046)
+++ head/sys/fs/procfs/procfs_ioctl.c	Tue Mar 17 18:44:03 2020	(r359047)
@@ -69,10 +69,53 @@ 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) {

Modified: head/sys/sys/pioctl.h
==============================================================================
--- head/sys/sys/pioctl.h	Tue Mar 17 18:17:32 2020	(r359046)
+++ head/sys/sys/pioctl.h	Tue Mar 17 18:44:03 2020	(r359047)
@@ -41,6 +41,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 {


More information about the svn-src-head mailing list