Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp920916ybh; Sun, 19 Jul 2020 03:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvNCJ5wfxwlq7TE+8wb3lgNLVxvADkpDrEs98QY9IwqMqRr88er1j5t+mqMGZQ+On8ghlo X-Received: by 2002:a05:6402:1d0a:: with SMTP id dg10mr16251620edb.110.1595153352502; Sun, 19 Jul 2020 03:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595153352; cv=none; d=google.com; s=arc-20160816; b=kl/AsL6jhmNIzC2S9whmJQhohpzLQ2LubkuCathy6/k+ZarXz5eUni9fTsvi39p327 nTIgh8OoJ3DozvEL7rSYErqwGi9xwblalDhXKjAige8g7SmP9eV8XXhRcfDHiP2Bh6uI PdFaRm29J1OG/NVFYm5WWpn679Dr1Tyy6R2imRAPwZWG55JTiSYlHwZ8VSeX36ZzrB6M Bg+y3xujSEU/mc+o/xfoNtpzwyC4VkPNcvkDhhCr2bPj7WDcJA/p+fISh4QvJmjAKbkl lsXZp7Sf9Li7BokQsxHUy35Kv2vP9gY8z8JlKmNXl0fPtZGoXv7iyZuCLe/KDLwftRFN a3fg== 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=bWuh2eVsJy0zmmKuqx/toS5Tiv1kLy1bNqveFCfH5Bc=; b=PQxZ8D+Mk6wQdMbumrM5nedUtf0Qw6eaCdwfmnuhtxOCFXZud74l06+0xIy9kY4Gvh Pdgaq/Xfuu/xjbnZ5IwokOolegXM1bph+3K24N51pPLzkUwvVYjMLC24xyos6XwRjlmd BwIJCdRvlYTlOiyEfvJSrHhGh0eVTrS9rXeluHf8p2QzFknls5F40+YlKrS3sEl1MhI4 +IKdvDfnn6brve8lBogjQ54D3KCjyV21iPdEKVu97Z6HUlscMgqW7aInmUOsJxteDJPI yYL2BV9mgl7k5pS49WzdQ92dhIzU62moZrXuMWeDY9mOMgj7JeBIGrpaHrsqM1OQCpaZ lDFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d25qZHxb; 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 e14si8993666edr.380.2020.07.19.03.08.49; Sun, 19 Jul 2020 03:09:12 -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=d25qZHxb; 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 S1726715AbgGSKGH (ORCPT + 99 others); Sun, 19 Jul 2020 06:06:07 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37747 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726608AbgGSKGF (ORCPT ); Sun, 19 Jul 2020 06:06:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595153164; 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=bWuh2eVsJy0zmmKuqx/toS5Tiv1kLy1bNqveFCfH5Bc=; b=d25qZHxbdFo0wHUXA6aawM5H8nsz21uyJh/yBzqGLaZOx2C+6P2Qij0zm7S0eki3WPShLB oRFmijbIx0WQHK3QRoRu9HBSqIA6rtr3Dul9nVk1N6OkbBn/CapsJkMDtTkwpDC3091h0K w2I5u4Sfe8E2dk2MK5J3C9El2kS5ddQ= 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-27-HFeV2CDOO668pp4rFaUAjw-1; Sun, 19 Jul 2020 06:06:00 -0400 X-MC-Unique: HFeV2CDOO668pp4rFaUAjw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 621AA1085; Sun, 19 Jul 2020 10:05:57 +0000 (UTC) Received: from dcbz.redhat.com (ovpn-112-10.ams2.redhat.com [10.36.112.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C6B8710A8; Sun, 19 Jul 2020 10:05:52 +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 v6 4/7] proc: allow access in init userns for map_files with CAP_CHECKPOINT_RESTORE Date: Sun, 19 Jul 2020 12:04:14 +0200 Message-Id: <20200719100418.2112740-5-areber@redhat.com> In-Reply-To: <20200719100418.2112740-1-areber@redhat.com> References: <20200719100418.2112740-1-areber@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Reviewed-by: Cyrill Gorcunov --- 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..b824a8c89011 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 (!checkpoint_restore_ns_capable(&init_user_ns)) return ERR_PTR(-EPERM); return proc_pid_get_link(dentry, inode, done); -- 2.26.2