All of lore.kernel.org
 help / color / mirror / Atom feed
* Default context with context mount option.
@ 2014-06-08 14:48 dE
  2014-06-08 17:46 ` Christian Evans
  2014-06-09 13:34 ` Stephen Smalley
  0 siblings, 2 replies; 14+ messages in thread
From: dE @ 2014-06-08 14:48 UTC (permalink / raw)
  To: selinux

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-08 14:48 Default context with context mount option dE
@ 2014-06-08 17:46 ` Christian Evans
  2014-06-09  5:30   ` dE
  2014-06-09 13:34 ` Stephen Smalley
  1 sibling, 1 reply; 14+ messages in thread
From: Christian Evans @ 2014-06-08 17:46 UTC (permalink / raw)
  To: selinux

On Sun, 08 Jun 2014 20:18:15 +0530
dE <de.techno@gmail.com> 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?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-08 17:46 ` Christian Evans
@ 2014-06-09  5:30   ` dE
  0 siblings, 0 replies; 14+ messages in thread
From: dE @ 2014-06-09  5:30 UTC (permalink / raw)
  To: selinux

On 06/08/14 23:16, Christian Evans wrote:
> On Sun, 08 Jun 2014 20:18:15 +0530
> dE <de.techno@gmail.com> 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?
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to Selinux-request@tycho.nsa.gov.

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-08 14:48 Default context with context mount option dE
  2014-06-08 17:46 ` Christian Evans
@ 2014-06-09 13:34 ` Stephen Smalley
  2014-06-10  8:16   ` dE
  1 sibling, 1 reply; 14+ messages in thread
From: Stephen Smalley @ 2014-06-09 13:34 UTC (permalink / raw)
  To: dE, selinux

On 06/08/2014 10:48 AM, dE 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?
> 
> 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-09 13:34 ` Stephen Smalley
@ 2014-06-10  8:16   ` dE
  2014-06-10 12:05     ` Stephen Smalley
  0 siblings, 1 reply; 14+ messages in thread
From: dE @ 2014-06-10  8:16 UTC (permalink / raw)
  To: selinux

On 06/09/14 19:04, Stephen Smalley wrote:
> On 06/08/2014 10:48 AM, dE 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?
>>
>> 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.

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-10  8:16   ` dE
@ 2014-06-10 12:05     ` Stephen Smalley
  2014-06-10 15:41       ` David Caplan
                         ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stephen Smalley @ 2014-06-10 12:05 UTC (permalink / raw)
  To: dE, selinux

On 06/10/2014 04:16 AM, dE wrote:
> On 06/09/14 19:04, Stephen Smalley wrote:
>> On 06/08/2014 10:48 AM, dE 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?
>>>
>>> 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.
> 
> 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.

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: Default context with context mount option.
  2014-06-10 12:05     ` Stephen Smalley
@ 2014-06-10 15:41       ` David Caplan
  2014-06-10 17:25         ` Stephen Smalley
  2014-06-11  7:12         ` dE
  2014-06-11  7:08       ` dE
  2014-06-11  7:29       ` dE
  2 siblings, 2 replies; 14+ messages in thread
From: David Caplan @ 2014-06-10 15:41 UTC (permalink / raw)
  To: Stephen Smalley, dE, selinux

> -----Original Message-----
> From: Selinux [mailto:selinux-bounces@tycho.nsa.gov] On Behalf Of
> Stephen Smalley
> Sent: Tuesday, June 10, 2014 8:05 AM
> To: dE; selinux@tycho.nsa.gov
> Subject: Re: Default context with context mount option.
> 
> On 06/10/2014 04:16 AM, dE wrote:
> > On 06/09/14 19:04, Stephen Smalley wrote:
> >> On 06/08/2014 10:48 AM, dE 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?
> >>>
> >>> 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.
> >
> > 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.
> 
> 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.
> 

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-10 15:41       ` David Caplan
@ 2014-06-10 17:25         ` Stephen Smalley
  2014-06-11  7:12         ` dE
  1 sibling, 0 replies; 14+ messages in thread
From: Stephen Smalley @ 2014-06-10 17:25 UTC (permalink / raw)
  To: David Caplan, dE, selinux

On 06/10/2014 11:41 AM, David Caplan wrote:
>> -----Original Message-----
>> From: Selinux [mailto:selinux-bounces@tycho.nsa.gov] On Behalf Of
>> Stephen Smalley
>> Sent: Tuesday, June 10, 2014 8:05 AM
>> To: dE; selinux@tycho.nsa.gov
>> Subject: Re: Default context with context mount option.
>>
>> On 06/10/2014 04:16 AM, dE wrote:
>>> On 06/09/14 19:04, Stephen Smalley wrote:
>>>> On 06/08/2014 10:48 AM, dE 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?
>>>>>
>>>>> 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.
>>>
>>> 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.
>>
>> 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.
>>
> 
> 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-10 12:05     ` Stephen Smalley
  2014-06-10 15:41       ` David Caplan
@ 2014-06-11  7:08       ` dE
  2014-06-11  7:29       ` dE
  2 siblings, 0 replies; 14+ messages in thread
From: dE @ 2014-06-11  7:08 UTC (permalink / raw)
  To: selinux

On 06/10/14 17:35, Stephen Smalley wrote:
> On 06/10/2014 04:16 AM, dE wrote:
>> On 06/09/14 19:04, Stephen Smalley wrote:
>>> On 06/08/2014 10:48 AM, dE 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?
>>>>
>>>> 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.
>> 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.
> 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.

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-10 15:41       ` David Caplan
  2014-06-10 17:25         ` Stephen Smalley
@ 2014-06-11  7:12         ` dE
  1 sibling, 0 replies; 14+ messages in thread
From: dE @ 2014-06-11  7:12 UTC (permalink / raw)
  To: selinux

On 06/10/14 21:11, David Caplan wrote:
>> -----Original Message-----
>> From: Selinux [mailto:selinux-bounces@tycho.nsa.gov] On Behalf Of
>> Stephen Smalley
>> Sent: Tuesday, June 10, 2014 8:05 AM
>> To: dE; selinux@tycho.nsa.gov
>> Subject: Re: Default context with context mount option.
>>
>> On 06/10/2014 04:16 AM, dE wrote:
>>> On 06/09/14 19:04, Stephen Smalley wrote:
>>>> On 06/08/2014 10:48 AM, dE 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?
>>>>>
>>>>> 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.
>>> 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.
>> 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.
>>
> 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-10 12:05     ` Stephen Smalley
  2014-06-10 15:41       ` David Caplan
  2014-06-11  7:08       ` dE
@ 2014-06-11  7:29       ` dE
  2014-06-11 12:33         ` Stephen Smalley
  2014-06-11 12:38         ` Daniel J Walsh
  2 siblings, 2 replies; 14+ messages in thread
From: dE @ 2014-06-11  7:29 UTC (permalink / raw)
  To: selinux

On 06/10/14 17:35, Stephen Smalley wrote:
> On 06/10/2014 04:16 AM, dE wrote:
>> On 06/09/14 19:04, Stephen Smalley wrote:
>>> On 06/08/2014 10:48 AM, dE 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?
>>>>
>>>> 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.
>> 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.
> 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.
>
>
>

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-11  7:29       ` dE
@ 2014-06-11 12:33         ` Stephen Smalley
  2014-06-12  1:15           ` dE
  2014-06-11 12:38         ` Daniel J Walsh
  1 sibling, 1 reply; 14+ messages in thread
From: Stephen Smalley @ 2014-06-11 12:33 UTC (permalink / raw)
  To: dE, selinux

On 06/11/2014 03:29 AM, dE wrote:
> On 06/10/14 17:35, Stephen Smalley wrote:
>> On 06/10/2014 04:16 AM, dE wrote:
>>> On 06/09/14 19:04, Stephen Smalley wrote:
>>>> On 06/08/2014 10:48 AM, dE 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?
>>>>>
>>>>> 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.
>>> 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.
>> 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.
>>
>>
>>
> 
> 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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-11  7:29       ` dE
  2014-06-11 12:33         ` Stephen Smalley
@ 2014-06-11 12:38         ` Daniel J Walsh
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel J Walsh @ 2014-06-11 12:38 UTC (permalink / raw)
  To: dE, selinux


On 06/11/2014 12:29 AM, dE wrote:
> On 06/10/14 17:35, Stephen Smalley wrote:
>> On 06/10/2014 04:16 AM, dE wrote:
>>> On 06/09/14 19:04, Stephen Smalley wrote:
>>>> On 06/08/2014 10:48 AM, dE 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?
>>>>>
>>>>> 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.
>>> 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.
>> 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.
>>
>>
>>
>
> 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
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
Policy states that file system objects without labels is file_t, In
latest Fedora and RHEL7 this is changed to unlabeled_t.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Default context with context mount option.
  2014-06-11 12:33         ` Stephen Smalley
@ 2014-06-12  1:15           ` dE
  0 siblings, 0 replies; 14+ messages in thread
From: dE @ 2014-06-12  1:15 UTC (permalink / raw)
  To: selinux

On 06/11/14 18:03, Stephen Smalley wrote:
> On 06/11/2014 03:29 AM, dE wrote:
>> On 06/10/14 17:35, Stephen Smalley wrote:
>>> On 06/10/2014 04:16 AM, dE wrote:
>>>> On 06/09/14 19:04, Stephen Smalley wrote:
>>>>> On 06/08/2014 10:48 AM, dE 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?
>>>>>>
>>>>>> 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.
>>>> 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.
>>> 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.
>>>
>>>
>>>
>> 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.

Thanks for clarifying.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-06-12  1:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-08 14:48 Default context with context mount option dE
2014-06-08 17:46 ` Christian Evans
2014-06-09  5:30   ` dE
2014-06-09 13:34 ` Stephen Smalley
2014-06-10  8:16   ` dE
2014-06-10 12:05     ` Stephen Smalley
2014-06-10 15:41       ` David Caplan
2014-06-10 17:25         ` Stephen Smalley
2014-06-11  7:12         ` dE
2014-06-11  7:08       ` dE
2014-06-11  7:29       ` dE
2014-06-11 12:33         ` Stephen Smalley
2014-06-12  1:15           ` dE
2014-06-11 12:38         ` Daniel J Walsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.