* [RFC PATCH v2 0/2] Labeled networking core stack changes for 2.6.25
@ 2008-01-07 17:47 Paul Moore
2008-01-07 17:47 ` [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone() Paul Moore
2008-01-07 17:47 ` [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks Paul Moore
0 siblings, 2 replies; 8+ messages in thread
From: Paul Moore @ 2008-01-07 17:47 UTC (permalink / raw)
To: netdev; +Cc: davem
Take #2 ...
Once again, two patches. The first should be familiar as it is the same patch
as before with feedback taken into account. The second patch is most likely
new to the netdev crowd as it consists of the SELinux changes necessary to
implement the network ingress/egress controls I talked about last week after
the previous approach was rejected.
You will note that the ingress/egress controls are now completely contained
within the LSM/SELinux code using the skb->dst->xfrm approach mentioned last
Friday. For those of you who want/need more context when looking at the
second patch, you can find the rest of the patches here:
* git://git.infradead.org/users/pcmoore/lblnet-2.6_testing
* http://git.infradead.org/?p=users/pcmoore/lblnet-2.6_testing
Just as before, I'm posting these patches here for review and hopefully an
'Acked-by', not inclusion into net-2.6.25. If these patches are acceptable
then they will pushed upstream with the rest of the changes when 2.6.25 is
ready.
Thanks.
--
paul moore
linux security @ hp
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone()
2008-01-07 17:47 [RFC PATCH v2 0/2] Labeled networking core stack changes for 2.6.25 Paul Moore
@ 2008-01-07 17:47 ` Paul Moore
2008-01-07 21:11 ` James Morris
2008-01-08 6:01 ` David Miller
2008-01-07 17:47 ` [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks Paul Moore
1 sibling, 2 replies; 8+ messages in thread
From: Paul Moore @ 2008-01-07 17:47 UTC (permalink / raw)
To: netdev; +Cc: davem
Both NetLabel and SELinux (other LSMs may grow to use it as well) rely on the
'iif' field to determine the receiving network interface of inbound packets.
Unfortunately, at present this field is not preserved across a skb clone
operation which can lead to garbage values if the cloned skb is sent back
through the network stack. This patch corrects this problem by properly
copying the 'iif' field in __skb_clone() and removing the 'iif' field
assignment from skb_act_clone() since it is no longer needed.
Also, while we are here, put the assignments in the same order as the offsets
to reduce cacheline bounces.
Signed-off-by: Paul Moore <paul.moore@hp.com>
---
include/net/sch_generic.h | 1 -
net/core/skbuff.c | 11 ++++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index c926551..4c3b351 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -325,7 +325,6 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask)
n->tc_verd = SET_TC_VERD(n->tc_verd, 0);
n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
- n->iif = skb->iif;
}
return n;
}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5b4ce9b..b628377 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -416,16 +416,17 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
C(len);
C(data_len);
C(mac_len);
- n->cloned = 1;
n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
+ n->cloned = 1;
n->nohdr = 0;
n->destructor = NULL;
- C(truesize);
- atomic_set(&n->users, 1);
- C(head);
- C(data);
+ C(iif);
C(tail);
C(end);
+ C(head);
+ C(data);
+ C(truesize);
+ atomic_set(&n->users, 1);
atomic_inc(&(skb_shinfo(skb)->dataref));
skb->cloned = 1;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks
2008-01-07 17:47 [RFC PATCH v2 0/2] Labeled networking core stack changes for 2.6.25 Paul Moore
2008-01-07 17:47 ` [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone() Paul Moore
@ 2008-01-07 17:47 ` Paul Moore
2008-01-08 6:02 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Paul Moore @ 2008-01-07 17:47 UTC (permalink / raw)
To: netdev; +Cc: davem
This patch implements packet ingress/egress controls for SELinux which allow
SELinux security policy to control the flow of all IPv4 and IPv6 packets into
and out of the system. Currently SELinux does not have proper control over
forwarded packets and this patch corrects this problem.
Special thanks to Venkat Yekkirala <vyekkirala@trustedcs.com> whose earlier
work on this topic eventually led to this patch.
Signed-off-by: Paul Moore <paul.moore@hp.com>
---
security/selinux/hooks.c | 371 ++++++++++++++++++++++++++++++++--------------
1 files changed, 256 insertions(+), 115 deletions(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d16f586..1d7eed7 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -12,8 +12,8 @@
* Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
* Copyright (C) 2004-2005 Trusted Computer Solutions, Inc.
* <dgoeddel@trustedcs.com>
- * Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
- * Paul Moore, <paul.moore@hp.com>
+ * Copyright (C) 2006, 2007 Hewlett-Packard Development Company, L.P.
+ * Paul Moore <paul.moore@hp.com>
* Copyright (C) 2007 Hitachi Software Engineering Co., Ltd.
* Yuichi Nakamura <ynakam@hitachisoft.jp>
*
@@ -3608,6 +3608,29 @@ static int selinux_socket_unix_may_send(struct socket *sock,
return 0;
}
+static int selinux_inet_sys_rcv_skb(int ifindex, char *addrp, u16 family,
+ u32 peer_sid,
+ struct avc_audit_data *ad)
+{
+ int err;
+ u32 if_sid;
+ u32 node_sid;
+
+ err = sel_netif_sid(ifindex, &if_sid);
+ if (err)
+ return err;
+ err = avc_has_perm(peer_sid, if_sid,
+ SECCLASS_NETIF, NETIF__INGRESS, ad);
+ if (err)
+ return err;
+
+ err = sel_netnode_sid(addrp, family, &node_sid);
+ if (err)
+ return err;
+ return avc_has_perm(peer_sid, node_sid,
+ SECCLASS_NODE, NODE__RECVFROM, ad);
+}
+
static int selinux_sock_rcv_skb_iptables_compat(struct sock *sk,
struct sk_buff *skb,
struct avc_audit_data *ad,
@@ -3748,6 +3771,10 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
err = selinux_skb_peerlbl_sid(skb, family, &peer_sid);
if (err)
return err;
+ err = selinux_inet_sys_rcv_skb(skb->iif, addrp, family,
+ peer_sid, &ad);
+ if (err)
+ return err;
err = avc_has_perm(sk_sid, peer_sid, SECCLASS_PEER,
PEER__RECV, &ad);
}
@@ -3964,151 +3991,238 @@ out:
#ifdef CONFIG_NETFILTER
-static int selinux_ip_postroute_last_compat(struct sock *sk,
- struct net_device *dev,
- struct avc_audit_data *ad,
- u16 family,
- char *addrp)
+static unsigned int selinux_ip_forward(struct sk_buff *skb, int ifindex,
+ u16 family)
{
- int err = 0;
- u32 netif_perm, node_perm, node_sid, if_sid, send_perm = 0;
- struct socket *sock;
- struct inode *inode;
- struct inode_security_struct *isec;
+ if (!selinux_policycap_netpeer)
+ return NF_ACCEPT;
- sock = sk->sk_socket;
- if (!sock)
- goto out;
+ if (netlbl_enabled() || selinux_xfrm_enabled()) {
+ char *addrp;
+ u32 peer_sid;
+ struct avc_audit_data ad;
- inode = SOCK_INODE(sock);
- if (!inode)
- goto out;
+ AVC_AUDIT_DATA_INIT(&ad, NET);
+ ad.u.net.netif = ifindex;
+ ad.u.net.family = family;
+ if (selinux_parse_skb(skb, &ad, &addrp, 1, NULL) != 0)
+ return NF_DROP;
+
+ if (selinux_skb_peerlbl_sid(skb, family, &peer_sid) != 0)
+ return NF_DROP;
+ if (selinux_inet_sys_rcv_skb(ifindex, addrp, family,
+ peer_sid, &ad) != 0)
+ return NF_DROP;
+ }
- isec = inode->i_security;
-
- err = sel_netif_sid(dev->ifindex, &if_sid);
- if (err)
- goto out;
+ return NF_ACCEPT;
+}
+
+static unsigned int selinux_ipv4_forward(unsigned int hooknum,
+ struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
+{
+ return selinux_ip_forward(skb, in->ifindex, PF_INET);
+}
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+static unsigned int selinux_ipv6_forward(unsigned int hooknum,
+ struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
+{
+ return selinux_ip_forward(skb, in->ifindex, PF_INET6);
+}
+#endif /* IPV6 */
+
+static int selinux_ip_postroute_iptables_compat(struct sock *sk,
+ int ifindex,
+ struct avc_audit_data *ad,
+ u16 family, char *addrp)
+{
+ int err;
+ struct sk_security_struct *sksec = sk->sk_security;
+ u16 sk_class;
+ u32 netif_perm, node_perm, send_perm;
+ u32 port_sid, node_sid, if_sid, sk_sid;
+
+ sk_sid = sksec->sid;
+ sk_class = sksec->sclass;
- switch (isec->sclass) {
+ switch (sk_class) {
case SECCLASS_UDP_SOCKET:
netif_perm = NETIF__UDP_SEND;
node_perm = NODE__UDP_SEND;
send_perm = UDP_SOCKET__SEND_MSG;
break;
-
case SECCLASS_TCP_SOCKET:
netif_perm = NETIF__TCP_SEND;
node_perm = NODE__TCP_SEND;
send_perm = TCP_SOCKET__SEND_MSG;
break;
-
case SECCLASS_DCCP_SOCKET:
netif_perm = NETIF__DCCP_SEND;
node_perm = NODE__DCCP_SEND;
send_perm = DCCP_SOCKET__SEND_MSG;
break;
-
default:
netif_perm = NETIF__RAWIP_SEND;
node_perm = NODE__RAWIP_SEND;
+ send_perm = 0;
break;
}
- err = avc_has_perm(isec->sid, if_sid, SECCLASS_NETIF, netif_perm, ad);
+ err = sel_netif_sid(ifindex, &if_sid);
if (err)
- goto out;
+ return err;
+ err = avc_has_perm(sk_sid, if_sid, SECCLASS_NETIF, netif_perm, ad);
+ return err;
err = sel_netnode_sid(addrp, family, &node_sid);
if (err)
- goto out;
-
- err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, node_perm, ad);
+ return err;
+ err = avc_has_perm(sk_sid, node_sid, SECCLASS_NODE, node_perm, ad);
if (err)
- goto out;
+ return err;
- if (send_perm) {
- u32 port_sid;
-
- err = security_port_sid(sk->sk_family,
- sk->sk_type,
- sk->sk_protocol,
- ntohs(ad->u.net.dport),
- &port_sid);
- if (err)
- goto out;
+ if (send_perm != 0)
+ return 0;
+
+ err = security_port_sid(sk->sk_family, sk->sk_type,
+ sk->sk_protocol, ntohs(ad->u.net.dport),
+ &port_sid);
+ if (err)
+ return err;
+ return avc_has_perm(sk_sid, port_sid, sk_class, send_perm, ad);
+}
+
+static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
+ int ifindex,
+ struct avc_audit_data *ad,
+ u16 family,
+ char *addrp,
+ u8 proto)
+{
+ struct sock *sk = skb->sk;
+ struct sk_security_struct *sksec;
+
+ if (sk == NULL)
+ return NF_ACCEPT;
+ sksec = sk->sk_security;
- err = avc_has_perm(isec->sid, port_sid, isec->sclass,
- send_perm, ad);
+ if (selinux_compat_net) {
+ if (selinux_ip_postroute_iptables_compat(skb->sk, ifindex,
+ ad, family, addrp))
+ return NF_DROP;
+ } else {
+ if (avc_has_perm(sksec->sid, skb->secmark,
+ SECCLASS_PACKET, PACKET__SEND, ad))
+ return NF_DROP;
}
-out:
- return err;
+
+ if (selinux_policycap_netpeer)
+ if (selinux_xfrm_postroute_last(sksec->sid, skb, ad, proto))
+ return NF_DROP;
+
+ return NF_ACCEPT;
}
-static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
- struct sk_buff *skb,
- const struct net_device *in,
- const struct net_device *out,
- int (*okfn)(struct sk_buff *),
- u16 family)
+static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
+ u16 family)
{
- char *addrp;
- int err = 0;
+ u32 peer_sid;
struct sock *sk;
struct avc_audit_data ad;
- struct net_device *dev = (struct net_device *)out;
- struct sk_security_struct *sksec;
+ char *addrp;
u8 proto;
-
- sk = skb->sk;
- if (!sk)
- goto out;
-
- sksec = sk->sk_security;
+ u8 secmark_active;
+ u8 peerlbl_active;
AVC_AUDIT_DATA_INIT(&ad, NET);
- ad.u.net.netif = dev->ifindex;
+ ad.u.net.netif = ifindex;
ad.u.net.family = family;
+ if (selinux_parse_skb(skb, &ad, &addrp, 0, &proto))
+ return NF_DROP;
- err = selinux_parse_skb(skb, &ad, &addrp, 0, &proto);
- if (err)
- goto out;
-
- if (selinux_compat_net)
- err = selinux_ip_postroute_last_compat(sk, dev, &ad,
- family, addrp);
- else
- err = avc_has_perm(sksec->sid, skb->secmark, SECCLASS_PACKET,
- PACKET__SEND, &ad);
+ /* If any sort of compatibility mode is enabled then handoff processing
+ * to the selinux_ip_postroute_compat() function to deal with the
+ * special handling. We do this in an attempt to keep this function
+ * as fast and as clean as possible. */
+ if (selinux_compat_net || !selinux_policycap_netpeer)
+ return selinux_ip_postroute_compat(skb, ifindex, &ad,
+ family, addrp, proto);
+
+ /* If skb->dst->xfrm is non-NULL then the packet is undergoing an IPsec
+ * packet transformation so allow the packet to pass without any checks
+ * since we'll have another chance to perform access control checks
+ * when the packet is on it's final way out. */
+ if (skb->dst->xfrm != NULL)
+ return NF_ACCEPT;
+
+ secmark_active = selinux_secmark_enabled();
+ peerlbl_active = netlbl_enabled() || selinux_xfrm_enabled();
+ if (!secmark_active && !peerlbl_active)
+ return NF_ACCEPT;
+
+ /* if the packet is locally generated (skb->sk != NULL) then use the
+ * socket's label as the peer label, otherwise the packet is being
+ * forwarded through this system and we need to fetch the peer label
+ * directly from the packet */
+ sk = skb->sk;
+ if (sk) {
+ struct sk_security_struct *sksec = sk->sk_security;
+ peer_sid = sksec->sid;
+ } else {
+ if (selinux_skb_peerlbl_sid(skb, family, &peer_sid))
+ return NF_DROP;
+ }
- if (err)
- goto out;
+ if (secmark_active)
+ if (avc_has_perm(peer_sid, skb->secmark,
+ SECCLASS_PACKET, PACKET__SEND, &ad))
+ return NF_DROP;
+
+ if (peerlbl_active) {
+ u32 if_sid;
+ u32 node_sid;
+
+ if (sel_netif_sid(ifindex, &if_sid))
+ return NF_DROP;
+ if (avc_has_perm(peer_sid, if_sid,
+ SECCLASS_NETIF, NETIF__EGRESS, &ad))
+ return NF_DROP;
+
+ if (sel_netnode_sid(addrp, family, &node_sid))
+ return NF_DROP;
+ if (avc_has_perm(peer_sid, node_sid,
+ SECCLASS_NODE, NODE__SENDTO, &ad))
+ return NF_DROP;
+ }
- err = selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto);
-out:
- return err ? NF_DROP : NF_ACCEPT;
+ return NF_ACCEPT;
}
-static unsigned int selinux_ipv4_postroute_last(unsigned int hooknum,
- struct sk_buff *skb,
- const struct net_device *in,
- const struct net_device *out,
- int (*okfn)(struct sk_buff *))
+static unsigned int selinux_ipv4_postroute(unsigned int hooknum,
+ struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
{
- return selinux_ip_postroute_last(hooknum, skb, in, out, okfn, PF_INET);
+ return selinux_ip_postroute(skb, out->ifindex, PF_INET);
}
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-
-static unsigned int selinux_ipv6_postroute_last(unsigned int hooknum,
- struct sk_buff *skb,
- const struct net_device *in,
- const struct net_device *out,
- int (*okfn)(struct sk_buff *))
+static unsigned int selinux_ipv6_postroute(unsigned int hooknum,
+ struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ int (*okfn)(struct sk_buff *))
{
- return selinux_ip_postroute_last(hooknum, skb, in, out, okfn, PF_INET6);
+ return selinux_ip_postroute(skb, out->ifindex, PF_INET6);
}
-
#endif /* IPV6 */
#endif /* CONFIG_NETFILTER */
@@ -5093,22 +5207,40 @@ security_initcall(selinux_init);
#if defined(CONFIG_NETFILTER)
-static struct nf_hook_ops selinux_ipv4_op = {
- .hook = selinux_ipv4_postroute_last,
- .owner = THIS_MODULE,
- .pf = PF_INET,
- .hooknum = NF_IP_POST_ROUTING,
- .priority = NF_IP_PRI_SELINUX_LAST,
+static struct nf_hook_ops selinux_ipv4_ops[] = {
+ {
+ .hook = selinux_ipv4_postroute,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_POST_ROUTING,
+ .priority = NF_IP_PRI_SELINUX_LAST,
+ },
+ {
+ .hook = selinux_ipv4_forward,
+ .owner = THIS_MODULE,
+ .pf = PF_INET,
+ .hooknum = NF_IP_FORWARD,
+ .priority = NF_IP_PRI_SELINUX_FIRST,
+ }
};
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-static struct nf_hook_ops selinux_ipv6_op = {
- .hook = selinux_ipv6_postroute_last,
- .owner = THIS_MODULE,
- .pf = PF_INET6,
- .hooknum = NF_IP6_POST_ROUTING,
- .priority = NF_IP6_PRI_SELINUX_LAST,
+static struct nf_hook_ops selinux_ipv6_ops[] = {
+ {
+ .hook = selinux_ipv6_postroute,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_POST_ROUTING,
+ .priority = NF_IP6_PRI_SELINUX_LAST,
+ },
+ {
+ .hook = selinux_ipv6_forward,
+ .owner = THIS_MODULE,
+ .pf = PF_INET6,
+ .hooknum = NF_IP6_FORWARD,
+ .priority = NF_IP6_PRI_SELINUX_FIRST,
+ }
};
#endif /* IPV6 */
@@ -5116,22 +5248,27 @@ static struct nf_hook_ops selinux_ipv6_op = {
static int __init selinux_nf_ip_init(void)
{
int err = 0;
+ u32 iter;
if (!selinux_enabled)
goto out;
printk(KERN_DEBUG "SELinux: Registering netfilter hooks\n");
- err = nf_register_hook(&selinux_ipv4_op);
- if (err)
- panic("SELinux: nf_register_hook for IPv4: error %d\n", err);
+ for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++) {
+ err = nf_register_hook(&selinux_ipv4_ops[iter]);
+ if (err)
+ panic("SELinux: nf_register_hook for IPv4: error %d\n",
+ err);
+ }
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-
- err = nf_register_hook(&selinux_ipv6_op);
- if (err)
- panic("SELinux: nf_register_hook for IPv6: error %d\n", err);
-
+ for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++) {
+ err = nf_register_hook(&selinux_ipv6_ops[iter]);
+ if (err)
+ panic("SELinux: nf_register_hook for IPv6: error %d\n",
+ err);
+ }
#endif /* IPV6 */
out:
@@ -5143,11 +5280,15 @@ __initcall(selinux_nf_ip_init);
#ifdef CONFIG_SECURITY_SELINUX_DISABLE
static void selinux_nf_ip_exit(void)
{
+ u32 iter;
+
printk(KERN_DEBUG "SELinux: Unregistering netfilter hooks\n");
- nf_unregister_hook(&selinux_ipv4_op);
+ for (iter = 0; iter < ARRAY_SIZE(selinux_ipv4_ops); iter++)
+ nf_unregister_hook(&selinux_ipv4_ops[iter]);
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
- nf_unregister_hook(&selinux_ipv6_op);
+ for (iter = 0; iter < ARRAY_SIZE(selinux_ipv6_ops); iter++)
+ nf_unregister_hook(&selinux_ipv6_ops[iter]);
#endif /* IPV6 */
}
#endif
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone()
2008-01-07 17:47 ` [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone() Paul Moore
@ 2008-01-07 21:11 ` James Morris
2008-01-08 5:48 ` David Miller
2008-01-08 6:01 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: James Morris @ 2008-01-07 21:11 UTC (permalink / raw)
To: Paul Moore; +Cc: netdev, David S. Miller
On Mon, 7 Jan 2008, Paul Moore wrote:
> Both NetLabel and SELinux (other LSMs may grow to use it as well) rely on the
> 'iif' field to determine the receiving network interface of inbound packets.
> Unfortunately, at present this field is not preserved across a skb clone
> operation which can lead to garbage values if the cloned skb is sent back
> through the network stack. This patch corrects this problem by properly
> copying the 'iif' field in __skb_clone() and removing the 'iif' field
> assignment from skb_act_clone() since it is no longer needed.
>
> Also, while we are here, put the assignments in the same order as the offsets
> to reduce cacheline bounces.
>
> Signed-off-by: Paul Moore <paul.moore@hp.com>
Dave, perhaps this one should pushed to Linus now as a bugfix?
> ---
>
> include/net/sch_generic.h | 1 -
> net/core/skbuff.c | 11 ++++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index c926551..4c3b351 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -325,7 +325,6 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask)
> n->tc_verd = SET_TC_VERD(n->tc_verd, 0);
> n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
> n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
> - n->iif = skb->iif;
> }
> return n;
> }
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 5b4ce9b..b628377 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -416,16 +416,17 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
> C(len);
> C(data_len);
> C(mac_len);
> - n->cloned = 1;
> n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
> + n->cloned = 1;
> n->nohdr = 0;
> n->destructor = NULL;
> - C(truesize);
> - atomic_set(&n->users, 1);
> - C(head);
> - C(data);
> + C(iif);
> C(tail);
> C(end);
> + C(head);
> + C(data);
> + C(truesize);
> + atomic_set(&n->users, 1);
>
> atomic_inc(&(skb_shinfo(skb)->dataref));
> skb->cloned = 1;
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone()
2008-01-07 21:11 ` James Morris
@ 2008-01-08 5:48 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2008-01-08 5:48 UTC (permalink / raw)
To: jmorris; +Cc: paul.moore, netdev
From: James Morris <jmorris@namei.org>
Date: Tue, 8 Jan 2008 08:11:11 +1100 (EST)
> On Mon, 7 Jan 2008, Paul Moore wrote:
>
> > Both NetLabel and SELinux (other LSMs may grow to use it as well) rely on the
> > 'iif' field to determine the receiving network interface of inbound packets.
> > Unfortunately, at present this field is not preserved across a skb clone
> > operation which can lead to garbage values if the cloned skb is sent back
> > through the network stack. This patch corrects this problem by properly
> > copying the 'iif' field in __skb_clone() and removing the 'iif' field
> > assignment from skb_act_clone() since it is no longer needed.
> >
> > Also, while we are here, put the assignments in the same order as the offsets
> > to reduce cacheline bounces.
> >
> > Signed-off-by: Paul Moore <paul.moore@hp.com>
>
> Dave, perhaps this one should pushed to Linus now as a bugfix?
Probably we should, yes.
Ok, that's what I'll do.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone()
2008-01-07 17:47 ` [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone() Paul Moore
2008-01-07 21:11 ` James Morris
@ 2008-01-08 6:01 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2008-01-08 6:01 UTC (permalink / raw)
To: paul.moore; +Cc: netdev
From: Paul Moore <paul.moore@hp.com>
Date: Mon, 07 Jan 2008 12:47:42 -0500
> Both NetLabel and SELinux (other LSMs may grow to use it as well) rely on the
> 'iif' field to determine the receiving network interface of inbound packets.
> Unfortunately, at present this field is not preserved across a skb clone
> operation which can lead to garbage values if the cloned skb is sent back
> through the network stack. This patch corrects this problem by properly
> copying the 'iif' field in __skb_clone() and removing the 'iif' field
> assignment from skb_act_clone() since it is no longer needed.
>
> Also, while we are here, put the assignments in the same order as the offsets
> to reduce cacheline bounces.
>
> Signed-off-by: Paul Moore <paul.moore@hp.com>
Applied to net-2.6 and I think I'll toss this into -stable as well.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks
2008-01-07 17:47 ` [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks Paul Moore
@ 2008-01-08 6:02 ` David Miller
2008-01-08 13:13 ` Paul Moore
0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2008-01-08 6:02 UTC (permalink / raw)
To: paul.moore; +Cc: netdev
From: Paul Moore <paul.moore@hp.com>
Date: Mon, 07 Jan 2008 12:47:48 -0500
> This patch implements packet ingress/egress controls for SELinux which allow
> SELinux security policy to control the flow of all IPv4 and IPv6 packets into
> and out of the system. Currently SELinux does not have proper control over
> forwarded packets and this patch corrects this problem.
>
> Special thanks to Venkat Yekkirala <vyekkirala@trustedcs.com> whose earlier
> work on this topic eventually led to this patch.
>
> Signed-off-by: Paul Moore <paul.moore@hp.com>
This looks fine, and since it doesn't touch anything under net/
please feel free to merge it however you like.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks
2008-01-08 6:02 ` David Miller
@ 2008-01-08 13:13 ` Paul Moore
0 siblings, 0 replies; 8+ messages in thread
From: Paul Moore @ 2008-01-08 13:13 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Tuesday 08 January 2008 1:02:11 am David Miller wrote:
> From: Paul Moore <paul.moore@hp.com>
> Date: Mon, 07 Jan 2008 12:47:48 -0500
>
> > This patch implements packet ingress/egress controls for SELinux which
> > allow SELinux security policy to control the flow of all IPv4 and IPv6
> > packets into and out of the system. Currently SELinux does not have
> > proper control over forwarded packets and this patch corrects this
> > problem.
> >
> > Special thanks to Venkat Yekkirala <vyekkirala@trustedcs.com> whose
> > earlier work on this topic eventually led to this patch.
> >
> > Signed-off-by: Paul Moore <paul.moore@hp.com>
>
> This looks fine, and since it doesn't touch anything under net/
> please feel free to merge it however you like.
Thanks. For the record, I believe the plan is that James will be pushing all
the labeled networking changes to Linus when the time comes.
--
paul moore
linux security @ hp
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-01-08 13:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-07 17:47 [RFC PATCH v2 0/2] Labeled networking core stack changes for 2.6.25 Paul Moore
2008-01-07 17:47 ` [RFC PATCH v2 1/2] NET: Clone the sk_buff 'iif' field in __skb_clone() Paul Moore
2008-01-07 21:11 ` James Morris
2008-01-08 5:48 ` David Miller
2008-01-08 6:01 ` David Miller
2008-01-07 17:47 ` [RFC PATCH v2 2/2] SELinux: Add network ingress and egress control permission checks Paul Moore
2008-01-08 6:02 ` David Miller
2008-01-08 13:13 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).