~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/apparmor-d_namespace.diff

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: b/security/apparmor/main.c
2
 
===================================================================
3
 
--- a/security/apparmor/main.c
4
 
+++ b/security/apparmor/main.c
5
 
@@ -12,6 +12,7 @@
6
 
 #include <linux/security.h>
7
 
 #include <linux/namei.h>
8
 
 #include <linux/audit.h>
9
 
+#include <linux/mount.h>
10
 
 
11
 
 #include "apparmor.h"
12
 
 
13
 
@@ -486,38 +487,20 @@ out:
14
 
  * @mnt: where in tree
15
 
  *
16
 
  * Returns fully qualified path name on sucess, NULL on failure.
17
 
- * aa_put_name must be used to free allocated buffer.
18
 
+ * aa_put_name must be used to free the allocated buffer.
19
 
  */
20
 
 char *aa_get_name(struct dentry *dentry, struct vfsmount *mnt)
21
 
 {
22
 
        char *page, *name;
23
 
 
24
 
        page = (char *)__get_free_page(GFP_KERNEL);
25
 
-       if (!page) {
26
 
-               name = ERR_PTR(-ENOMEM);
27
 
-               goto out;
28
 
-       }
29
 
+       if (!page)
30
 
+               return ERR_PTR(-ENOMEM);
31
 
 
32
 
-       name = d_path(dentry, mnt, page, PAGE_SIZE);
33
 
-       /* check for (deleted) that d_path appends to pathnames if the dentry
34
 
-        * has been removed from the cache.
35
 
-        * The size > deleted_size and strcmp checks are redundant safe guards.
36
 
-        */
37
 
-       if (IS_ERR(name)) {
38
 
+       name = d_namespace_path(dentry, mnt, page, PAGE_SIZE);
39
 
+       if (IS_ERR(name))
40
 
                free_page((unsigned long)page);
41
 
-       } else {
42
 
-               const char deleted_str[] = " (deleted)";
43
 
-               const size_t deleted_size = sizeof(deleted_str) - 1;
44
 
-               size_t size;
45
 
-               size = strlen(name);
46
 
-               if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
47
 
-                   size > deleted_size &&
48
 
-                   strcmp(name + size - deleted_size, deleted_str) == 0)
49
 
-                       name[size - deleted_size] = '\0';
50
 
-               AA_DEBUG("%s: full_path=%s\n", __FUNCTION__, name);
51
 
-       }
52
 
 
53
 
-out:
54
 
        return name;
55
 
 }
56