Skip to contentSkip to conversation

A few clarifications - SID, Precondition functions

DISCUSSION Vikram K 4 participants 6 messages Oct 7, 2003 – Oct 8, 2003 SELinux security module

lore
Share & tools
lore

Vikram K

author
#0 lore raw

Hello,

We had a few doubts regarding the SELinux kernel code.

1. The need for having a SID ( instead of having a struct context* ) in
each of the *_security_struct structures. (* = task, inode, etc.) As we
see it, the SID is just a means of referring to the corresponding context
structure and seems to have no other utility.

2. If once an object is created, what would happen if we change its SID.
Is it at all safe to change the SID?
(maybe because the struct context to which it was referring has a
few fields changed and this structure is being referred to by other
objects)

3. There is a lot of documentation about "Precondition Functions" which
are called whenever an SID needs to be dereferenced. This would help in
initializing security fields of objects that were created before the
SELinux module is loaded (or starts - if SELinux is built into the kernel)
We couldn't find these precondition functions in the code, though. Can
anybody tell us if they have been implemented and if yes, then in which
version?

Thanks in advance,
Vikram
Kamalneet

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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

#1 lore raw
Quoted 11 lines · Vikram K

Hello,

We had a few doubts regarding the SELinux kernel code.

1. The need for having a SID ( instead of having a struct context* ) in
each of the *_security_struct structures. (* = task, inode, etc.) As we
see it, the SID is just a means of referring to the corresponding context
structure and seems to have no other utility.

You might want to read the Flask architecture paper available from http://www.nsa.gov/selinux/background.html to understand the original motivation for SIDs. However, I'll grant that the elimination of SIDs from the userspace API makes them a less useful abstraction, so it might be reasonable to investigate replacing them with direct references to context structures (while continuing to keep the structure definition private to the security server to encapsulate the policy).

Quoted 8 lines

2. If once an object is created, what would happen if we change its SID.
Is it at all safe to change the SID?
(maybe because the struct context to which it was referring has a
few fields changed and this structure is being referred to by other
objects)

Do you mean change the SID of the object or change the context associated with the SID? Two different concepts. Changing the SID of an object is supported, at least for certain classes of objects, although revocation is not completely implemented yet (e.g. memory-mapped files). setxattr can be used to change the context of a file, and /proc/pid/attr/exec can be used to change the context of a process when it performs an exec.

Quoted 5 lines

3. There is a lot of documentation about "Precondition Functions" which
are called whenever an SID needs to be dereferenced. This would help in
initializing security fields of objects that were

Quoted 8 lines

created before the
SELinux module is loaded (or starts - if SELinux is built into the kernel)
We couldn't find these precondition functions in the code, though. Can
anybody tell us if they have been implemented and if yes, then in which
version?

The module report is out-of-date with respect to the current implementation; the SELinux module underwent many significant changes as part of preparing it for mainline inclusion. The precondition functions were eliminated at the recommendation of the kernel developers, and replaced by a combination of early initialization for the SELinux module and more explicit initialization hooks.

Signature · 8 lines
Stephen Smalley <[email protected]>
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 10 lines · Stephen Smalley
Quoted 7 lines · Vikram K

1. The need for having a SID ( instead of having a struct context* ) in
each of the *_security_struct structures. (* = task, inode, etc.) As we
see it, the SID is just a means of referring to the corresponding context
structure and seems to have no other utility.

Quoted 7 lines

You might want to read the Flask architecture paper available from http://www.nsa.gov/selinux/background.html to understand the original motivation for SIDs. However, I'll grant that the elimination of SIDs from the userspace API makes them a less useful abstraction, so it might be reasonable to investigate replacing them with direct references to context structures (while continuing to keep the structure definition private to the security server to encapsulate the policy).

It's not clear to me that there would be any e.g. performance advantage from doing this. There is a potential to eliminate sidtab lookups, although these are generally cached via the AVC and do not significantly impact on performance.

It would be a major job to remove SIDs from the kernel code, and given the risk of introducing bugs, there would need to be strong justification for this kind of change.

- James

Signature · 9 lines
James Morris
<[email protected]>



--
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.
author
#3 lore raw

Before trying to get further clarifications, let us articulate what we are trying to do and the group can comment on it. We are trying to work out a design and an implementation for using loadable policy modules. Our earlier effort of trying to build into SELinux a specific policy enforcement mechanism (Biba Integrity) seemed to be of not much use as the group had itself pointed out. Therefore, we thought of generalizing this process and instead of hardcoding a particular model into the existing code, we would add hooks that would be implemented by a loadable policy module (similar to the way in which LSM works). Particular policies can then be implemented in such modules. Such a framework, we felt, could be useful for indirectly extending the policy language by implementing these extensions as modules themselves. This is a highly unconfirmed statement, though, but we felt motivated enough to proceed.

This idea is similar to the idea proposed by David Caplan in his mail to the group and there we found further motivations for proceeding with what we were doing. We have a tentative design which we have started implementing and in this context we need to know the following.

These loadable modules would want to add its own security attributes/fields in kernel objects. We do this by adding a void* pointer into the context structure. For the time being let us assume that there would be only one module loaded (if we would like more modules to be loaded a module can "multiplex" this pointer to other modules). This pointer would have to be filled in by the module itself in one of its hook function implementation.

Issues arise when kernel objects created before the loading of the policy module have to be filled in with security attributes. If the module, say in its init function, does this for existing objects by filling in the void* pointer in whatever manner it pleases, it changes the context structure of each object. This would not have been a problem if there was no sharing of context structures. It seems, though, that sharing does happen and a context structure can be referred to by the same SID in different places.

Thus we cannot blindly change a context structure.We would rather have to create a copy and make changes in the copy and set the SID of this copy in the appropriate *_security_struct structure.

We would like to know if doing this would be safe.

Thanks in advance
Vikram

James Morris <[email protected]> wrote:

Quoted 10 lines · Stephen Smalley
Quoted 7 lines · Vikram K

1. The need for having a SID ( instead of having a struct context* ) in
each of the *_security_struct structures. (* = task, inode, etc.) As we
see it, the SID is just a means of referring to the corresponding context
structure and seems to have no other utility.

Quoted 7 lines

You might want to read the Flask architecture paper available from http://www.nsa.gov/selinux/background.html to understand the original motivation for SIDs. However, I'll grant that the elimination of SIDs from the userspace API makes them a less useful abstraction, so it might be reasonable to investigate replacing them with direct references to context structures (while continuing to keep the structure definition private to the security server to encapsulate the policy).

It's not clear to me that there would be any e.g. performance advantage from doing this. There is a potential to eliminate sidtab lookups, although these are generally cached via the AVC and do not significantly impact on performance.

It would be a major job to remove SIDs from the kernel code, and given the risk of introducing bugs, there would need to be strong justification for this kind of change.

- James

Signature · 13 lines
James Morris




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

---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
#4 lore raw
Quoted 8 lines · Vikram K

Therefore, we thought of generalizing this process and instead of hardcoding a particular model into the existing code, we would add hooks that would be implemented by a loadable policy module (similar to the way in which LSM works). Particular policies can then be implemented in such modules. Such a framework, we felt, could be useful for indirectly extending the policy language by implementing these extensions as modules themselves. This is a highly unconfirmed statement, though, but we felt motivated enough to proceed.

I think that this is likely the wrong approach. Rather than creating yet another infrastructure within SELinux for loadable policy modules (which is really what LSM is for), I'd suggest working on creating a real module abstraction in the policy language and implementing support for policy modules that can be reasonably bounded and can be checked for violations of properties of the base policy. I'd suggest reading the following paper as background:
T. Fraser and L. Badger, _Ensuring Continuity during Dynamic Security Policy Reconfiguration in DTE_, Proceedings of the 1998 IEEE Symposium on Security and Privacy,
http://www.computer.org/proceedings/s&p/8386/83860015abs.htm

Signature · 8 lines
Stephen Smalley <[email protected]>
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.
#5 lore raw
Quoted 5 lines · On Wednesday, October 08, 2003 9:39 AM,, [email protected] wrote:

Subject: Re: A few clarifications - SID, Precondition functions I think that this is likely the wrong approach. Rather than creating yet another infrastructure within SELinux for loadable policy modules (which is really what LSM is for), I'd suggest working on creating a real module abstraction in the policy language and

Quoted 8 lines

implementing support
for policy modules that can be reasonably bounded and can be checked for violations of properties of the base policy. I'd suggest reading the following paper as background:
T. Fraser and L. Badger, _Ensuring Continuity during Dynamic Security Policy Reconfiguration in DTE_, Proceedings of the 1998 IEEE Symposium on Security and Privacy,
http://www.computer.org/proceedings/s&p/8386/83860015abs.htm

As Dave Caplan mentioned in a earlier message, we're currently designing an enhancement to do policy modules, which we plan to implement once we finish the conditional policy extensions.

Frank

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