Commit efa06708 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jmorris/selinux-2.6

* 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jmorris/selinux-2.6:
  selinux: Delete mls_copy_context
parents 86302f41 0efc61ea
...@@ -55,6 +55,29 @@ static inline int mls_context_cpy(struct context *dst, struct context *src) ...@@ -55,6 +55,29 @@ static inline int mls_context_cpy(struct context *dst, struct context *src)
return rc; return rc;
} }
/*
* Sets both levels in the MLS range of 'dst' to the low level of 'src'.
*/
static inline int mls_context_cpy_low(struct context *dst, struct context *src)
{
int rc;
if (!selinux_mls_enabled)
return 0;
dst->range.level[0].sens = src->range.level[0].sens;
rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[0].cat);
if (rc)
goto out;
dst->range.level[1].sens = src->range.level[0].sens;
rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[0].cat);
if (rc)
ebitmap_destroy(&dst->range.level[0].cat);
out:
return rc;
}
static inline int mls_context_cmp(struct context *c1, struct context *c2) static inline int mls_context_cmp(struct context *c1, struct context *c2)
{ {
if (!selinux_mls_enabled) if (!selinux_mls_enabled)
......
...@@ -270,7 +270,7 @@ int mls_context_to_sid(char oldc, ...@@ -270,7 +270,7 @@ int mls_context_to_sid(char oldc,
if (!defcon) if (!defcon)
goto out; goto out;
rc = mls_copy_context(context, defcon); rc = mls_context_cpy(context, defcon);
goto out; goto out;
} }
...@@ -400,26 +400,6 @@ int mls_from_string(char *str, struct context *context, gfp_t gfp_mask) ...@@ -400,26 +400,6 @@ int mls_from_string(char *str, struct context *context, gfp_t gfp_mask)
return rc; return rc;
} }
/*
* Copies the effective MLS range from `src' into `dst'.
*/
static inline int mls_scopy_context(struct context *dst,
struct context *src)
{
int l, rc = 0;
/* Copy the MLS range from the source context */
for (l = 0; l < 2; l++) {
dst->range.level[l].sens = src->range.level[0].sens;
rc = ebitmap_cpy(&dst->range.level[l].cat,
&src->range.level[0].cat);
if (rc)
break;
}
return rc;
}
/* /*
* Copies the MLS range `range' into `context'. * Copies the MLS range `range' into `context'.
*/ */
...@@ -552,19 +532,19 @@ int mls_compute_sid(struct context *scontext, ...@@ -552,19 +532,19 @@ int mls_compute_sid(struct context *scontext,
case AVTAB_CHANGE: case AVTAB_CHANGE:
if (tclass == SECCLASS_PROCESS) if (tclass == SECCLASS_PROCESS)
/* Use the process MLS attributes. */ /* Use the process MLS attributes. */
return mls_copy_context(newcontext, scontext); return mls_context_cpy(newcontext, scontext);
else else
/* Use the process effective MLS attributes. */ /* Use the process effective MLS attributes. */
return mls_scopy_context(newcontext, scontext); return mls_context_cpy_low(newcontext, scontext);
case AVTAB_MEMBER: case AVTAB_MEMBER:
/* Only polyinstantiate the MLS attributes if /* Only polyinstantiate the MLS attributes if
the type is being polyinstantiated */ the type is being polyinstantiated */
if (newcontext->type != tcontext->type) { if (newcontext->type != tcontext->type) {
/* Use the process effective MLS attributes. */ /* Use the process effective MLS attributes. */
return mls_scopy_context(newcontext, scontext); return mls_context_cpy_low(newcontext, scontext);
} else { } else {
/* Use the related object MLS attributes. */ /* Use the related object MLS attributes. */
return mls_copy_context(newcontext, tcontext); return mls_context_cpy(newcontext, tcontext);
} }
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -24,26 +24,6 @@ ...@@ -24,26 +24,6 @@
#include "context.h" #include "context.h"
#include "policydb.h" #include "policydb.h"
/*
* Copies the MLS range from `src' into `dst'.
*/
static inline int mls_copy_context(struct context *dst,
struct context *src)
{
int l, rc = 0;
/* Copy the MLS range from the source context */
for (l = 0; l < 2; l++) {
dst->range.level[l].sens = src->range.level[l].sens;
rc = ebitmap_cpy(&dst->range.level[l].cat,
&src->range.level[l].cat);
if (rc)
break;
}
return rc;
}
int mls_compute_context_len(struct context *context); int mls_compute_context_len(struct context *context);
void mls_sid_to_context(struct context *context, char **scontext); void mls_sid_to_context(struct context *context, char **scontext);
int mls_context_isvalid(struct policydb *p, struct context *c); int mls_context_isvalid(struct policydb *p, struct context *c);
......
...@@ -1916,11 +1916,10 @@ int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid) ...@@ -1916,11 +1916,10 @@ int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid)
newcon.user = context1->user; newcon.user = context1->user;
newcon.role = context1->role; newcon.role = context1->role;
newcon.type = context1->type; newcon.type = context1->type;
rc = mls_copy_context(&newcon, context2); rc = mls_context_cpy(&newcon, context2);
if (rc) if (rc)
goto out_unlock; goto out_unlock;
/* Check the validity of the new context. */ /* Check the validity of the new context. */
if (!policydb_context_isvalid(&policydb, &newcon)) { if (!policydb_context_isvalid(&policydb, &newcon)) {
rc = convert_context_handle_invalid_context(&newcon); rc = convert_context_handle_invalid_context(&newcon);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment