Merge tag 'apparmor-pr-2021-11-10' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / security / apparmor / apparmorfs.c
index 0920f518863173feb1a3e2a8bc723c9aa1b8630f..0797edb2fb3dc6c4e16921c7e3c3dad91ae98792 100644 (file)
@@ -422,7 +422,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
         */
        error = aa_may_manage_policy(label, ns, mask);
        if (error)
-               return error;
+               goto end_section;
 
        data = aa_simple_write_to_buffer(buf, size, size, pos);
        error = PTR_ERR(data);
@@ -430,6 +430,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,
                error = aa_replace_profiles(ns, label, mask, data);
                aa_put_loaddata(data);
        }
+end_section:
        end_current_label_crit_section(label);
 
        return error;
@@ -1771,7 +1772,8 @@ fail2:
        return error;
 }
 
-static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
+static int ns_mkdir_op(struct user_namespace *mnt_userns, struct inode *dir,
+                      struct dentry *dentry, umode_t mode)
 {
        struct aa_ns *ns, *parent;
        /* TODO: improve permission check */
@@ -2044,9 +2046,6 @@ fail2:
        return error;
 }
 
-
-#define list_entry_is_head(pos, head, member) (&pos->member == (head))
-
 /**
  * __next_ns - find the next namespace to list
  * @root: root namespace to stop search at (NOT NULL)
@@ -2542,16 +2541,18 @@ static const char *policy_get_link(struct dentry *dentry,
 {
        struct aa_ns *ns;
        struct path path;
+       int error;
 
        if (!dentry)
                return ERR_PTR(-ECHILD);
+
        ns = aa_get_current_ns();
        path.mnt = mntget(aafs_mnt);
        path.dentry = dget(ns_dir(ns));
-       nd_jump_link(&path);
+       error = nd_jump_link(&path);
        aa_put_ns(ns);
 
-       return NULL;
+       return ERR_PTR(error);
 }
 
 static int policy_readlink(struct dentry *dentry, char __user *buffer,