aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Branco <rbranco@suse.de>2026-04-19 21:16:48 +0000
committerPouria Mousavizadeh Tehrani <pouria@FreeBSD.org>2026-04-22 09:27:41 +0000
commit98a868c61b931e37cf09adecd8542cbd874d333f (patch)
tree85e0c5f8bf98c197e0254d7046913541ac437344
parent50ff71e956b631b56a878bd723a9b32dfbdac60f (diff)
linux: Support LINUX_PR_GET_NO_NEW_PRIVS prctl(2)
PR: 294651 Signed-off-by: Ricardo Branco <rbranco@suse.de> Reviewed by: kib, pouria Pull-Request: https://github.com/freebsd/freebsd-src/pull/2151
-rw-r--r--sys/compat/linux/linux_misc.c8
-rw-r--r--sys/compat/linux/linux_misc.h3
2 files changed, 10 insertions, 1 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 6080bbd058f0..85088e8ed7ca 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1822,6 +1822,14 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args)
error = kern_procctl(td, P_PID, p->p_pid,
PROC_NO_NEW_PRIVS_CTL, &arg);
break;
+ case LINUX_PR_GET_NO_NEW_PRIVS:
+ error = kern_procctl(td, P_PID, p->p_pid,
+ PROC_NO_NEW_PRIVS_STATUS, &arg);
+ if (error != 0)
+ return (error);
+ /* Linux returns the value as the syscall return */
+ td->td_retval[0] = arg == PROC_NO_NEW_PRIVS_ENABLE ? 1 : 0;
+ break;
case LINUX_PR_SET_PTRACER:
linux_msg(td, "unsupported prctl PR_SET_PTRACER");
error = EINVAL;
diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h
index 4412ff5b0f92..abd3a6df76f1 100644
--- a/sys/compat/linux/linux_misc.h
+++ b/sys/compat/linux/linux_misc.h
@@ -59,7 +59,8 @@
#define LINUX_PR_CAPBSET_READ 23
#define LINUX_PR_SET_CHILD_SUBREAPER 36 /* Get child subreaper status */
#define LINUX_PR_GET_CHILD_SUBREAPER 37 /* Set child subreaper status */
-#define LINUX_PR_SET_NO_NEW_PRIVS 38
+#define LINUX_PR_SET_NO_NEW_PRIVS 38 /* Set no_new_privs attribute */
+#define LINUX_PR_GET_NO_NEW_PRIVS 39 /* Get no_new_privs attribute */
#define LINUX_PR_SET_PTRACER 1499557217
#define LINUX_MAX_COMM_LEN 16 /* Maximum length of the process name. */