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 DAF11C433DF for ; Tue, 9 Jun 2020 16:15:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB88820760 for ; Tue, 9 Jun 2020 16:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731125AbgFIQOx (ORCPT ); Tue, 9 Jun 2020 12:14:53 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53541 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731021AbgFIQOx (ORCPT ); Tue, 9 Jun 2020 12:14: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 1jigtQ-0007qO-Cr; Tue, 09 Jun 2020 16:14:28 +0000 Date: Tue, 9 Jun 2020 18:14:27 +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: <20200609161427.4eoozs3kkgablmaa@wittgenstein> References: <20200603162328.854164-1-areber@redhat.com> <20200603162328.854164-2-areber@redhat.com> <20200609034221.GA150921@gmail.com> <20200609074422.burwzfgwgqqysrzh@wittgenstein> <20200609160627.GA163855@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200609160627.GA163855@gmail.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Tue, Jun 09, 2020 at 09:06:27AM -0700, Andrei Vagin wrote: > On Tue, Jun 09, 2020 at 09:44:22AM +0200, Christian Brauner wrote: > > 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. > > Why do you think so bad about me;). I don't suggest to remove or Andrei, nothing could be further from me than to think bad about you! You've done way too much excellent work. ;) > downgrade this capability check. The patch allows all c/r related > operations if the current has CAP_CHECKPOINT_RESTORE. > > So in this case the check: > if (!capable(CAP_SYS_ADMIN)) > return -EPERM; > > will be converted in: > if (!capable(CAP_SYS_ADMIN) && !capable(CAP_CHECKPOINT_RESTORE)) > return -EPERM; Yeah, I got that but what's the goal here? Isn't it that you want to make it safe to install the criu binary with the CAP_CHECKPOINT_RESTORE fscap set so that unprivileged users can restore their own processes without creating a new user namespace or am I missing something? The use-cases in the cover-letter make it sound like that's what this is leading up to: > > > > * 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. But maybe I'm just misunderstanding crucial bits (likely (TM)). Christian