]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Revert "UBUNTU: SAUCE: apparmor: fix replacement race in reading rawdata"
authorStefan Bader <stefan.bader@canonical.com>
Wed, 22 Mar 2017 08:52:36 +0000 (09:52 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Mar 2017 10:20:12 +0000 (11:20 +0100)
This reverts commit f76c72509af85672411638f99b80ad97b01a6f88.

BugLink: https://bugs.launchpad.net/bugs/1666897
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
security/apparmor/apparmorfs.c

index 6950d27105e6aa5a3626498c5f72e6c45cdac848..f6a2370b375803681f4f247a473f7a9798ba4c38 100644 (file)
@@ -766,7 +766,7 @@ static const struct file_operations aa_fs_ns_name = {
 static int rawdata_release(struct inode *inode, struct file *file)
 {
        /* TODO: switch to loaddata when profile switched to symlink */
-       aa_put_loaddata(file->private_data);
+       aa_put_proxy(file->private_data);
 
        return 0;
 }
@@ -832,24 +832,22 @@ static const struct file_operations aa_fs_seq_raw_hash_fops = {
 static ssize_t rawdata_read(struct file *file, char __user *buf, size_t size,
                            loff_t *ppos)
 {
-       struct aa_loaddata *rawdata = file->private_data;
+       struct aa_proxy *proxy = file->private_data;
+       struct aa_label *label = aa_get_label_rcu(&proxy->label);
+       struct aa_profile *profile = labels_profile(label);
 
-       return simple_read_from_buffer(buf, size, ppos, rawdata->data,
-                                      rawdata->size);
+       ssize_t ret = simple_read_from_buffer(buf, size, ppos, profile->rawdata->data, profile->rawdata->size);
+       aa_put_label(label);
+
+       return ret;
 }
 
 static int rawdata_open(struct inode *inode, struct file *file)
 {
-       struct aa_proxy *proxy = inode->i_private;
-       struct aa_label *label;
-       struct aa_profile *profile;
-
        if (!policy_view_capable(NULL))
                return -EACCES;
-       label = aa_get_label_rcu(&proxy->label);
-       profile = labels_profile(label);
-       file->private_data = aa_get_loaddata(profile->rawdata);
-       aa_put_label(label);
+
+       file->private_data = aa_get_proxy(inode->i_private);
 
        return 0;
 }