Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Aug 2020 20:44:15 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364535 - head/usr.bin/proccontrol
Message-ID:  <202008232044.07NKiF4h034829@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Aug 23 20:44:15 2020
New Revision: 364535
URL: https://svnweb.freebsd.org/changeset/base/364535

Log:
  procctl(8): usermode bits to force LA58/LA57 on exec.
  
  Sponsored by:	The FreeBSD Foundation
  Differential revision:	https://reviews.freebsd.org/D25273

Modified:
  head/usr.bin/proccontrol/proccontrol.1
  head/usr.bin/proccontrol/proccontrol.c

Modified: head/usr.bin/proccontrol/proccontrol.1
==============================================================================
--- head/usr.bin/proccontrol/proccontrol.1	Sun Aug 23 20:43:23 2020	(r364534)
+++ head/usr.bin/proccontrol/proccontrol.1	Sun Aug 23 20:44:15 2020	(r364535)
@@ -71,6 +71,9 @@ Controls the implicit PROT_MAX application for
 .Xr mmap 2 .
 .It Ar kpti
 Controls the KPTI enable, AMD64 only.
+.It Ar la48
+Control limiting usermode process address space to 48 bits of address,
+AMD64 only, on machines capable of 57-bit addressing.
 .El
 .Pp
 The

Modified: head/usr.bin/proccontrol/proccontrol.c
==============================================================================
--- head/usr.bin/proccontrol/proccontrol.c	Sun Aug 23 20:43:23 2020	(r364534)
+++ head/usr.bin/proccontrol/proccontrol.c	Sun Aug 23 20:44:15 2020	(r364535)
@@ -48,6 +48,10 @@ enum {
 #ifdef PROC_KPTI_CTL
 	MODE_KPTI,
 #endif
+#ifdef PROC_LA_CTL
+	MODE_LA57,
+	MODE_LA48,
+#endif
 };
 
 static pid_t
@@ -69,13 +73,18 @@ str2pid(const char *str)
 #else
 #define	KPTI_USAGE
 #endif
+#ifdef PROC_LA_CTL
+#define	LA_USAGE "|la48|la57"
+#else
+#define	LA_USAGE
+#endif
 
 static void __dead2
 usage(void)
 {
 
 	fprintf(stderr, "Usage: proccontrol -m (aslr|protmax|trace|trapcap|"
-	    "stackgap"KPTI_USAGE") [-q] "
+	    "stackgap"KPTI_USAGE LA_USAGE") [-q] "
 	    "[-s (enable|disable)] [-p pid | command]\n");
 	exit(1);
 }
@@ -108,6 +117,12 @@ main(int argc, char *argv[])
 			else if (strcmp(optarg, "kpti") == 0)
 				mode = MODE_KPTI;
 #endif
+#ifdef PROC_LA_CTL
+			else if (strcmp(optarg, "la57") == 0)
+				mode = MODE_LA57;
+			else if (strcmp(optarg, "la48") == 0)
+				mode = MODE_LA48;
+#endif
 			else
 				usage();
 			break;
@@ -164,6 +179,12 @@ main(int argc, char *argv[])
 			error = procctl(P_PID, pid, PROC_KPTI_STATUS, &arg);
 			break;
 #endif
+#ifdef PROC_LA_CTL
+		case MODE_LA57:
+		case MODE_LA48:
+			error = procctl(P_PID, pid, PROC_LA_STATUS, &arg);
+			break;
+#endif
 		default:
 			usage();
 			break;
@@ -259,6 +280,27 @@ main(int argc, char *argv[])
 				printf(", not active\n");
 			break;
 #endif
+#ifdef PROC_LA_CTL
+		case MODE_LA57:
+		case MODE_LA48:
+			switch (arg & ~(PROC_LA_STATUS_LA48 |
+			    PROC_LA_STATUS_LA57)) {
+			case PROC_LA_CTL_LA48_ON_EXEC:
+				printf("la48 on exec");
+				break;
+			case PROC_LA_CTL_LA57_ON_EXEC:
+				printf("la57 on exec");
+				break;
+			case PROC_LA_CTL_DEFAULT_ON_EXEC:
+				printf("default on exec");
+				break;
+			}
+			if ((arg & PROC_LA_STATUS_LA48) != 0)
+				printf(", la48 active\n");
+			else if ((arg & PROC_LA_STATUS_LA57) != 0)
+				printf(", la57 active\n");
+			break;
+#endif
 		}
 	} else {
 		switch (mode) {
@@ -293,6 +335,18 @@ main(int argc, char *argv[])
 			arg = enable ? PROC_KPTI_CTL_ENABLE_ON_EXEC :
 			    PROC_KPTI_CTL_DISABLE_ON_EXEC;
 			error = procctl(P_PID, pid, PROC_KPTI_CTL, &arg);
+			break;
+#endif
+#ifdef PROC_LA_CTL
+		case MODE_LA57:
+			arg = enable ? PROC_LA_CTL_LA57_ON_EXEC :
+			    PROC_LA_CTL_DEFAULT_ON_EXEC;
+			error = procctl(P_PID, pid, PROC_LA_CTL, &arg);
+			break;
+		case MODE_LA48:
+			arg = enable ? PROC_LA_CTL_LA48_ON_EXEC :
+			    PROC_LA_CTL_DEFAULT_ON_EXEC;
+			error = procctl(P_PID, pid, PROC_LA_CTL, &arg);
 			break;
 #endif
 		default:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008232044.07NKiF4h034829>