Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235109
b: refs/heads/master
c: 6f5317e
h: refs/heads/master
i:
  235107: f0e05c2
v: v3
  • Loading branch information
Harry Ciao authored and Eric Paris committed Mar 3, 2011
1 parent eca9682 commit cd8c257
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 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: 4bc6c2d5d8386800fde23a8e78cd4f04a0ade0ad
refs/heads/master: 6f5317e730505d5cbc851c435a2dfe3d5a21d343
5 changes: 3 additions & 2 deletions trunk/security/selinux/ss/mls.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ int mls_compute_sid(struct context *scontext,
struct context *tcontext,
u16 tclass,
u32 specified,
struct context *newcontext)
struct context *newcontext,
bool sock)
{
struct range_trans rtr;
struct mls_range *r;
Expand All @@ -531,7 +532,7 @@ int mls_compute_sid(struct context *scontext,
return mls_range_set(newcontext, r);
/* Fallthrough */
case AVTAB_CHANGE:
if (tclass == policydb.process_class)
if ((tclass == policydb.process_class) || (sock == true))
/* Use the process MLS attributes. */
return mls_context_cpy(newcontext, scontext);
else
Expand Down
3 changes: 2 additions & 1 deletion trunk/security/selinux/ss/mls.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ int mls_compute_sid(struct context *scontext,
struct context *tcontext,
u16 tclass,
u32 specified,
struct context *newcontext);
struct context *newcontext,
bool sock);

int mls_setup_user_range(struct context *fromcon, struct user_datum *user,
struct context *usercon);
Expand Down
28 changes: 24 additions & 4 deletions trunk/security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ static u16 unmap_class(u16 tclass)
return tclass;
}

/*
* Get kernel value for class from its policy value
*/
static u16 map_class(u16 pol_value)
{
u16 i;

for (i = 1; i < current_mapping_size; i++) {
if (current_mapping[i].value == pol_value)
return i;
}

return pol_value;
}

static void map_decision(u16 tclass, struct av_decision *avd,
int allow_unknown)
{
Expand Down Expand Up @@ -1374,6 +1389,7 @@ static int security_compute_sid(u32 ssid,
struct avtab_node *node;
u16 tclass;
int rc = 0;
bool sock;

if (!ss_initialized) {
switch (orig_tclass) {
Expand All @@ -1391,10 +1407,13 @@ static int security_compute_sid(u32 ssid,

read_lock(&policy_rwlock);

if (kern)
if (kern) {
tclass = unmap_class(orig_tclass);
else
sock = security_is_socket_class(orig_tclass);
} else {
tclass = orig_tclass;
sock = security_is_socket_class(map_class(tclass));
}

scontext = sidtab_search(&sidtab, ssid);
if (!scontext) {
Expand Down Expand Up @@ -1425,7 +1444,7 @@ static int security_compute_sid(u32 ssid,
}

/* Set the role and type to default values. */
if (tclass == policydb.process_class) {
if ((tclass == policydb.process_class) || (sock == true)) {
/* Use the current role and type of process. */
newcontext.role = scontext->role;
newcontext.type = scontext->type;
Expand Down Expand Up @@ -1482,7 +1501,8 @@ static int security_compute_sid(u32 ssid,

/* Set the MLS attributes.
This is done last because it may allocate memory. */
rc = mls_compute_sid(scontext, tcontext, tclass, specified, &newcontext);
rc = mls_compute_sid(scontext, tcontext, tclass, specified,
&newcontext, sock);
if (rc)
goto out_unlock;

Expand Down

0 comments on commit cd8c257

Please sign in to comment.