Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp310079ybg; Tue, 9 Jun 2020 00:49:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyICiunWz+Ry1FSMNxlCciiwZ3w9lkOP+q4gvP0E+sc3nTIFF0GHh7cb3UH2A2vahyMppCm X-Received: by 2002:a17:906:7c5a:: with SMTP id g26mr24552077ejp.200.1591688987344; Tue, 09 Jun 2020 00:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591688987; cv=none; d=google.com; s=arc-20160816; b=hGGR2dnDtFkamt1TUo97mh/8oNdaSUntQ3RIoh2FLmPdCyGSoS23LNNwpwtb4v2Um5 jcELSVw8Z0KSyW/rsQMeOA85hoyrT7HrXHlrKLW4m6QiT4y5AMOs4HHRszywNXvVfwKo dBbRMOayK5EJyLrPu6ODHbLBBGRsS22NiA3Yi4PR6/a7qihFnjdBz2dThdB0NZYdIFti LLUgf0GvxSDKxehb3tnrCfKSQiyn7ijY299w0fDGpttrD1xvbRCatCMouAKu82AcY9lt JJUubNCNzskyhNbNLgPbAHF8mppDa/fhX3DjR1eJTutfk3ZB+J5dGvuvVPHTsKtlrK7x rFoQ== 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=9ieeboSlkMiGfLOWoXNV4U/pFxsDZ+dmhSb0pwTP+qU=; b=b/7pZNy6hYkhgP5fAfbM2v8tUY3c9Z3Jd6FRsJOuluWpQF1CArCI+6zd5qABDNaJgZ B9Hi7Fxwxk0k1pgz571UV4Obd+9MLOQswar1jmDtoUd/8h7hw6wD8ltJEjlZpp3gyW0O yQ+LG4/fR+JXCq+94W5FH+CmCgOmb3XpIpzIxHtlwvmUdr6SMia9Qt158xgeMT7hkCdA QS77jIPZopPJzSxkaq3DBbClG6CbTPm90BmP17PF7PSbNhkZTXed8nCALYKZftZ6k7+V fSegGJ16LmaygIrIH8m+UqALhy2zygZNf0L3Wa5rVf8Lf1AIxPhIJrIScG8BlAVsK6XM lnUg== 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 y25si8096431edm.63.2020.06.09.00.49.23; Tue, 09 Jun 2020 00:49:47 -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 S1728064AbgFIHoy (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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