Skip to contentSkip to conversation

Best method for obtaining the 'sid' of a task?

DISCUSSION Timothy R. Chavez 2 participants 2 messages Jan 27, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hello,

The audit subsystem would like to collect and record security label information on a user process emitting audit messages. Due to the asynchronous nature of netlink, the kernel cannot rely on the pid sent in the kernel-bound netlink packet because the pid may have already been recycled and the information recorded to the audit log, incorrect. Furthermore, we're not permitted to package the security label with the kernel-bound message itself due to the potential of spoofing. Thus, the solution seems to be similar to that of login uid, where we package the sid with the kernel-bound netlink packet at time of delivery when we know we have the right process (because we are running as that process). This guarantees that the sid cannot be spoofed and that we're in fact sending the correct sid. Once the kernel receives this packet, it can then resolve the sid to the correct security label. One of the pitfalls of this approach may be that the sid disappears because policy is reloaded while the packet is in transit. Is this correct? I think, in terms of an IT security evaluation, we can make the assumption that this won't be done. Aside from this concern, the question I have is this:

"What is the best way to do this?"

Because I am not exposed to: task_security_struct in net/af_netlink.c, I cannot simply do a:

if (current->security)

	NETLINK_CB(skb).selinux_sid = current->security->sid;

So I did a little digging and I thought perhaps the security hook, selinux_getprocattr(), could be modified such that I can pass into it &NETLINK_CB(skb).selinux_sid and obtain the 'sid' in addition to the context since we're already obtaining the sid there. The disadvantage I see here, is that it changes the interface. I'm not sure how sensitive people are to this. Are there any alternative (possibly better) suggestions?

Thanks.

-tim

--
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 4 lines · Timothy R. Chavez

sending the correct sid. Once the kernel receives this packet, it can then resolve the sid to the correct security label. One of the pitfalls of this approach may be that the sid disappears because policy is reloaded while the packet is in transit. Is this correct?

Yes, the SID could be invalidated by a policy reload, in which case subsequent attempts to ask for its context will return the context of the unlabeled SID. Naturally, policy reload is a privileged operation.

Quoted 8 lines

"What is the best way to do this?"

Because I am not exposed to: task_security_struct in net/af_netlink.c, I cannot simply do a:

if (current->security)

	NETLINK_CB(skb).selinux_sid = current->security->sid;
Quoted 7 lines

So I did a little digging and I thought perhaps the security hook, selinux_getprocattr(), could be modified such that I can pass into it &NETLINK_CB(skb).selinux_sid and obtain the 'sid' in addition to the context since we're already obtaining the sid there. The disadvantage I see here, is that it changes the interface. I'm not sure how sensitive people are to this. Are there any alternative (possibly better) suggestions?

I'd tend to suggest a new interface for getting the current task SID and an interface for mapping it to a context, and I'm not sure it even needs to be LSM-based, given its specifity to SELinux for LSPP. I wouldn't call the field 'selinux_sid' however, and even sid may be confusing (unfortunate overlap with session id). secid may be better.

There are a couple of examples of SELinux exporting SID and context information to other parts of the kernel. One example is the ctx_sid and ctx_str fields of xfrm_sec_ctx for the IPSEC work by Trent for the SIDs associated with IPSEC SAs. That does use LSM interfaces for its purposes. Another example are some experimental patches by James Morris for iptables integration, which provide direct interfaces from SELinux for getting socket SIDs and mapping between them and contexts.

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.