Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80886
b: refs/heads/master
c: 224dfbd
h: refs/heads/master
v: v3
  • Loading branch information
Paul Moore authored and James Morris committed Jan 29, 2008
1 parent 0faec0a commit d815815
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da5645a28a15aed2e541a814ecf9f7ffcd4c4673
refs/heads/master: 224dfbd81e1ff672eb46e7695469c395bd531083
9 changes: 8 additions & 1 deletion trunk/security/selinux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/

selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o exports.o
selinux-y := avc.o \
hooks.o \
selinuxfs.o \
netlink.o \
nlmsgtab.o \
netif.o \
netnode.o \
exports.o

selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o

Expand Down
33 changes: 17 additions & 16 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "avc.h"
#include "objsec.h"
#include "netif.h"
#include "netnode.h"
#include "xfrm.h"
#include "netlabel.h"

Expand Down Expand Up @@ -3395,7 +3396,7 @@ static int selinux_parse_skb_ipv6(struct sk_buff *skb,
#endif /* IPV6 */

static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
char **addrp, int *len, int src, u8 *proto)
char **addrp, int src, u8 *proto)
{
int ret = 0;

Expand All @@ -3404,7 +3405,6 @@ static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
ret = selinux_parse_skb_ipv4(skb, ad, proto);
if (ret || !addrp)
break;
*len = 4;
*addrp = (char *)(src ? &ad->u.net.v4info.saddr :
&ad->u.net.v4info.daddr);
break;
Expand All @@ -3414,7 +3414,6 @@ static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
ret = selinux_parse_skb_ipv6(skb, ad, proto);
if (ret || !addrp)
break;
*len = 16;
*addrp = (char *)(src ? &ad->u.net.v6info.saddr :
&ad->u.net.v6info.daddr);
break;
Expand Down Expand Up @@ -3614,7 +3613,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
break;
}

err = security_node_sid(family, addrp, addrlen, &sid);
err = sel_netnode_sid(addrp, family, &sid);
if (err)
goto out;

Expand Down Expand Up @@ -3826,7 +3825,8 @@ static int selinux_socket_unix_may_send(struct socket *sock,
}

static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
struct avc_audit_data *ad, u16 family, char *addrp, int len)
struct avc_audit_data *ad,
u16 family, char *addrp)
{
int err = 0;
u32 netif_perm, node_perm, node_sid, if_sid, recv_perm = 0;
Expand Down Expand Up @@ -3886,7 +3886,7 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
if (err)
goto out;

err = security_node_sid(family, addrp, len, &node_sid);
err = sel_netnode_sid(addrp, family, &node_sid);
if (err)
goto out;

Expand Down Expand Up @@ -3915,7 +3915,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
u16 family;
char *addrp;
int len, err = 0;
int err = 0;
struct avc_audit_data ad;
struct sk_security_struct *sksec = sk->sk_security;

Expand All @@ -3931,13 +3931,12 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
ad.u.net.netif = skb->iif;
ad.u.net.family = family;

err = selinux_parse_skb(skb, &ad, &addrp, &len, 1, NULL);
err = selinux_parse_skb(skb, &ad, &addrp, 1, NULL);
if (err)
goto out;

if (selinux_compat_net)
err = selinux_sock_rcv_skb_compat(sk, skb, &ad, family,
addrp, len);
err = selinux_sock_rcv_skb_compat(sk, skb, &ad, family, addrp);
else
err = avc_has_perm(sksec->sid, skb->secmark, SECCLASS_PACKET,
PACKET__RECV, &ad);
Expand Down Expand Up @@ -4158,9 +4157,11 @@ static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb)

#ifdef CONFIG_NETFILTER

static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *dev,
static int selinux_ip_postroute_last_compat(struct sock *sk,
struct net_device *dev,
struct avc_audit_data *ad,
u16 family, char *addrp, int len)
u16 family,
char *addrp)
{
int err = 0;
u32 netif_perm, node_perm, node_sid, if_sid, send_perm = 0;
Expand Down Expand Up @@ -4211,7 +4212,7 @@ static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *
if (err)
goto out;

err = security_node_sid(family, addrp, len, &node_sid);
err = sel_netnode_sid(addrp, family, &node_sid);
if (err)
goto out;

Expand Down Expand Up @@ -4245,7 +4246,7 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
u16 family)
{
char *addrp;
int len, err = 0;
int err = 0;
struct sock *sk;
struct avc_audit_data ad;
struct net_device *dev = (struct net_device *)out;
Expand All @@ -4262,13 +4263,13 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
ad.u.net.netif = dev->ifindex;
ad.u.net.family = family;

err = selinux_parse_skb(skb, &ad, &addrp, &len, 0, &proto);
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, len);
family, addrp);
else
err = avc_has_perm(sksec->sid, skb->secmark, SECCLASS_PACKET,
PACKET__SEND, &ad);
Expand Down
32 changes: 32 additions & 0 deletions trunk/security/selinux/include/netnode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Network node table
*
* SELinux must keep a mapping of network nodes to labels/SIDs. This
* mapping is maintained as part of the normal policy but a fast cache is
* needed to reduce the lookup overhead since most of these queries happen on
* a per-packet basis.
*
* Author: Paul Moore <paul.moore@hp.com>
*
*/

/*
* (c) Copyright Hewlett-Packard Development Company, L.P., 2007
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef _SELINUX_NETNODE_H
#define _SELINUX_NETNODE_H

int sel_netnode_sid(void *addr, u16 family, u32 *sid);

#endif
9 changes: 9 additions & 0 deletions trunk/security/selinux/include/objsec.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ struct netif_security_struct {
u32 sid; /* SID for this interface */
};

struct netnode_security_struct {
union {
__be32 ipv4; /* IPv4 node address */
struct in6_addr ipv6; /* IPv6 node address */
} addr;
u32 sid; /* SID for this node */
u16 family; /* address family */
};

struct sk_security_struct {
struct sock *sk; /* back pointer to sk object */
u32 sid; /* SID of this object */
Expand Down
Loading

0 comments on commit d815815

Please sign in to comment.