diff options
author | Eric Paris <eparis@redhat.com> | 2010-11-16 06:52:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-17 13:54:35 -0500 |
commit | 1f1aaf82825865a50cef0b4722607abb12aeee52 (patch) | |
tree | 9ab2495097fa2944404ab41bfb3038de374f5626 /security | |
parent | ee58681195bf243bafc44ca53f3c24429d096cce (diff) |
SELinux: return -ECONNREFUSED from ip_postroute to signal fatal error
The SELinux netfilter hooks just return NF_DROP if they drop a packet. We
want to signal that a drop in this hook is a permanant fatal error and is not
transient. If we do this the error will be passed back up the stack in some
places and applications will get a faster interaction that something went
wrong.
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'security')
-rw-r--r-- | security/selinux/hooks.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index d9154cf90ae1..2c145f12d991 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -4585,11 +4585,11 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex, | |||
4585 | secmark_perm = PACKET__SEND; | 4585 | secmark_perm = PACKET__SEND; |
4586 | break; | 4586 | break; |
4587 | default: | 4587 | default: |
4588 | return NF_DROP; | 4588 | return NF_DROP_ERR(-ECONNREFUSED); |
4589 | } | 4589 | } |
4590 | if (secmark_perm == PACKET__FORWARD_OUT) { | 4590 | if (secmark_perm == PACKET__FORWARD_OUT) { |
4591 | if (selinux_skb_peerlbl_sid(skb, family, &peer_sid)) | 4591 | if (selinux_skb_peerlbl_sid(skb, family, &peer_sid)) |
4592 | return NF_DROP; | 4592 | return NF_DROP_ERR(-ECONNREFUSED); |
4593 | } else | 4593 | } else |
4594 | peer_sid = SECINITSID_KERNEL; | 4594 | peer_sid = SECINITSID_KERNEL; |
4595 | } else { | 4595 | } else { |
@@ -4602,28 +4602,28 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex, | |||
4602 | ad.u.net.netif = ifindex; | 4602 | ad.u.net.netif = ifindex; |
4603 | ad.u.net.family = family; | 4603 | ad.u.net.family = family; |
4604 | if (selinux_parse_skb(skb, &ad, &addrp, 0, NULL)) | 4604 | if (selinux_parse_skb(skb, &ad, &addrp, 0, NULL)) |
4605 | return NF_DROP; | 4605 | return NF_DROP_ERR(-ECONNREFUSED); |
4606 | 4606 | ||
4607 | if (secmark_active) | 4607 | if (secmark_active) |
4608 | if (avc_has_perm(peer_sid, skb->secmark, | 4608 | if (avc_has_perm(peer_sid, skb->secmark, |
4609 | SECCLASS_PACKET, secmark_perm, &ad)) | 4609 | SECCLASS_PACKET, secmark_perm, &ad)) |
4610 | return NF_DROP; | 4610 | return NF_DROP_ERR(-ECONNREFUSED); |
4611 | 4611 | ||
4612 | if (peerlbl_active) { | 4612 | if (peerlbl_active) { |
4613 | u32 if_sid; | 4613 | u32 if_sid; |
4614 | u32 node_sid; | 4614 | u32 node_sid; |
4615 | 4615 | ||
4616 | if (sel_netif_sid(ifindex, &if_sid)) | 4616 | if (sel_netif_sid(ifindex, &if_sid)) |
4617 | return NF_DROP; | 4617 | return NF_DROP_ERR(-ECONNREFUSED); |
4618 | if (avc_has_perm(peer_sid, if_sid, | 4618 | if (avc_has_perm(peer_sid, if_sid, |
4619 | SECCLASS_NETIF, NETIF__EGRESS, &ad)) | 4619 | SECCLASS_NETIF, NETIF__EGRESS, &ad)) |
4620 | return NF_DROP; | 4620 | return NF_DROP_ERR(-ECONNREFUSED); |
4621 | 4621 | ||
4622 | if (sel_netnode_sid(addrp, family, &node_sid)) | 4622 | if (sel_netnode_sid(addrp, family, &node_sid)) |
4623 | return NF_DROP; | 4623 | return NF_DROP_ERR(-ECONNREFUSED); |
4624 | if (avc_has_perm(peer_sid, node_sid, | 4624 | if (avc_has_perm(peer_sid, node_sid, |
4625 | SECCLASS_NODE, NODE__SENDTO, &ad)) | 4625 | SECCLASS_NODE, NODE__SENDTO, &ad)) |
4626 | return NF_DROP; | 4626 | return NF_DROP_ERR(-ECONNREFUSED); |
4627 | } | 4627 | } |
4628 | 4628 | ||
4629 | return NF_ACCEPT; | 4629 | return NF_ACCEPT; |