[RFC,bpf-next,01/13] fork: New clone3 flag for BPF namespace
Commit Message
A new clone3 flag CLONE_NEWBPF is introduced to create a new BPF
namespace.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/uapi/linux/sched.h | 1 +
kernel/fork.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
@@ -36,6 +36,7 @@
/* Flags for the clone3() syscall. */
#define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */
#define CLONE_INTO_CGROUP 0x200000000ULL /* Clone into a specific cgroup given the right permissions. */
+#define CLONE_NEWBPF 0x400000000ULL /* New BPF namespace */
/*
* cloning flags intersect with CSIGNAL so can be used with unshare and clone3
@@ -2929,7 +2929,8 @@ static bool clone3_args_valid(struct kernel_clone_args *kargs)
{
/* Verify that no unknown flags are passed along. */
if (kargs->flags &
- ~(CLONE_LEGACY_FLAGS | CLONE_CLEAR_SIGHAND | CLONE_INTO_CGROUP))
+ ~(CLONE_LEGACY_FLAGS | CLONE_CLEAR_SIGHAND | CLONE_INTO_CGROUP |
+ CLONE_NEWBPF))
return false;
/*
@@ -3080,7 +3081,7 @@ static int check_unshare_flags(unsigned long unshare_flags)
CLONE_VM|CLONE_FILES|CLONE_SYSVSEM|
CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET|
CLONE_NEWUSER|CLONE_NEWPID|CLONE_NEWCGROUP|
- CLONE_NEWTIME))
+ CLONE_NEWTIME|CLONE_NEWBPF))
return -EINVAL;
/*
* Not implemented, but pretend it works if there is nothing