Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 88449
b: refs/heads/master
c: 64dbf07
h: refs/heads/master
i:
  88447: f355d6b
v: v3
  • Loading branch information
Eric Paris authored and James Morris committed Apr 18, 2008
1 parent 751f5de commit 7218362
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 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: 0356357c5158c71d4cbf20196b2f784435dd916c
refs/heads/master: 64dbf07474d011540ca479a2e87fe998f570d6e3
2 changes: 1 addition & 1 deletion trunk/security/selinux/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ config SECURITY_SELINUX_POLICYDB_VERSION_MAX
config SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE
int "NSA SELinux maximum supported policy format version value"
depends on SECURITY_SELINUX_POLICYDB_VERSION_MAX
range 15 22
range 15 23
default 19
help
This option sets the value for the maximum policy format version
Expand Down
9 changes: 5 additions & 4 deletions trunk/security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,12 +893,13 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid,
denied = requested & ~(p_ae->avd.allowed);

if (denied) {
if (selinux_enforcing || (flags & AVC_STRICT))
if (flags & AVC_STRICT)
rc = -EACCES;
else if (!selinux_enforcing || security_permissive_sid(ssid))
avc_update_node(AVC_CALLBACK_GRANT, requested, ssid,
tsid, tclass);
else
if (node)
avc_update_node(AVC_CALLBACK_GRANT,requested,
ssid,tsid,tclass);
rc = -EACCES;
}

rcu_read_unlock();
Expand Down
5 changes: 4 additions & 1 deletion trunk/security/selinux/include/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
#define POLICYDB_VERSION_AVTAB 20
#define POLICYDB_VERSION_RANGETRANS 21
#define POLICYDB_VERSION_POLCAP 22
#define POLICYDB_VERSION_PERMISSIVE 23

/* Range of policy versions we understand*/
#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
#ifdef CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX
#define POLICYDB_VERSION_MAX CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE
#else
#define POLICYDB_VERSION_MAX POLICYDB_VERSION_POLCAP
#define POLICYDB_VERSION_MAX POLICYDB_VERSION_PERMISSIVE
#endif

#define CONTEXT_MNT 0x01
Expand Down Expand Up @@ -69,6 +70,8 @@ struct av_decision {
u32 seqno;
};

int security_permissive_sid(u32 sid);

int security_compute_av(u32 ssid, u32 tsid,
u16 tclass, u32 requested,
struct av_decision *avd);
Expand Down
11 changes: 11 additions & 0 deletions trunk/security/selinux/ss/policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ static struct policydb_compat_info policydb_compat[] = {
.version = POLICYDB_VERSION_POLCAP,
.sym_num = SYM_NUM,
.ocon_num = OCON_NUM,
},
{
.version = POLICYDB_VERSION_PERMISSIVE,
.sym_num = SYM_NUM,
.ocon_num = OCON_NUM,
}
};

Expand Down Expand Up @@ -194,6 +199,7 @@ static int policydb_init(struct policydb *p)
goto out_free_symtab;

ebitmap_init(&p->policycaps);
ebitmap_init(&p->permissive_map);

out:
return rc;
Expand Down Expand Up @@ -687,6 +693,7 @@ void policydb_destroy(struct policydb *p)
kfree(p->type_attr_map);
kfree(p->undefined_perms);
ebitmap_destroy(&p->policycaps);
ebitmap_destroy(&p->permissive_map);

return;
}
Expand Down Expand Up @@ -1570,6 +1577,10 @@ int policydb_read(struct policydb *p, void *fp)
ebitmap_read(&p->policycaps, fp) != 0)
goto bad;

if (p->policyvers >= POLICYDB_VERSION_PERMISSIVE &&
ebitmap_read(&p->permissive_map, fp) != 0)
goto bad;

info = policydb_lookup_compat(p->policyvers);
if (!info) {
printk(KERN_ERR "SELinux: unable to find policy compat info "
Expand Down
2 changes: 2 additions & 0 deletions trunk/security/selinux/ss/policydb.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ struct policydb {

struct ebitmap policycaps;

struct ebitmap permissive_map;

unsigned int policyvers;

unsigned int reject_unknown : 1;
Expand Down
25 changes: 25 additions & 0 deletions trunk/security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,31 @@ static int context_struct_compute_av(struct context *scontext,
return -EINVAL;
}

/*
* Given a sid find if the type has the permissive flag set
*/
int security_permissive_sid(u32 sid)
{
struct context *context;
u32 type;
int rc;

POLICY_RDLOCK;

context = sidtab_search(&sidtab, sid);
BUG_ON(!context);

type = context->type;
/*
* we are intentionally using type here, not type-1, the 0th bit may
* someday indicate that we are globally setting permissive in policy.
*/
rc = ebitmap_get_bit(&policydb.permissive_map, type);

POLICY_RDUNLOCK;
return rc;
}

static int security_validtrans_handle_fail(struct context *ocontext,
struct context *ncontext,
struct context *tcontext,
Expand Down

0 comments on commit 7218362

Please sign in to comment.