Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1550420

Re: mount_pseudo(), sget() and MS_KERNMOUNT

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From ebiederm@xmission.com (Eric W. Biederman)
Newsgroups linux.kernel
Subject Re: mount_pseudo(), sget() and MS_KERNMOUNT
Date Wed, 04 Jan 2017 05:30:01 +0100
Message-ID <sVLn3-7ZE-3@gated-at.bofh.it> (permalink)
References <sSXE5-Wv-3@gated-at.bofh.it>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)
MIME-Version 1.0
Content-Type text/plain
X-Xm-Spf eid=1cOd7J-0004hk-8N;;;mid=<87a8b7318k.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=101.100.131.98;;;frm=ebiederm@xmission.com;;;spf=neutral
X-Xm-Aid U2FsdGVkX1/zItHOzSVxF+ljUrfzW1WHkmz5L3q3MPo=
X-Sa-Exim-Connect-IP 101.100.131.98
X-Sa-Exim-Mail-From ebiederm@xmission.com
X-Spam-Report * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject
X-Spam-Dcc XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1
X-Spam-Combo ;Luis Ressel <aranea@aixah.de>
X-Spam-Timing total 5344 ms - load_scoreonly_sql: 0.09 (0.0%), signal_user_changed: 12 (0.2%), b_tie_ro: 9 (0.2%), parse: 2.2 (0.0%), extract_message_metadata: 31 (0.6%), get_uri_detail_list: 2.6 (0.0%), tests_pri_-1000: 9 (0.2%), tests_pri_-950: 2.4 (0.0%), tests_pri_-900: 1.96 (0.0%), tests_pri_-400: 38 (0.7%), check_bayes: 36 (0.7%), b_tokenize: 12 (0.2%), b_tok_get_all: 9 (0.2%), b_comp_prob: 6 (0.1%), b_tok_touch_all: 3.7 (0.1%), b_finish: 1.77 (0.0%), tests_pri_0: 418 (7.8%), check_dkim_signature: 1.22 (0.0%), check_dkim_adsp: 6 (0.1%), tests_pri_500: 4820 (90.2%), poll_dns_idle: 4800 (89.8%), rewrite_mail: 0.00 (0.0%)
X-Spam-Flag No
X-Sa-Exim-Version 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600)
X-Sa-Exim-Scanned Yes (on in02.mta.xmission.com)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 45
Organization linux.* mail to news gateway
X-Original-Cc Alexander Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Wed, 04 Jan 2017 17:20:11 +1300
X-Original-Message-ID <87a8b7318k.fsf@xmission.com>
X-Original-References <20161227112037.015dc5ac@gentp.lnet>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1550420

Show key headers only | View raw


Luis Ressel <aranea@aixah.de> writes:

> Hello,
>
> With Linux 4.8, the sget() function in fs/super.c got a new permission
> check: It now returns -EPERM if
> (!(flags & MS_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN)) .
>
> I presume the first half is intented to detect in-kernel mounts? If so,
> why doesn't mount_pseudo() (in fs/libfs.c) pass the MS_KERNMOUNT flag
> to sget()?

It looks like an oversight that has simply not mattered.

> This behaviour has caused a problem for me: During graphics driver
> initalization, drm_fs_inode_new() (in drivers/gpu/drm/drm_drv.c) calls
> simple_pin_fs(). The MS_KERNMOUNT flag is indeed passed down the
> call chain from there, but it is lost when mount_pseudo() is called, as
> that function doesn't take a 'flags' argument.
>
> Hence, the first part of the above permission check fails. (The second
> part also fails under some cicumstances due to a SELinux quirk, and
> therefore the initalization of my graphics driver doesn't succeed.)

I am concerned that perhaps there is some wrong context in here that is
causing SELinux to have problems.

Does this correct your symptoms?

Eric

diff --git a/fs/libfs.c b/fs/libfs.c
index e973cd51f126..28d6f35feed6 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -245,7 +245,8 @@ struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type, char *name,
 	struct inode *root;
 	struct qstr d_name = QSTR_INIT(name, strlen(name));
 
-	s = sget(fs_type, NULL, set_anon_super, MS_NOUSER, NULL);
+	s = sget_userns(fs_type, NULL, set_anon_super, MS_KERNMOUNT|MS_NOUSER,
+			&init_user_ns, NULL);
 	if (IS_ERR(s))
 		return ERR_CAST(s);
 

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

mount_pseudo(), sget() and MS_KERNMOUNT Luis Ressel <aranea@aixah.de> - 2016-12-27 12:00 +0100
  Re: mount_pseudo(), sget() and MS_KERNMOUNT ebiederm@xmission.com (Eric W. Biederman) - 2017-01-04 05:30 +0100

csiph-web