Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6304652pxb; Wed, 17 Feb 2021 00:27:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP26iwPaFh/zOA0N/iIFPQqT6x1MTPIBOUsECqumdUfB+IZ0e62tSJ6EhjhE6hAMW+6bP+ X-Received: by 2002:a50:8a90:: with SMTP id j16mr24598491edj.334.1613550421155; Wed, 17 Feb 2021 00:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613550421; cv=none; d=google.com; s=arc-20160816; b=js+PHevX8iwxqfXIhvxOuZ7Hqol9pXX6cmGy8+iRJ6lVthQIN/EUsT1Xlrs+H27AsR PslnpYbZXoE+pRTxUMB3rE/DBb5teNxmeGUKz9yp2Vj4IP7ldJwA8NV4M1+DITo8s6Ze miFHQKJUl0j28OZZIum/tesbZ6CRO9wl14TQEhi5DblBHKTOoGBJ6l70pNXAjnby4UUp /klL4aHxfMYqUYDtgugWCQFidOuDaK16awWho4Nc5bknzHVtiwYB/TIBcyIFo6k7+QuS Xs17ddHGijHRC7r4w10/P73is9z4suqir9GpcOF+aC9xt5ocxCf4HA4/XjqoCFFqvD2g dT4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3wRNeviy8S4CQ+4Q+aBrmkorq4UarUFgzpBLBlz8qnI=; b=BDJlkerMNN8Yn0+FhLZGFf+yglwCdouqvPrx66KZ/7DsJRtBh6Kg/8AZMwhOsBX4D3 /UvSi9GXF80zeHAUSg57MHRjYkaID6/0FpAlKj0CY+pCBz6MIayNCNgQUhh31PV5awvv qZxQlAdxkENSSX+bj0p9l2KeVAq0zxOVjMRpatKMotWpyk2ErsJjwAcNn9TQI98hy0iD WThshR9mOd/IDWpCbFTQZaiZ0CrlQIIH5HUoXA/JLey4lMeH/mnMuwNC5Bd1TSE2AxV+ eI7j9ugWYgNRR4ibivp+Z0j5sJwayZMjo9jPd03iKu0pj9VvJgWw9Q45e7ZqDsoKb/+Q txNQ== 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si1041415ejy.672.2021.02.17.00.26.37; Wed, 17 Feb 2021 00:27:01 -0800 (PST) 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231947AbhBQIWu (ORCPT + 99 others); Wed, 17 Feb 2021 03:22:50 -0500 Received: from raptor.unsafe.ru ([5.9.43.93]:56796 "EHLO raptor.unsafe.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbhBQIWl (ORCPT ); Wed, 17 Feb 2021 03:22:41 -0500 Received: from comp-core-i7-2640m-0182e6.redhat.com (ip-94-113-225-162.net.upcbroadband.cz [94.113.225.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by raptor.unsafe.ru (Postfix) with ESMTPSA id 50EEC20A19; Wed, 17 Feb 2021 08:21:57 +0000 (UTC) From: Alexey Gladkov To: LKML , "Eric W . Biederman" , Linux FS Devel Cc: Alexey Gladkov , Alexander Viro , Kees Cook Subject: [RESEND PATCH v4 3/3] proc: Disable cancellation of subset=pid option Date: Wed, 17 Feb 2021 09:21:43 +0100 Message-Id: <4aa63b96263e564822a7782ad826e43d3d9de34b.1613550081.git.gladkov.alexey@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.1 (raptor.unsafe.ru [5.9.43.93]); Wed, 17 Feb 2021 08:21:57 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no way to remount procfs mountpoint with subset=pid option without it. This is done in order not to make visible what was hidden since some checks occur during mount. This patch makes this limitation explicit and demonstrates the error. Signed-off-by: Alexey Gladkov --- fs/proc/root.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/proc/root.c b/fs/proc/root.c index 0ab90e24d9ae..d4a91f48c430 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -145,7 +145,7 @@ static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param) return 0; } -static void proc_apply_options(struct super_block *s, +static int proc_apply_options(struct super_block *s, struct fs_context *fc, struct user_namespace *user_ns) { @@ -159,8 +159,11 @@ static void proc_apply_options(struct super_block *s, if (ctx->mask & (1 << Opt_subset)) { if (ctx->pidonly == PROC_PIDONLY_ON) s->s_iflags |= SB_I_DYNAMIC; + else if (fs_info->pidonly == PROC_PIDONLY_ON) + return invalf(fc, "proc: subset=pid cannot be unset\n"); fs_info->pidonly = ctx->pidonly; } + return 0; } static int proc_fill_super(struct super_block *s, struct fs_context *fc) @@ -187,7 +190,10 @@ static int proc_fill_super(struct super_block *s, struct fs_context *fc) fs_info->pid_ns = get_pid_ns(ctx->pid_ns); fs_info->mounter_cred = get_cred(fc->cred); - proc_apply_options(s, fc, current_user_ns()); + ret = proc_apply_options(s, fc, current_user_ns()); + if (ret) { + return ret; + } /* * procfs isn't actually a stacking filesystem; however, there is @@ -229,8 +235,7 @@ static int proc_reconfigure(struct fs_context *fc) put_cred(fs_info->mounter_cred); fs_info->mounter_cred = get_cred(fc->cred); - proc_apply_options(sb, fc, current_user_ns()); - return 0; + return proc_apply_options(sb, fc, current_user_ns()); } static int proc_get_tree(struct fs_context *fc) -- 2.29.2