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

Timothy R. Chavez tinytim at us.ibm.com
Fri Jan 27 19:38:44 UTC 2006


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




More information about the Linux-audit mailing list