Skip to content

Commit

Permalink
SELinux: extract the NetLabel SELinux support from the security server
Browse files Browse the repository at this point in the history
Up until this patch the functions which have provided NetLabel support to
SELinux have been integrated into the SELinux security server, which for
various reasons is not really ideal.  This patch makes an effort to extract as
much of the NetLabel support from the security server as possibile and move it
into it's own file within the SELinux directory structure.

Signed-off-by: Paul Moore <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
pcmoore authored and James Morris committed Apr 26, 2007
1 parent 128c6b6 commit 5778eab
Show file tree
Hide file tree
Showing 6 changed files with 481 additions and 405 deletions.
3 changes: 0 additions & 3 deletions net/netlabel/netlabel_kapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ int netlbl_socket_setattr(const struct socket *sock,
int ret_val = -ENOENT;
struct netlbl_dom_map *dom_entry;

if ((secattr->flags & NETLBL_SECATTR_DOMAIN) == 0)
return -ENOENT;

rcu_read_lock();
dom_entry = netlbl_domhsh_getentry(secattr->domain);
if (dom_entry == NULL)
Expand Down
2 changes: 2 additions & 0 deletions security/selinux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o exports.o

selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o

selinux-$(CONFIG_NETLABEL) += netlabel.o

EXTRA_CFLAGS += -Isecurity/selinux/include

24 changes: 24 additions & 0 deletions security/selinux/include/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif

struct sk_buff;
struct netlbl_lsm_secattr;

extern int selinux_enabled;
extern int selinux_mls_enabled;
Expand Down Expand Up @@ -102,5 +103,28 @@ int security_fs_use(const char *fstype, unsigned int *behavior,
int security_genfs_sid(const char *fstype, char *name, u16 sclass,
u32 *sid);

#ifdef CONFIG_NETLABEL
int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr,
u32 base_sid,
u32 *sid);

int security_netlbl_sid_to_secattr(u32 sid,
struct netlbl_lsm_secattr *secattr);
#else
static inline int security_netlbl_secattr_to_sid(
struct netlbl_lsm_secattr *secattr,
u32 base_sid,
u32 *sid)
{
return -EIDRM;
}

static inline int security_netlbl_sid_to_secattr(u32 sid,
struct netlbl_lsm_secattr *secattr)
{
return -ENOENT;
}
#endif /* CONFIG_NETLABEL */

#endif /* _SELINUX_SECURITY_H_ */

71 changes: 34 additions & 37 deletions security/selinux/include/selinux_netlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@

#ifdef CONFIG_NETLABEL
void selinux_netlbl_cache_invalidate(void);
int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid);
int selinux_netlbl_socket_post_create(struct socket *sock);
void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock);
int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
struct avc_audit_data *ad);

void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec,
int family);
void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
int family);
void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
struct sk_security_struct *newssec);

int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid);

void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock);
int selinux_netlbl_socket_post_create(struct socket *sock);
int selinux_netlbl_inode_permission(struct inode *inode, int mask);
int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
struct avc_audit_data *ad);
int selinux_netlbl_socket_setsockopt(struct socket *sock,
int level,
int optname);
Expand All @@ -60,59 +63,53 @@ static inline void selinux_netlbl_cache_invalidate(void)
return;
}

static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
u32 base_sid,
u32 *sid)
static inline void selinux_netlbl_sk_security_reset(
struct sk_security_struct *ssec,
int family)
{
*sid = SECSID_NULL;
return 0;
return;
}

static inline int selinux_netlbl_socket_post_create(struct socket *sock)
static inline void selinux_netlbl_sk_security_init(
struct sk_security_struct *ssec,
int family)
{
return 0;
return;
}

static inline void selinux_netlbl_sock_graft(struct sock *sk,
struct socket *sock)
static inline void selinux_netlbl_sk_security_clone(
struct sk_security_struct *ssec,
struct sk_security_struct *newssec)
{
return;
}

static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
struct avc_audit_data *ad)
static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
u32 base_sid,
u32 *sid)
{
*sid = SECSID_NULL;
return 0;
}

static inline void selinux_netlbl_sk_security_reset(
struct sk_security_struct *ssec,
int family)
{
return;
}

static inline void selinux_netlbl_sk_security_init(
struct sk_security_struct *ssec,
int family)
static inline void selinux_netlbl_sock_graft(struct sock *sk,
struct socket *sock)
{
return;
}

static inline void selinux_netlbl_sk_security_clone(
struct sk_security_struct *ssec,
struct sk_security_struct *newssec)
static inline int selinux_netlbl_socket_post_create(struct socket *sock)
{
return;
return 0;
}

static inline int selinux_netlbl_inode_permission(struct inode *inode,
int mask)
{
return 0;
}

static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
struct sk_buff *skb,
struct avc_audit_data *ad)
{
return 0;
}
static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
int level,
int optname)
Expand Down
Loading

0 comments on commit 5778eab

Please sign in to comment.