Skip to contentSkip to conversation

selinux: Null-out secmark after use

PATCH In review Venkat Yekkirala 1 participant 3 messages Oct 6, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: Null-out secmark after use

This nulls out the secmark field on the skb after we are done with ALL the access checks in the postroute_last hook to handle the case where multicast packets that we send might be arriving back to us on a non-loopback device. This would cause the flow_in hook to use the secmark on the skb (ostensibly from the originating socket) as a security point context, which it isn't.

---

security/selinux/hooks.c +16 -0
@@ -3903,6 +3903,22 @@ static unsigned int selinux_ip_postroute
 		}
 		err = avc_has_perm(skb->secmark, SECINITSID_NETMSG,
 				   SECCLASS_PACKET, PACKET__FLOW_OUT, &ad);
+
+		if (skb->secmark  && skb->dev != &loopback_dev)
+			/*
+			 * Our multicast packets could get copied back
+			 * to us, arriving on a non-loopback device.
+			 * Leaving the secmark intact here will cause it
+			 * to be used as a security point context in
+			 * the flow_in hook above while it's not in fact
+			 * a security point context.
+			 *
+			 * We may be able to retain this marking if
+			 * we can reliably determine that it was a local
+			 * packet although it arrived on a non-loopback
+			 * device, in the flow_in hook above.
+			 */
+			skb->secmark = SECSID_NULL;
 	}
 out:
 	return err ? NF_DROP : NF_ACCEPT;

--
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 9 lines · Venkat Yekkirala

This nulls out the secmark field on the skb after we are done with ALL the access checks in the postroute_last hook to handle the case where multicast packets that we send might be arriving back to us on a non-loopback device. This would cause the flow_in hook to use the secmark on the skb (ostensibly from the originating socket) as a security point context, which it isn't.

Actually the sign-off should be (copied and pasted from the wrong email :):

Please disregard this patch.

--
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 9 lines · Venkat Yekkirala
Quoted 8 lines · Venkat Yekkirala

This nulls out the secmark field on the skb after we are done with ALL the access checks in the postroute_last hook to handle the case where multicast packets that we send might be arriving back to us on a non-loopback device. This would cause the flow_in hook to use the secmark on the skb (ostensibly from the originating socket) as a security point context, which it isn't.

Quoted 8 lines
Quoted 1 line

Actually the sign-off should be (copied and pasted from the wrong email :):

Please disregard this patch.

Oh yeah. But the code in fact is exactly what James would write though :)

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