From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A7FDC433E0 for ; Tue, 9 Jun 2020 07:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1CD12074B for ; Tue, 9 Jun 2020 07:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbgFIHoy (ORCPT ); Tue, 9 Jun 2020 03:44:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:60738 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbgFIHox (ORCPT ); Tue, 9 Jun 2020 03:44:53 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jiYvo-0005vo-1f; Tue, 09 Jun 2020 07:44:24 +0000 Date: Tue, 9 Jun 2020 09:44:22 +0200 From: Christian Brauner To: Andrei Vagin Cc: Adrian Reber , Eric Biederman , Pavel Emelyanov , Oleg Nesterov , Dmitry Safonov <0x7f454c46@gmail.com>, Nicolas Viennot , =?utf-8?B?TWljaGHFgiBDxYJhcGnFhHNraQ==?= , Kamil Yurtsever , Dirk Petersen , Christine Flood , Casey Schaufler , Mike Rapoport , Radostin Stoyanov , Cyrill Gorcunov , Serge Hallyn , Stephen Smalley , Sargun Dhillon , Arnd Bergmann , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, Eric Paris , Jann Horn , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 1/3] capabilities: Introduce CAP_CHECKPOINT_RESTORE Message-ID: <20200609074422.burwzfgwgqqysrzh@wittgenstein> References: <20200603162328.854164-1-areber@redhat.com> <20200603162328.854164-2-areber@redhat.com> <20200609034221.GA150921@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200609034221.GA150921@gmail.com> Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org On Mon, Jun 08, 2020 at 08:42:21PM -0700, Andrei Vagin wrote: > On Wed, Jun 03, 2020 at 06:23:26PM +0200, Adrian Reber wrote: > > This patch introduces CAP_CHECKPOINT_RESTORE, a new capability facilitating > > checkpoint/restore for non-root users. > > > > Over the last years, The CRIU (Checkpoint/Restore In Userspace) team has been > > asked numerous times if it is possible to checkpoint/restore a process as > > non-root. The answer usually was: 'almost'. > > > > The main blocker to restore a process as non-root was to control the PID of the > > restored process. This feature available via the clone3 system call, or via > > /proc/sys/kernel/ns_last_pid is unfortunately guarded by CAP_SYS_ADMIN. > > > > In the past two years, requests for non-root checkpoint/restore have increased > > due to the following use cases: > > * Checkpoint/Restore in an HPC environment in combination with a resource > > manager distributing jobs where users are always running as non-root. > > There is a desire to provide a way to checkpoint and restore long running > > jobs. > > * Container migration as non-root > > * We have been in contact with JVM developers who are integrating > > CRIU into a Java VM to decrease the startup time. These checkpoint/restore > > applications are not meant to be running with CAP_SYS_ADMIN. > > > ... > > > > The introduced capability allows to: > > * Control PIDs when the current user is CAP_CHECKPOINT_RESTORE capable > > for the corresponding PID namespace via ns_last_pid/clone3. > > * Open files in /proc/pid/map_files when the current user is > > CAP_CHECKPOINT_RESTORE capable in the root namespace, useful for recovering > > files that are unreachable via the file system such as deleted files, or memfd > > files. > > PTRACE_O_SUSPEND_SECCOMP is needed for C/R and it is protected by > CAP_SYS_ADMIN too. This is currently capable(CAP_SYS_ADMIN) (init_ns capable) why is it safe to allow unprivileged users to suspend security policies? That sounds like a bad idea. if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) { if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) || !IS_ENABLED(CONFIG_SECCOMP)) return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (seccomp_mode(¤t->seccomp) != SECCOMP_MODE_DISABLED || current->ptrace & PT_SUSPEND_SECCOMP) return -EPERM; } Christian