Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/jmorris/security-testing-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
  smackfs: check for allocation failures in smk_set_access()
  • Loading branch information
Linus Torvalds committed Dec 28, 2008
2 parents 96faec9 + 54d2f64 commit d05a788
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions security/smack/smackfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ static int smk_open_load(struct inode *inode, struct file *file)
* the subject/object pair and replaces the access that was
* there. If the pair isn't found add it with the specified
* access.
*
* Returns 0 if nothing goes wrong or -ENOMEM if it fails
* during the allocation of the new pair to add.
*/
static void smk_set_access(struct smack_rule *srp)
static int smk_set_access(struct smack_rule *srp)
{
struct smk_list_entry *sp;
struct smk_list_entry *newp;
int ret = 0;

mutex_lock(&smack_list_lock);

Expand All @@ -202,14 +206,20 @@ static void smk_set_access(struct smack_rule *srp)

if (sp == NULL) {
newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL);
if (newp == NULL) {
ret = -ENOMEM;
goto out;
}

newp->smk_rule = *srp;
newp->smk_next = smack_list;
smack_list = newp;
}

out:
mutex_unlock(&smack_list_lock);

return;
return ret;
}

/**
Expand Down Expand Up @@ -309,8 +319,10 @@ static ssize_t smk_write_load(struct file *file, const char __user *buf,
goto out;
}

smk_set_access(&rule);
rc = count;
rc = smk_set_access(&rule);

if (!rc)
rc = count;

out:
kfree(data);
Expand Down

0 comments on commit d05a788

Please sign in to comment.