Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211677
b: refs/heads/master
c: d5630b9
h: refs/heads/master
i:
  211675: d7826c8
v: v3
  • Loading branch information
Eric Paris authored and James Morris committed Oct 20, 2010
1 parent 349faad commit 1d60f82
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 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: 2606fd1fa5710205b23ee859563502aa18362447
refs/heads/master: d5630b9d276bd389299ffea620b7c340ab19bcf5
6 changes: 5 additions & 1 deletion trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -1285,9 +1285,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* Return 0 if permission is granted.
*
* @secid_to_secctx:
* Convert secid to security context.
* Convert secid to security context. If secdata is NULL the length of
* the result will be returned in seclen, but no secdata will be returned.
* This does mean that the length could change between calls to check the
* length and the next call which actually allocates and returns the secdata.
* @secid contains the security ID.
* @secdata contains the pointer that stores the converted security context.
* @seclen pointer which contains the length of the data
* @secctx_to_secid:
* Convert security context to secid.
* @secid contains the pointer to the generated security ID.
Expand Down
11 changes: 9 additions & 2 deletions trunk/security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,8 @@ static int context_struct_to_string(struct context *context, char **scontext, u3
{
char *scontextp;

*scontext = NULL;
if (scontext)
*scontext = NULL;
*scontext_len = 0;

if (context->len) {
Expand All @@ -1008,6 +1009,9 @@ static int context_struct_to_string(struct context *context, char **scontext, u3
*scontext_len += strlen(policydb.p_type_val_to_name[context->type - 1]) + 1;
*scontext_len += mls_compute_context_len(context);

if (!scontext)
return 0;

/* Allocate space for the context; caller must free this space. */
scontextp = kmalloc(*scontext_len, GFP_ATOMIC);
if (!scontextp)
Expand Down Expand Up @@ -1047,14 +1051,17 @@ static int security_sid_to_context_core(u32 sid, char **scontext,
struct context *context;
int rc = 0;

*scontext = NULL;
if (scontext)
*scontext = NULL;
*scontext_len = 0;

if (!ss_initialized) {
if (sid <= SECINITSID_NUM) {
char *scontextp;

*scontext_len = strlen(initial_sid_to_string[sid]) + 1;
if (!scontext)
goto out;
scontextp = kmalloc(*scontext_len, GFP_ATOMIC);
if (!scontextp) {
rc = -ENOMEM;
Expand Down
3 changes: 2 additions & 1 deletion trunk/security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3004,7 +3004,8 @@ static int smack_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
{
char *sp = smack_from_secid(secid);

*secdata = sp;
if (secdata)
*secdata = sp;
*seclen = strlen(sp);
return 0;
}
Expand Down

0 comments on commit 1d60f82

Please sign in to comment.