fork: Using clone_flags for legacy clone check
authorWang Jinchao <wangjinchao@xfusion.com>
Wed, 31 Jan 2024 02:54:41 +0000 (10:54 +0800)
committerChristian Brauner <brauner@kernel.org>
Fri, 2 Feb 2024 12:12:28 +0000 (13:12 +0100)
In the current implementation of clone(), there is a line that
initializes `u64 clone_flags = args->flags` at the top.
This means that there is no longer a need to use args->flags
for the legacy clone check.

Signed-off-by: Wang Jinchao <wangjinchao@xfusion.com>
Link: https://lore.kernel.org/r/202401311054+0800-wangjinchao@xfusion.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/fork.c

index 47ff3b35352e0bb4ec040b77241d9cbdcb986ef2..95647c66309f22cbf099974920529076cc372784 100644 (file)
@@ -2875,8 +2875,8 @@ pid_t kernel_clone(struct kernel_clone_args *args)
         * here has the advantage that we don't need to have a separate helper
         * to check for legacy clone().
         */
-       if ((args->flags & CLONE_PIDFD) &&
-           (args->flags & CLONE_PARENT_SETTID) &&
+       if ((clone_flags & CLONE_PIDFD) &&
+           (clone_flags & CLONE_PARENT_SETTID) &&
            (args->pidfd == args->parent_tid))
                return -EINVAL;