git: 1544f5add8c7 - main - Revert "kern_exec: Add kern.stacktop sysctl."

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 17 Jan 2022 21:13:04 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1544f5add8c72c28e939a1557e3e319c6cfe5008

commit 1544f5add8c72c28e939a1557e3e319c6cfe5008
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-01-17 16:41:58 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-01-17 16:41:58 +0000

    Revert "kern_exec: Add kern.stacktop sysctl."
    
    The current ASLR stack gap feature will be removed, and with that the
    need for the kern.stacktop sysctl is gone.  All consumers have been
    removed.
    
    This reverts commit a97d697122da2bfb0baae5f0939d118d119dae33.
    
    Reviewed by:    kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33704
---
 sys/kern/kern_exec.c | 31 +------------------------------
 sys/sys/sysctl.h     |  1 -
 2 files changed, 1 insertion(+), 31 deletions(-)

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 7e7fbe31976a..198f69ff4214 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -119,7 +119,6 @@ SYSCTL_INT(_kern, OID_AUTO, coredump_pack_vmmapinfo, CTLFLAG_RWTUN,
 
 static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS);
 static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS);
-static int sysctl_kern_stacktop(SYSCTL_HANDLER_ARGS);
 static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS);
 static int do_execve(struct thread *td, struct image_args *args,
     struct mac *mac_p, struct vmspace *oldvmspace);
@@ -134,10 +133,6 @@ SYSCTL_PROC(_kern, KERN_USRSTACK, usrstack, CTLTYPE_ULONG|CTLFLAG_RD|
     CTLFLAG_CAPRD|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_usrstack, "LU",
     "Top of process stack");
 
-SYSCTL_PROC(_kern, KERN_STACKTOP, stacktop, CTLTYPE_ULONG | CTLFLAG_RD |
-    CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_stacktop, "LU",
-    "Top of process stack with stack gap.");
-
 SYSCTL_PROC(_kern, OID_AUTO, stackprot, CTLTYPE_INT|CTLFLAG_RD|CTLFLAG_MPSAFE,
     NULL, 0, sysctl_kern_stackprot, "I",
     "Stack memory permissions");
@@ -196,31 +191,7 @@ sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS)
 #endif
 		error = SYSCTL_OUT(req, &p->p_sysent->sv_usrstack,
 		    sizeof(p->p_sysent->sv_usrstack));
-	return (error);
-}
-
-static int
-sysctl_kern_stacktop(SYSCTL_HANDLER_ARGS)
-{
-	vm_offset_t stacktop;
-	struct proc *p;
-	int error;
-
-	p = curproc;
-#ifdef SCTL_MASK32
-	if (req->flags & SCTL_MASK32) {
-		unsigned int val;
-
-		val = (unsigned int)(p->p_sysent->sv_usrstack -
-		    p->p_vmspace->vm_stkgap);
-		error = SYSCTL_OUT(req, &val, sizeof(val));
-	} else
-#endif
-	{
-		stacktop = p->p_sysent->sv_usrstack - p->p_vmspace->vm_stkgap;
-		error = SYSCTL_OUT(req, &stacktop, sizeof(stacktop));
-	}
-	return (error);
+	return error;
 }
 
 static int
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index b455fec7209f..71a34652ff44 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -976,7 +976,6 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
 #define	KERN_HOSTUUID		36	/* string: host UUID identifier */
 #define	KERN_ARND		37	/* int: from arc4rand() */
 #define	KERN_MAXPHYS		38	/* int: MAXPHYS value */
-#define	KERN_STACKTOP		39	/* int: USRSTACK - stack gap */
 /*
  * KERN_PROC subtypes
  */