git: 6d849754b996 - main - linux: implement PR_CHILD_SET_SUBREAPER

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 29 May 2024 13:58:14 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d849754b996703093ca474604c4d8b596c22bf3

commit 6d849754b996703093ca474604c4d8b596c22bf3
Author:     Son Phan Trung <phantrungson17@gmail.com>
AuthorDate: 2024-05-28 09:51:16 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-29 13:56:23 +0000

    linux: implement PR_CHILD_SET_SUBREAPER
    
    Reviewed by: imp, dchagin
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1260
---
 sys/compat/linux/linux_misc.c | 8 ++++++++
 sys/compat/linux/linux_misc.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index aa6c3923067f..73a4c49a1a6f 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1819,6 +1819,14 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args)
 #endif
 		error = EINVAL;
 		break;
+	case LINUX_PR_SET_CHILD_SUBREAPER:
+		if (args->arg2 == 0){
+			return (kern_procctl(td, P_PID, 0, PROC_REAP_RELEASE,
+			    NULL));
+		}
+
+		return (kern_procctl(td, P_PID, 0, PROC_REAP_ACQUIRE,
+		    NULL));
 	case LINUX_PR_SET_NO_NEW_PRIVS:
 		arg = args->arg2 == 1 ?
 		    PROC_NO_NEW_PRIVS_ENABLE : PROC_NO_NEW_PRIVS_DISABLE;
diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h
index cc025f89d5ff..445110c598cc 100644
--- a/sys/compat/linux/linux_misc.h
+++ b/sys/compat/linux/linux_misc.h
@@ -57,6 +57,7 @@
 #define	LINUX_PR_GET_SECCOMP	21
 #define	LINUX_PR_SET_SECCOMP	22
 #define	LINUX_PR_CAPBSET_READ	23
+#define LINUX_PR_SET_CHILD_SUBREAPER 36
 #define	LINUX_PR_SET_NO_NEW_PRIVS	38
 #define	LINUX_PR_SET_PTRACER	1499557217