Skip to contentSkip to conversation

Default context with context mount option.

DISCUSSION dE 5 participants 14 messages Jun 8, 2014 – Jun 12, 2014 SELinux security module

lore
Share & tools
lore

dE

author
#0 lore raw

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

Thanks.

#1 lore raw
Quoted 4 lines · On Sun, 08 Jun 2014 20:18:15 +0530 dE <[email protected]> wrote:

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

What do you mean by "security namespace" actually?

author
#2 lore raw
Quoted 7 lines · Christian Evans
Quoted 4 lines · On Sun, 08 Jun 2014 20:18:15 +0530 dE <[email protected]> wrote:

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

Quoted 7 lines

What do you mean by "security namespace" actually?

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

The xattr security namespace in the file system which's used by SELinux to store security context.

#3 lore raw
In reply to dE
Quoted 9 lines · dE

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

author
#4 lore raw
Quoted 12 lines · Stephen Smalley
Quoted 9 lines · dE

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

#5 lore raw
Quoted 25 lines · dE
Quoted 12 lines · Stephen Smalley
Quoted 9 lines · dE

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

Quoted 8 lines

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

#6 lore raw
Quoted 62 lines

-----Original Message-----
From: Selinux [mailto:[email protected]] On Behalf Of Stephen Smalley
Sent: Tuesday, June 10, 2014 8:05 AM
To: dE; [email protected]
Subject: Re: Default context with context mount option.

Quoted 3 lines · dE
Quoted 2 lines · Stephen Smalley
Quoted 1 line · dE

When a new file is created on a FS which supports security

namespace but

Quoted 1 line
Quoted 1 line
Quoted 1 line

the FS is mounted using context= option, then what will be the

context

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly

to

Quoted 1 line
Quoted 1 line
Quoted 1 line

get the getfattr dump to realize the security namespace is not

empty

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

(this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes

to

Quoted 4 lines
Quoted 4 lines

userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types

or

Quoted 3 lines
Quoted 1 line

conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there

does

Quoted 3 lines

exist a security attribute. But these FSs are defined by genfscon.

But about FSs which do support the security namespace (like XFS), and

so

Quoted 1 line

do not have a genfscon statement associated to them they but still

have

Quoted 4 lines

a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are

they

Quoted 1 line

just empty? Things get more confusing cause I get permission denied

when

Quoted 1 line

trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 6 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

How about creating a file based filesystem image and mounting it with a loop device? You can mount it with context mount options or straight up and easily see changes (or no changes) to the filesystem. That way you don't have to disable selinux and reboot the whole system. You can easily experiment with whichever filesystem types you'd like.

David

#7 lore raw
Quoted 62 lines · David Caplan
Quoted 62 lines

-----Original Message-----
From: Selinux [mailto:[email protected]] On Behalf Of Stephen Smalley
Sent: Tuesday, June 10, 2014 8:05 AM
To: dE; [email protected]
Subject: Re: Default context with context mount option.

Quoted 3 lines · dE
Quoted 2 lines · Stephen Smalley
Quoted 1 line · dE

When a new file is created on a FS which supports security

namespace but

Quoted 1 line
Quoted 1 line
Quoted 1 line

the FS is mounted using context= option, then what will be the

context

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly

to

Quoted 1 line
Quoted 1 line
Quoted 1 line

get the getfattr dump to realize the security namespace is not

empty

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

(this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes

to

Quoted 4 lines
Quoted 4 lines

userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types

or

Quoted 3 lines
Quoted 1 line

conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there

does

Quoted 3 lines

exist a security attribute. But these FSs are defined by genfscon.

But about FSs which do support the security namespace (like XFS), and

so

Quoted 1 line

do not have a genfscon statement associated to them they but still

have

Quoted 4 lines

a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are

they

Quoted 1 line

just empty? Things get more confusing cause I get permission denied

when

Quoted 1 line

trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 8 lines
Quoted 6 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

How about creating a file based filesystem image and mounting it with a loop device? You can mount it with context mount options or straight up and easily see changes (or no changes) to the filesystem. That way you don't have to disable selinux and reboot the whole system. You can easily experiment with whichever filesystem types you'd like.

I could be wrong, but as long as SELinux is enabled in the kernel I don't believe that will change anything. SELinux will still interpose on getxattr() and listxattr() requests performed on directories and files in the mounted filesystem, and it will still prohibit removexattr of the security.selinux attribute on such files.

Now, you could of course create a VM, perform your test there and only disable SELinux in the VM.

author
#8 lore raw
In reply to David Caplan
Quoted 66 lines · David Caplan
Quoted 60 lines

-----Original Message-----
From: Selinux [mailto:[email protected]] On Behalf Of Stephen Smalley
Sent: Tuesday, June 10, 2014 8:05 AM
To: dE; [email protected]
Subject: Re: Default context with context mount option.

Quoted 3 lines · dE
Quoted 2 lines · Stephen Smalley
Quoted 1 line · dE

When a new file is created on a FS which supports security

namespace but

Quoted 1 line
Quoted 1 line
Quoted 1 line

the FS is mounted using context= option, then what will be the

context

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly

to

Quoted 1 line
Quoted 1 line
Quoted 1 line

get the getfattr dump to realize the security namespace is not

empty

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

(this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes

to

Quoted 4 lines
Quoted 4 lines

userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types

or

Quoted 2 lines
Quoted 1 line

conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there

does

Quoted 3 lines

exist a security attribute. But these FSs are defined by genfscon.

But about FSs which do support the security namespace (like XFS), and

so

Quoted 1 line

do not have a genfscon statement associated to them they but still

have

Quoted 4 lines

a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are

they

Quoted 1 line

just empty? Things get more confusing cause I get permission denied

when

Quoted 1 line

trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 6 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

Quoted 4 lines

How about creating a file based filesystem image and mounting it with a loop device? You can mount it with context mount options or straight up and easily see changes (or no changes) to the filesystem. That way you don't have to disable selinux and reboot the whole system. You can easily experiment with whichever filesystem types you'd like.

David

Yeah, I did exactly that, but to see the actually xattr on the FS, you have to disable SELinux, cause get/setxattr works at VFS level; it queries the kernel for the xattr, and the kernel lies to it via SELinux (which has attached LSM hooks).

The manual loop mount idea is good to prevent an automatic relabel by the systemd services, but you have to disable SELinux.

author
#9 lore raw
In reply to Stephen Smalley
Quoted 41 lines · Stephen Smalley
Quoted 24 lines · dE
Quoted 12 lines · Stephen Smalley
Quoted 9 lines · dE

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

Quoted 8 lines

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 5 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

So preventing removal of security namespace is hard coded into the kernel.

I booted off sysrescuecd to check the security context -- and no, there was no security context for the file.

Thanks for clarifying.

author
#10 lore raw
In reply to Stephen Smalley
Quoted 41 lines · Stephen Smalley
Quoted 24 lines · dE
Quoted 12 lines · Stephen Smalley
Quoted 9 lines · dE

When a new file is created on a FS which supports security namespace but the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

Quoted 8 lines

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 8 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

Another question is -- what will be the default security context of a FS which does not have a genfscon statement associated to it? Does it depend on the policy or is it hard coded in the kernel?

From what I've seen, it defaults to system_u:object_r:file_t:s0

#11 lore raw
Quoted 53 lines · dE
Quoted 43 lines · Stephen Smalley
Quoted 25 lines · dE
Quoted 13 lines · Stephen Smalley
Quoted 10 lines · dE

When a new file is created on a FS which supports security namespace but
the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

Quoted 8 lines

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 8 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

Quoted 5 lines

Another question is -- what will be the default security context of a FS which does not have a genfscon statement associated to it? Does it depend on the policy or is it hard coded in the kernel?

From what I've seen, it defaults to system_u:object_r:file_t:s0

Whatever the unlabeled SID is mapped to by policy, typically unlabeled_t.

file_t is the type associated with the file SID, which is used as the default label for files that lack any security.selinux xattr value in filesystems that support xattrs. That was recently collapsed into unlabeled_t in refpolicy.

author
#12 lore raw
Quoted 57 lines · Stephen Smalley
Quoted 56 lines · dE
Quoted 43 lines · Stephen Smalley
Quoted 25 lines · dE
Quoted 13 lines · Stephen Smalley
Quoted 10 lines · dE

When a new file is created on a FS which supports security namespace but
the FS is mounted using context= option, then what will be the context of the newly created file on the FS?

I did exactly this, and next, umount and then mount the FS readonly to get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 8 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does exist a security attribute. But these FSs are defined by genfscon.

Quoted 8 lines

But about FSs which do support the security namespace (like XFS), and so do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 8 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

Another question is -- what will be the default security context of a FS which does not have a genfscon statement associated to it? Does it depend on the policy or is it hard coded in the kernel?

Quoted 7 lines
Quoted 1 line

From what I've seen, it defaults to system_u:object_r:file_t:s0

Whatever the unlabeled SID is mapped to by policy, typically unlabeled_t.

file_t is the type associated with the file SID, which is used as the default label for files that lack any security.selinux xattr value in filesystems that support xattrs. That was recently collapsed into unlabeled_t in refpolicy.

Thanks for clarifying.

#13 lore raw
In reply to dE
Quoted 63 lines · dE
Quoted 49 lines · Stephen Smalley
Quoted 35 lines · dE
Quoted 15 lines · Stephen Smalley
Quoted 6 lines · dE

When a new file is created on a FS which supports security namespace but
the FS is mounted using context= option, then what will be the context
of the newly created file on the FS?

Quoted 6 lines

I did exactly this, and next, umount and then mount the FS readonly to
get the getfattr dump to realize the security namespace is not empty (this came as a surprise).

So, can someone explain what exactly happens in this case?

The kernel lies to you ;)

Quoted 9 lines

If SELinux (or another security module that implements the inode_getsecurity and inode_listsecurity hooks) is enabled, then the security module gets to report its view of the security.* attributes to
userspace instead of whatever may or may not be stored by the filesystem. That allows SELinux to handle such requests even for filesystems that do not natively support the security.* namespace as well as remap attribute values as needed to deal with removed types or conversion from non-MLS to MLS policies or various other situations.

Yes, if I mount vfat for e.g. check the xattr using getfattr, there does
exist a security attribute. But these FSs are defined by genfscon.

But about FSs which do support the security namespace (like XFS), and so
do not have a genfscon statement associated to them they but still have a security namespace value (as reported by the kernel, which lies to userspace).

Quoted 4 lines

Question is -- are these values actually written to the FS or are they just empty? Things get more confusing cause I get permission denied when
trying to delete the security namespace values.

It shouldn't be written to the filesystem. You can check by booting with SELinux disabled (selinux=0 on the kernel command-line or /etc/selinux/config SELINUX=disabled) and then running getfattr; then the kernel will just call down to the filesystem code to fetch the attribute without any interference by the security module. However, note that this will trigger an automatic filesystem relabel upon reboot into SELinux to ensure that all files are labeled, which can take some time.

Quoted 8 lines

With regard to removing the security.selinux attributes, SELinux also prohibits that entirely; see security/selinux/hooks.c:selinux_inode_removexattr() in the kernel. So again, to do that, you'd have to boot with SELinux disabled, but it shouldn't be necessary.

Another question is -- what will be the default security context of a FS which does not have a genfscon statement associated to it? Does it depend on the policy or is it hard coded in the kernel?

Quoted 7 lines

From what I've seen, it defaults to system_u:object_r:file_t:s0
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Policy states that file system objects without labels is file_t, In latest Fedora and RHEL7 this is changed to unlabeled_t.