Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp523906ybh; Wed, 15 Jul 2020 08:13:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlQFDm3rrF19iT4UTWDmgUOG1xX8hMxknV6cxXdE9UIwqpk8Mp7pnmUuwjswea61PUikrv X-Received: by 2002:a17:906:dc12:: with SMTP id yy18mr5838047ejb.295.1594826003260; Wed, 15 Jul 2020 08:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594826003; cv=none; d=google.com; s=arc-20160816; b=befPd7ae9u8qHNDWWL8acxjVWwLs7NgZmjqjqo+og9v6xGZRRu+pHTJGuB4skdeqvp CQmzcRPS5MRYqQzWCBFXfszqSo6rCiMUhslAF249x0g517OCd1YDMFKkpPAcB7fpdQWy nBPUwrmsYQ6kfj0htc9JQUMUUia9UhB0MwYDZE1CPItnupEK4LZVekouZgrjKTd7iYVs DfEL4SwjkgjK/tSmeU0z0Zm8/SDUXIJ5YCORLPTTeYVhu/Q+BIpaGCp9mr7DS1Scsxn9 JHT7r/V2E2FeI+ph2fy6KA41wBZukK+jqSSNgROuN7HU6HdVW9L/V0dUFoPbXNc1VxXY yIag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YrIQ7usHt/ICUIVG/4Zzx10RZSX03Ne/OGNOYc1RqJU=; b=GzYQbalddc60H+5jG3o/sKJkmj5zuV/wP1kZe7EsM3W6co8e7dgVhkq7NysAQNFjls rrrqwuAV4tdCn9KAKPXrf6dnOCA49KLY4A34TF5TReZEmtN7DfVoVKFoTJu0WILUepO1 rbepmckB5IisOsLSi7WZcWMBxHAbWJAp55VkoHnAPpfScfBjbbRZjQB2N6VAJWh/3W8T 50EyTf0M8Aq0LIP3rTtMxc/21NEIRsQbhj4ReBaLvZR3Ooxo1SkUF7eyfPkqjdqrLExl H/arR1F3gVEDpnFBA1NauZ8MPkARuz6zjkH4s1guBt+GOuDfpwNqMds0Aoqtmd5qjzdt u71g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KCNM5aYq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si1392457eje.95.2020.07.15.08.13.00; Wed, 15 Jul 2020 08:13:23 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KCNM5aYq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbgGOOxD (ORCPT + 99 others); Wed, 15 Jul 2020 10:53:03 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59956 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726859AbgGOOxD (ORCPT ); Wed, 15 Jul 2020 10:53:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594824782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YrIQ7usHt/ICUIVG/4Zzx10RZSX03Ne/OGNOYc1RqJU=; b=KCNM5aYqJ/1VQbSvnu1+TFwUE5vGLQRflnY/U8zdu7Wzr8K7EN2GwFz+/uGaBmoS/SLOIz BV6Gf7Ml1UttQugxItEhIEDQknDx7fk4m47k4HCbjfZuol8ZBwSGYHOpGiLrAxLzp85HDV dp0iI3f5LnOBQLloxgp/1fUyMvId1SM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-OOnXwcsxNimB7eMBtWwEKw-1; Wed, 15 Jul 2020 10:51:49 -0400 X-MC-Unique: OOnXwcsxNimB7eMBtWwEKw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEEDE18A1DE7; Wed, 15 Jul 2020 14:51:45 +0000 (UTC) Received: from dcbz.redhat.com (ovpn-114-113.ams2.redhat.com [10.36.114.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03C7E60BF1; Wed, 15 Jul 2020 14:51:32 +0000 (UTC) From: Adrian Reber To: Christian Brauner , Eric Biederman , Pavel Emelyanov , Oleg Nesterov , Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Nicolas Viennot , =?UTF-8?q?Micha=C5=82=20C=C5=82api=C5=84ski?= , Kamil Yurtsever , Dirk Petersen , Christine Flood , Casey Schaufler Cc: Mike Rapoport , Radostin Stoyanov , Adrian Reber , 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: [PATCH v5 4/6] proc: allow access in init userns for map_files with CAP_CHECKPOINT_RESTORE Date: Wed, 15 Jul 2020 16:49:52 +0200 Message-Id: <20200715144954.1387760-5-areber@redhat.com> In-Reply-To: <20200715144954.1387760-1-areber@redhat.com> References: <20200715144954.1387760-1-areber@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Opening files in /proc/pid/map_files when the current user is CAP_CHECKPOINT_RESTORE capable in the root namespace is useful for checkpointing and restoring to recover files that are unreachable via the file system such as deleted files, or memfd files. Signed-off-by: Adrian Reber Signed-off-by: Nicolas Viennot --- fs/proc/base.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 65893686d1f1..cada783f229e 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2194,16 +2194,16 @@ struct map_files_info { }; /* - * Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the - * symlinks may be used to bypass permissions on ancestor directories in the - * path to the file in question. + * Only allow CAP_SYS_ADMIN and CAP_CHECKPOINT_RESTORE to follow the links, due + * to concerns about how the symlinks may be used to bypass permissions on + * ancestor directories in the path to the file in question. */ static const char * proc_map_files_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) { - if (!capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_CHECKPOINT_RESTORE)) return ERR_PTR(-EPERM); return proc_pid_get_link(dentry, inode, done); -- 2.26.2