Skip to contentSkip to conversation

SELINUX: add /sys/fs/selinux mount point to put selinuxfs

PATCH Stephen Smalley 3 participants 4 messages May 2, 2011 1 message not in the archive SELinux security module

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 15 lines · Greg KH

From: Greg Kroah-Hartman <[email protected]>

In the interest of keeping userspace from having to create new root filesystems all the time, let's follow the lead of the other in-kernel filesystems and provide a proper mount point for it in sysfs.

For selinuxfs, this mount point should be in /sys/fs/selinux/

Cc Stephen Smalley <[email protected]>
Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Daniel J Walsh <[email protected]>
Quoted 4 lines

---

Note, patch is untested, I don't have any selinux-based machines here, sorry.

If I understand correctly, the patch won't change any userspace-visible behavior until one has a new libselinux that actually mounts selinuxfs on /sys/fs/selinux instead of /selinux, right?

At that point, we have to ensure that all userspace that directly references /selinux rather than using libselinux is changed to use libselinux. You might argue that all such userspace is broken already, but given that selinuxfs has been mounted on /selinux ever since SELinux went into mainline in 2003 and , it is difficult to blame them. Using codesearch.google.com on
e.g. /selinux/enforce, /selinux/load, /selinux/booleans, /selinux/mls, etc turns up a number of examples, including glibc (a test case), puppet, dracut, anaconda, etc.

Policy implication: Any program that needs to access selinuxfs will need to be able to search sysfs too.

Added dependency: Any system that uses SELinux will need to enable and mount sysfs (or alternatively create at least a fake /sys/fs directory). I assume that sysfs is fairly universal at this point though, like proc?

Quoted 42 lines
security/selinux/selinuxfs.c +10 -2
index ea39cb7..2381c16 100644
@@ -1897,6 +1897,7 @@ static struct file_system_type sel_fs_type = {
 };
 
 struct vfsmount *selinuxfs_mount;
+static struct kobject *selinuxfs_kobj;
 
 static int __init init_sel_fs(void)
 {
@@ -1904,9 +1905,16 @@ static int __init init_sel_fs(void)
 
 	if (!selinux_enabled)
 		return 0;
+
+	selinux_kobj = kobject_create_and_add("selinux", fs_kobj);
+	if (!selinux_kobj)
+		return -ENOMEM;
+
 	err = register_filesystem(&sel_fs_type);
-	if (err)
+	if (err) {
+		kobject_put(selinux_kobj);
 		return err;
+	}
 
 	selinuxfs_mount = kern_mount(&sel_fs_type);
 	if (IS_ERR(selinuxfs_mount)) {
@@ -1923,6 +1931,7 @@ __initcall(init_sel_fs);
 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
 void exit_sel_fs(void)
 {
+	kobjext_put(selinux_kobj);
 	unregister_filesystem(&sel_fs_type);
 }
 #endif
--

To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 16 lines · Stephen Smalley
Quoted 15 lines · Greg KH

From: Greg Kroah-Hartman <[email protected]>

In the interest of keeping userspace from having to create new root filesystems all the time, let's follow the lead of the other in-kernel filesystems and provide a proper mount point for it in sysfs.

For selinuxfs, this mount point should be in /sys/fs/selinux/

Cc Stephen Smalley <[email protected]>
Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Daniel J Walsh <[email protected]>
Quoted 8 lines
Quoted 4 lines

---

Note, patch is untested, I don't have any selinux-based machines here, sorry.

If I understand correctly, the patch won't change any userspace-visible behavior until one has a new libselinux that actually mounts selinuxfs on /sys/fs/selinux instead of /selinux, right?

Correct.

Quoted 10 lines

At that point, we have to ensure that all userspace that directly references /selinux rather than using libselinux is changed to use libselinux. You might argue that all such userspace is broken already, but given that selinuxfs has been mounted on /selinux ever since SELinux went into mainline in 2003 and , it is difficult to blame them. Using codesearch.google.com on
e.g. /selinux/enforce, /selinux/load, /selinux/booleans, /selinux/mls, etc turns up a number of examples, including glibc (a test case), puppet, dracut, anaconda, etc.

Quoted 6 lines

Policy implication: Any program that needs to access selinuxfs will need to be able to search sysfs too.

Added dependency: Any system that uses SELinux will need to enable and mount sysfs (or alternatively create at least a fake /sys/fs directory). I assume that sysfs is fairly universal at this point though, like proc?

Yes it is.

Care to forward this on to James for the next kernel merge window?

thanks,

greg k-h

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 41 lines · Greg KH
Quoted 16 lines · Stephen Smalley
Quoted 15 lines · Greg KH

From: Greg Kroah-Hartman <[email protected]>

In the interest of keeping userspace from having to create new root filesystems all the time, let's follow the lead of the other in-kernel filesystems and provide a proper mount point for it in sysfs.

For selinuxfs, this mount point should be in /sys/fs/selinux/

Cc Stephen Smalley <[email protected]>
Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Daniel J Walsh <[email protected]>
Quoted 8 lines
Quoted 4 lines

---

Note, patch is untested, I don't have any selinux-based machines here, sorry.

If I understand correctly, the patch won't change any userspace-visible behavior until one has a new libselinux that actually mounts selinuxfs on /sys/fs/selinux instead of /selinux, right?

Correct.

Quoted 13 lines

At that point, we have to ensure that all userspace that directly references /selinux rather than using libselinux is changed to use libselinux. You might argue that all such userspace is broken already, but given that selinuxfs has been mounted on /selinux ever since SELinux went into mainline in 2003 and , it is difficult to blame them. Using codesearch.google.com on
e.g. /selinux/enforce, /selinux/load, /selinux/booleans, /selinux/mls, etc turns up a number of examples, including glibc (a test case), puppet, dracut, anaconda, etc.

Policy implication: Any program that needs to access selinuxfs will need to be able to search sysfs too.

Quoted 7 lines
Quoted 3 lines

Added dependency: Any system that uses SELinux will need to enable and mount sysfs (or alternatively create at least a fake /sys/fs directory). I assume that sysfs is fairly universal at this point though, like proc?

Yes it is.

Care to forward this on to James for the next kernel merge window?

I'll pick it up in the selinux tree when my machine finished reinstalling.

-Eric

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 46 lines · Eric Paris
Quoted 45 lines · Greg KH
Quoted 16 lines · Stephen Smalley
Quoted 15 lines · Greg KH

From: Greg Kroah-Hartman <[email protected]>

In the interest of keeping userspace from having to create new root filesystems all the time, let's follow the lead of the other in-kernel filesystems and provide a proper mount point for it in sysfs.

For selinuxfs, this mount point should be in /sys/fs/selinux/

Cc Stephen Smalley <[email protected]>
Cc James Morris <[email protected]>
Cc Eric Paris <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Daniel J Walsh <[email protected]>
Quoted 8 lines
Quoted 4 lines

---

Note, patch is untested, I don't have any selinux-based machines here, sorry.

If I understand correctly, the patch won't change any userspace-visible behavior until one has a new libselinux that actually mounts selinuxfs on /sys/fs/selinux instead of /selinux, right?

Correct.

Quoted 16 lines

At that point, we have to ensure that all userspace that directly references /selinux rather than using libselinux is changed to use libselinux. You might argue that all such userspace is broken already, but given that selinuxfs has been mounted on /selinux ever since SELinux went into mainline in 2003 and , it is difficult to blame them. Using codesearch.google.com on
e.g. /selinux/enforce, /selinux/load, /selinux/booleans, /selinux/mls, etc turns up a number of examples, including glibc (a test case), puppet, dracut, anaconda, etc.

Policy implication: Any program that needs to access selinuxfs will need to be able to search sysfs too.

Added dependency: Any system that uses SELinux will need to enable and mount sysfs (or alternatively create at least a fake /sys/fs directory). I assume that sysfs is fairly universal at this point though, like proc?

Quoted 6 lines
Quoted 3 lines

Yes it is.

Care to forward this on to James for the next kernel merge window?

I'll pick it up in the selinux tree when my machine finished reinstalling.

Wonderful, thanks for doing this.

greg k-h

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.