pid_namespace: use checkpoint_restore_ns_capable() for ns_last_pid
authorAdrian Reber <areber@redhat.com>
Sun, 19 Jul 2020 10:04:13 +0000 (12:04 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 19 Jul 2020 18:14:42 +0000 (20:14 +0200)
Use the newly introduced capability CAP_CHECKPOINT_RESTORE to allow
writing to ns_last_pid.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20200719100418.2112740-4-areber@redhat.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
kernel/pid_namespace.c

index 0e5ac16..ac135bd 100644 (file)
@@ -269,7 +269,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
        struct ctl_table tmp = *table;
        int ret, next;
 
-       if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
+       if (write && !checkpoint_restore_ns_capable(pid_ns->user_ns))
                return -EPERM;
 
        /*