Skip to content

Commit

Permalink
Merge branch 'next' of git://git.infradead.org/users/pcmoore/selinux …
Browse files Browse the repository at this point in the history
…into next
  • Loading branch information
James Morris committed Jul 19, 2014
2 parents 32c2e67 + 615e51f commit 2ccf466
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 162 deletions.
1 change: 0 additions & 1 deletion scripts/selinux/genheaders/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ hostprogs-y := genheaders
HOST_EXTRACFLAGS += -Isecurity/selinux/include

always := $(hostprogs-y)
clean-files := $(hostprogs-y)
2 changes: 1 addition & 1 deletion scripts/selinux/mdp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ hostprogs-y := mdp
HOST_EXTRACFLAGS += -Isecurity/selinux/include

always := $(hostprogs-y)
clean-files := $(hostprogs-y) policy.* file_contexts
clean-files := policy.* file_contexts
14 changes: 14 additions & 0 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ static int selinux_peerlbl_enabled(void)
return (selinux_policycap_alwaysnetwork || netlbl_enabled() || selinux_xfrm_enabled());
}

static int selinux_netcache_avc_callback(u32 event)
{
if (event == AVC_CALLBACK_RESET) {
sel_netif_flush();
sel_netnode_flush();
sel_netport_flush();
synchronize_net();
}
return 0;
}

/*
* initialise the security for the init task
*/
Expand Down Expand Up @@ -6002,6 +6013,9 @@ static __init int selinux_init(void)
if (register_security(&selinux_ops))
panic("SELinux: Unable to register with kernel.\n");

if (avc_add_callback(selinux_netcache_avc_callback, AVC_CALLBACK_RESET))
panic("SELinux: Unable to register AVC netcache callback\n");

if (selinux_enforcing)
printk(KERN_DEBUG "SELinux: Starting in enforcing mode\n");
else
Expand Down
2 changes: 2 additions & 0 deletions security/selinux/include/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef _SELINUX_NETIF_H_
#define _SELINUX_NETIF_H_

void sel_netif_flush(void);

int sel_netif_sid(int ifindex, u32 *sid);

#endif /* _SELINUX_NETIF_H_ */
Expand Down
2 changes: 2 additions & 0 deletions security/selinux/include/netnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#ifndef _SELINUX_NETNODE_H
#define _SELINUX_NETNODE_H

void sel_netnode_flush(void);

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

#endif
2 changes: 2 additions & 0 deletions security/selinux/include/netport.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef _SELINUX_NETPORT_H
#define _SELINUX_NETPORT_H

void sel_netport_flush(void);

int sel_netport_sid(u8 protocol, u16 pnum, u32 *sid);

#endif
3 changes: 2 additions & 1 deletion security/selinux/include/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef _SELINUX_SECURITY_H_
#define _SELINUX_SECURITY_H_

#include <linux/compiler.h>
#include <linux/dcache.h>
#include <linux/magic.h>
#include <linux/types.h>
Expand Down Expand Up @@ -220,7 +221,7 @@ struct selinux_kernel_status {
/*
* The version > 0 supports above members.
*/
} __attribute__((packed));
} __packed;

extern void selinux_status_update_setenforce(int enforcing);
extern void selinux_status_update_policyload(int seqno);
Expand Down
15 changes: 1 addition & 14 deletions security/selinux/netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void sel_netif_kill(int ifindex)
* Remove all entries from the network interface table.
*
*/
static void sel_netif_flush(void)
void sel_netif_flush(void)
{
int idx;
struct sel_netif *netif;
Expand All @@ -252,15 +252,6 @@ static void sel_netif_flush(void)
spin_unlock_bh(&sel_netif_lock);
}

static int sel_netif_avc_callback(u32 event)
{
if (event == AVC_CALLBACK_RESET) {
sel_netif_flush();
synchronize_net();
}
return 0;
}

static int sel_netif_netdev_notifier_handler(struct notifier_block *this,
unsigned long event, void *ptr)
{
Expand Down Expand Up @@ -291,10 +282,6 @@ static __init int sel_netif_init(void)

register_netdevice_notifier(&sel_netif_netdev_notifier);

err = avc_add_callback(sel_netif_avc_callback, AVC_CALLBACK_RESET);
if (err)
panic("avc_add_callback() failed, error %d\n", err);

return err;
}

Expand Down
15 changes: 1 addition & 14 deletions security/selinux/netnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int sel_netnode_sid(void *addr, u16 family, u32 *sid)
* Remove all entries from the network address table.
*
*/
static void sel_netnode_flush(void)
void sel_netnode_flush(void)
{
unsigned int idx;
struct sel_netnode *node, *node_tmp;
Expand All @@ -300,15 +300,6 @@ static void sel_netnode_flush(void)
spin_unlock_bh(&sel_netnode_lock);
}

static int sel_netnode_avc_callback(u32 event)
{
if (event == AVC_CALLBACK_RESET) {
sel_netnode_flush();
synchronize_net();
}
return 0;
}

static __init int sel_netnode_init(void)
{
int iter;
Expand All @@ -322,10 +313,6 @@ static __init int sel_netnode_init(void)
sel_netnode_hash[iter].size = 0;
}

ret = avc_add_callback(sel_netnode_avc_callback, AVC_CALLBACK_RESET);
if (ret != 0)
panic("avc_add_callback() failed, error %d\n", ret);

return ret;
}

Expand Down
15 changes: 1 addition & 14 deletions security/selinux/netport.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int sel_netport_sid(u8 protocol, u16 pnum, u32 *sid)
* Remove all entries from the network address table.
*
*/
static void sel_netport_flush(void)
void sel_netport_flush(void)
{
unsigned int idx;
struct sel_netport *port, *port_tmp;
Expand All @@ -234,15 +234,6 @@ static void sel_netport_flush(void)
spin_unlock_bh(&sel_netport_lock);
}

static int sel_netport_avc_callback(u32 event)
{
if (event == AVC_CALLBACK_RESET) {
sel_netport_flush();
synchronize_net();
}
return 0;
}

static __init int sel_netport_init(void)
{
int iter;
Expand All @@ -256,10 +247,6 @@ static __init int sel_netport_init(void)
sel_netport_hash[iter].size = 0;
}

ret = avc_add_callback(sel_netport_avc_callback, AVC_CALLBACK_RESET);
if (ret != 0)
panic("avc_add_callback() failed, error %d\n", ret);

return ret;
}

Expand Down
11 changes: 3 additions & 8 deletions security/selinux/ss/conditional.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,14 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
int rc;
struct cond_expr *expr = NULL, *last = NULL;

rc = next_entry(buf, fp, sizeof(u32));
rc = next_entry(buf, fp, sizeof(u32) * 2);
if (rc)
return rc;
goto err;

node->cur_state = le32_to_cpu(buf[0]);

len = 0;
rc = next_entry(buf, fp, sizeof(u32));
if (rc)
return rc;

/* expr */
len = le32_to_cpu(buf[0]);
len = le32_to_cpu(buf[1]);

for (i = 0; i < len; i++) {
rc = next_entry(buf, fp, sizeof(u32) * 2);
Expand Down
Loading

0 comments on commit 2ccf466

Please sign in to comment.