Skip to content

Commit

Permalink
apparmor: allow specifying an already created dir to create ns entrie…
Browse files Browse the repository at this point in the history
…s in

Signed-off-by: John Johansen <john.johansen@canonical.com>
Reviewed-by: Seth Arnold <seth.arnold@canonical.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
John Johansen committed Jun 8, 2017
1 parent c97204b commit 98407f0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions security/apparmor/apparmorfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,12 @@ static int __aafs_ns_mkdir_entries(struct aa_ns *ns, struct dentry *dir)
/*
* Requires: @ns->lock held
*/
int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name)
int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
struct dentry *dent)
{
struct aa_ns *sub;
struct aa_profile *child;
struct dentry *dent, *dir;
struct dentry *dir;
int error;

AA_BUG(!ns);
Expand Down Expand Up @@ -1373,7 +1374,7 @@ int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name)
/* subnamespaces */
list_for_each_entry(sub, &ns->sub_ns, base.list) {
mutex_lock(&sub->lock);
error = __aafs_ns_mkdir(sub, ns_subns_dir(ns), NULL);
error = __aafs_ns_mkdir(sub, ns_subns_dir(ns), NULL, NULL);
mutex_unlock(&sub->lock);
if (error)
goto fail2;
Expand Down Expand Up @@ -1929,7 +1930,7 @@ static int __init aa_create_aafs(void)
ns_subremove(root_ns) = dent;

mutex_lock(&root_ns->lock);
error = __aafs_ns_mkdir(root_ns, aa_sfs_entry.dentry, "policy");
error = __aafs_ns_mkdir(root_ns, aa_sfs_entry.dentry, "policy", NULL);
mutex_unlock(&root_ns->lock);

if (error)
Expand Down
4 changes: 2 additions & 2 deletions security/apparmor/include/apparmorfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
struct aa_profile *new);
int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);
void __aafs_ns_rmdir(struct aa_ns *ns);
int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent,
const char *name);
int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
struct dentry *dent);

struct aa_loaddata;
void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata);
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/policy_ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static struct aa_ns *__aa_create_ns(struct aa_ns *parent, const char *name,
if (!ns)
return NULL;
mutex_lock(&ns->lock);
error = __aafs_ns_mkdir(ns, ns_subns_dir(parent), name);
error = __aafs_ns_mkdir(ns, ns_subns_dir(parent), name, dir);
if (error) {
AA_ERROR("Failed to create interface for ns %s\n",
ns->base.name);
Expand Down

0 comments on commit 98407f0

Please sign in to comment.