Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp647819ybg; Tue, 9 Jun 2020 09:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ3wmrSfMwTQJAvuX5h+AFhuqw7mNCcqGz8BVxfciRT9OF/C001ERifFO2C2kSuW9owTHt X-Received: by 2002:a05:6402:6c6:: with SMTP id n6mr26588486edy.277.1591719599014; Tue, 09 Jun 2020 09:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591719599; cv=none; d=google.com; s=arc-20160816; b=RCQ69SihwOE7DpruSHHhywuBinh5xuZBuG6+7QGQ1f2C0MF1Hd2QH1HjOdyRE4cdDN u5y/JJvSWLxlKlbwmLiAjXqvUI+YNQgThHJ1vF6z3b3olvgpdAHP5/8+6EmC95T5MZhL 8VliDnADqca78yYEU1DzXPhmKu+aPzYPtpG47i9tVPF4q4BvEytV3nalF4Xqw/CTyX3r ZFGs3IvoxxaN03YPva/oSmiEEsf2AKx3gLYY6jMGZgyPrV5XOLO47zvH0Uq5zfh0AEnZ dRzzDSRPgPeautk9N+FC3vUCaWe3LxRRIwarNG2cDbMSgyeASdwMq1orl+JxabE4Z4VE 6SNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jaErIm1g8pBfDuw63kJESin3nykWHuqmau3bT/K+YjE=; b=ypiCJe7Iw+Cg0MTsPPLnb/9vDkkR/wBr/OnlTeSstqOQ5UBMZHeN9HUiWuWupHzdOs TW5G3fk9Fz7rd3uZ0909/2MdKuYjPC22qFthJUY0e9qIZWx/0uYvaYvrD/RRIH5MBi1j FL+CvZ8xuLuFKngFy9zyW6y3heigOnLpNrbBiUUhb3KKN3gPyzCxBD3J9R4oPahHd8jL 2l+m9dreVb1qLi5mDKb3dhN05rzOdkT4XcewR00el9EP2DqnGsn/NRGMuU0oAIXWUK/x V/EcCx3gt0su5+WZ/xw/Ol2a/+0Jsjf8HLmDAmv+3Ilr/wZoRXnvsJtvrpOXpSuA18Q0 R03g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf24si10029435ejb.80.2020.06.09.09.19.35; Tue, 09 Jun 2020 09:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731260AbgFIQOx (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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