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


Groups > linux.kernel > #1547553 > unrolled thread

mount_pseudo(), sget() and MS_KERNMOUNT

Started byLuis Ressel <aranea@aixah.de>
First post2016-12-27 12:00 +0100
Last post2017-01-04 05:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  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

#1547553 — mount_pseudo(), sget() and MS_KERNMOUNT

FromLuis Ressel <aranea@aixah.de>
Date2016-12-27 12:00 +0100
Subjectmount_pseudo(), sget() and MS_KERNMOUNT
Message-ID<sSXE5-Wv-3@gated-at.bofh.it>
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()?

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.)

Regards,
Luis Ressel

(Apologies if I'm sending this inquiry to the wrong people. I don't
know much about the kernel development workflow, so I decided to send
it to whomever get_maintainer.pl spat out, plus the author of the
sget() change in 4.8.)

[toc] | [next] | [standalone]


#1550420

Fromebiederm@xmission.com (Eric W. Biederman)
Date2017-01-04 05:30 +0100
Message-ID<sVLn3-7ZE-3@gated-at.bofh.it>
In reply to#1547553
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);
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web