aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-08-23 20:44:15 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-08-23 20:44:15 +0000
commitda477bcdc0c335171bb0ed3813f570026de6df85 (patch)
treee310a30aa9db3d18844ac727c99beedddc44969a /usr.bin
parentf446480b5f48abab1cab450dd076658a838190dc (diff)
downloadsrc-da477bcdc0c335171bb0ed3813f570026de6df85.tar.gz
src-da477bcdc0c335171bb0ed3813f570026de6df85.zip
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/proccontrol/proccontrol.13
-rw-r--r--usr.bin/proccontrol/proccontrol.c56
2 files changed, 58 insertions, 1 deletions
diff --git a/usr.bin/proccontrol/proccontrol.1 b/usr.bin/proccontrol/proccontrol.1
index 33dff9b34ff3..4445bb5f9f8e 100644
--- a/usr.bin/proccontrol/proccontrol.1
+++ b/usr.bin/proccontrol/proccontrol.1
@@ -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
diff --git a/usr.bin/proccontrol/proccontrol.c b/usr.bin/proccontrol/proccontrol.c
index 9f4e764cf870..edcc23a3cb34 100644
--- a/usr.bin/proccontrol/proccontrol.c
+++ b/usr.bin/proccontrol/proccontrol.c
@@ -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) {
@@ -295,6 +337,18 @@ main(int argc, char *argv[])
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:
usage();
break;