git: 59034620c491 - stable/13 - linux(4): Return ENOSYS for unsupported clone3 option bits.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 19:38:07 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=59034620c491aab24a9dbceb8134a8987472b458

commit 59034620c491aab24a9dbceb8134a8987472b458
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-08-12 08:56:36 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:32 +0000

    linux(4): Return ENOSYS for unsupported clone3 option bits.
    
    Differential Revision:  https://reviews.freebsd.org/D31483
    MFC after:              2 weeks
    
    (cherry picked from commit 4385147547d9f2f8b93f08012c0a18aa6d895403)
---
 sys/compat/linux/linux_fork.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c
index 77dd8446c588..ba169ff98923 100644
--- a/sys/compat/linux/linux_fork.c
+++ b/sys/compat/linux/linux_fork.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_futex.h>
+#include <compat/linux/linux_mib.h>
 #include <compat/linux/linux_misc.h>
 #include <compat/linux/linux_util.h>
 
@@ -411,6 +412,20 @@ linux_clone3_args_valid(struct l_user_clone_args *uca)
 	if (uca->stack != 0 && uca->stack_size == 0)
 		return (EINVAL);
 
+	/* Verify that no unsupported flags are passed along. */
+	if ((uca->flags & LINUX_CLONE_NEWTIME) != 0) {
+		LINUX_RATELIMIT_MSG("unsupported clone3 option CLONE_NEWTIME");
+		return (ENOSYS);
+	}
+	if ((uca->flags & LINUX_CLONE_INTO_CGROUP) != 0) {
+		LINUX_RATELIMIT_MSG("unsupported clone3 option CLONE_INTO_CGROUP");
+		return (ENOSYS);
+	}
+	if (uca->set_tid != 0 || uca->set_tid_size != 0) {
+		LINUX_RATELIMIT_MSG("unsupported clone3 set_tid");
+		return (ENOSYS);
+	}
+
 	return (0);
 }