Commit e819ff519b2d74373eca4a9a2b417ebf4c1e1b29
Committed by
James Morris
1 parent
98e52c373c
AppArmor: Drop hack to remove appended " (deleted)" string
The 2.6.36 kernel has refactored __d_path() so that it no longer appends " (deleted)" to unlinked paths. So drop the hack that was used to detect and remove the appended string. Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <jmorris@namei.org>
Showing 1 changed file with 11 additions and 27 deletions Side-by-side Diff
security/apparmor/path.c
... | ... | @@ -59,8 +59,7 @@ |
59 | 59 | { |
60 | 60 | struct path root, tmp; |
61 | 61 | char *res; |
62 | - int deleted, connected; | |
63 | - int error = 0; | |
62 | + int connected, error = 0; | |
64 | 63 | |
65 | 64 | /* Get the root we want to resolve too, released below */ |
66 | 65 | if (flags & PATH_CHROOT_REL) { |
... | ... | @@ -74,19 +73,8 @@ |
74 | 73 | } |
75 | 74 | |
76 | 75 | spin_lock(&dcache_lock); |
77 | - /* There is a race window between path lookup here and the | |
78 | - * need to strip the " (deleted) string that __d_path applies | |
79 | - * Detect the race and relookup the path | |
80 | - * | |
81 | - * The stripping of (deleted) is a hack that could be removed | |
82 | - * with an updated __d_path | |
83 | - */ | |
84 | - do { | |
85 | - tmp = root; | |
86 | - deleted = d_unlinked(path->dentry); | |
87 | - res = __d_path(path, &tmp, buf, buflen); | |
88 | - | |
89 | - } while (deleted != d_unlinked(path->dentry)); | |
76 | + tmp = root; | |
77 | + res = __d_path(path, &tmp, buf, buflen); | |
90 | 78 | spin_unlock(&dcache_lock); |
91 | 79 | |
92 | 80 | *name = res; |
93 | 81 | |
94 | 82 | |
... | ... | @@ -98,21 +86,17 @@ |
98 | 86 | *name = buf; |
99 | 87 | goto out; |
100 | 88 | } |
101 | - if (deleted) { | |
102 | - /* On some filesystems, newly allocated dentries appear to the | |
103 | - * security_path hooks as a deleted dentry except without an | |
104 | - * inode allocated. | |
105 | - * | |
106 | - * Remove the appended deleted text and return as string for | |
107 | - * normal mediation, or auditing. The (deleted) string is | |
108 | - * guaranteed to be added in this case, so just strip it. | |
109 | - */ | |
110 | - buf[buflen - 11] = 0; /* - (len(" (deleted)") +\0) */ | |
111 | 89 | |
112 | - if (path->dentry->d_inode && !(flags & PATH_MEDIATE_DELETED)) { | |
90 | + /* Handle two cases: | |
91 | + * 1. A deleted dentry && profile is not allowing mediation of deleted | |
92 | + * 2. On some filesystems, newly allocated dentries appear to the | |
93 | + * security_path hooks as a deleted dentry except without an inode | |
94 | + * allocated. | |
95 | + */ | |
96 | + if (d_unlinked(path->dentry) && path->dentry->d_inode && | |
97 | + !(flags & PATH_MEDIATE_DELETED)) { | |
113 | 98 | error = -ENOENT; |
114 | 99 | goto out; |
115 | - } | |
116 | 100 | } |
117 | 101 | |
118 | 102 | /* Determine if the path is connected to the expected root */ |