aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-26 18:48:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-26 20:22:07 -0400
commit9ec3a646fe09970f801ab15e0f1694060b9f19af (patch)
tree697058ca7e1671eda180a3ccc62445686fbc1a31 /security
parentc8b3fd0ce313443731e8fd6d5a541085eb465f99 (diff)
parent3cab989afd8d8d1bc3d99fef0e7ed87c31e7b647 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull fourth vfs update from Al Viro: "d_inode() annotations from David Howells (sat in for-next since before the beginning of merge window) + four assorted fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: RCU pathwalk breakage when running into a symlink overmounting something fix I_DIO_WAKEUP definition direct-io: only inc/dec inode->i_dio_count for file systems fs/9p: fix readdir() VFS: assorted d_backing_inode() annotations VFS: fs/inode.c helpers: d_inode() annotations VFS: fs/cachefiles: d_backing_inode() annotations VFS: fs library helpers: d_inode() annotations VFS: assorted weird filesystems: d_inode() annotations VFS: normal filesystems (and lustre): d_inode() annotations VFS: security/: d_inode() annotations VFS: security/: d_backing_inode() annotations VFS: net/: d_inode() annotations VFS: net/unix: d_backing_inode() annotations VFS: kernel/: d_inode() annotations VFS: audit: d_backing_inode() annotations VFS: Fix up some ->d_inode accesses in the chelsio driver VFS: Cachefiles should perform fs modifications on the top layer only VFS: AF_UNIX sockets should call mknod on the top layer only
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/apparmorfs.c2
-rw-r--r--security/apparmor/file.c6
-rw-r--r--security/apparmor/lsm.c18
-rw-r--r--security/commoncap.c6
-rw-r--r--security/inode.c18
-rw-r--r--security/integrity/evm/evm_crypto.c4
-rw-r--r--security/integrity/evm/evm_main.c18
-rw-r--r--security/integrity/ima/ima_appraise.c10
-rw-r--r--security/lsm_audit.c4
-rw-r--r--security/security.c50
-rw-r--r--security/selinux/hooks.c36
-rw-r--r--security/selinux/selinuxfs.c2
-rw-r--r--security/smack/smack_lsm.c46
-rw-r--r--security/smack/smackfs.c2
-rw-r--r--security/tomoyo/condition.c2
-rw-r--r--security/tomoyo/realpath.c10
16 files changed, 117 insertions, 117 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 7db9954f1af2..ad4fa49ad1db 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -365,7 +365,7 @@ void __aa_fs_profile_rmdir(struct aa_profile *profile)
365 if (!profile->dents[i]) 365 if (!profile->dents[i])
366 continue; 366 continue;
367 367
368 r = profile->dents[i]->d_inode->i_private; 368 r = d_inode(profile->dents[i])->i_private;
369 securityfs_remove(profile->dents[i]); 369 securityfs_remove(profile->dents[i]);
370 aa_put_replacedby(r); 370 aa_put_replacedby(r);
371 profile->dents[i] = NULL; 371 profile->dents[i] = NULL;
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index fdaa50cb1876..913f377a038a 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -259,7 +259,7 @@ unsigned int aa_str_perms(struct aa_dfa *dfa, unsigned int start,
259 */ 259 */
260static inline bool is_deleted(struct dentry *dentry) 260static inline bool is_deleted(struct dentry *dentry)
261{ 261{
262 if (d_unlinked(dentry) && dentry->d_inode->i_nlink == 0) 262 if (d_unlinked(dentry) && d_backing_inode(dentry)->i_nlink == 0)
263 return 1; 263 return 1;
264 return 0; 264 return 0;
265} 265}
@@ -351,8 +351,8 @@ int aa_path_link(struct aa_profile *profile, struct dentry *old_dentry,
351 struct path link = { new_dir->mnt, new_dentry }; 351 struct path link = { new_dir->mnt, new_dentry };
352 struct path target = { new_dir->mnt, old_dentry }; 352 struct path target = { new_dir->mnt, old_dentry };
353 struct path_cond cond = { 353 struct path_cond cond = {
354 old_dentry->d_inode->i_uid, 354 d_backing_inode(old_dentry)->i_uid,
355 old_dentry->d_inode->i_mode 355 d_backing_inode(old_dentry)->i_mode
356 }; 356 };
357 char *buffer = NULL, *buffer2 = NULL; 357 char *buffer = NULL, *buffer2 = NULL;
358 const char *lname, *tname = NULL, *info = NULL; 358 const char *lname, *tname = NULL, *info = NULL;
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index dd56bffd6500..e5f1561439db 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -204,8 +204,8 @@ static int common_perm_mnt_dentry(int op, struct vfsmount *mnt,
204 struct dentry *dentry, u32 mask) 204 struct dentry *dentry, u32 mask)
205{ 205{
206 struct path path = { mnt, dentry }; 206 struct path path = { mnt, dentry };
207 struct path_cond cond = { dentry->d_inode->i_uid, 207 struct path_cond cond = { d_backing_inode(dentry)->i_uid,
208 dentry->d_inode->i_mode 208 d_backing_inode(dentry)->i_mode
209 }; 209 };
210 210
211 return common_perm(op, &path, mask, &cond); 211 return common_perm(op, &path, mask, &cond);
@@ -223,7 +223,7 @@ static int common_perm_mnt_dentry(int op, struct vfsmount *mnt,
223static int common_perm_rm(int op, struct path *dir, 223static int common_perm_rm(int op, struct path *dir,
224 struct dentry *dentry, u32 mask) 224 struct dentry *dentry, u32 mask)
225{ 225{
226 struct inode *inode = dentry->d_inode; 226 struct inode *inode = d_backing_inode(dentry);
227 struct path_cond cond = { }; 227 struct path_cond cond = { };
228 228
229 if (!inode || !dir->mnt || !mediated_filesystem(dentry)) 229 if (!inode || !dir->mnt || !mediated_filesystem(dentry))
@@ -281,8 +281,8 @@ static int apparmor_path_mknod(struct path *dir, struct dentry *dentry,
281 281
282static int apparmor_path_truncate(struct path *path) 282static int apparmor_path_truncate(struct path *path)
283{ 283{
284 struct path_cond cond = { path->dentry->d_inode->i_uid, 284 struct path_cond cond = { d_backing_inode(path->dentry)->i_uid,
285 path->dentry->d_inode->i_mode 285 d_backing_inode(path->dentry)->i_mode
286 }; 286 };
287 287
288 if (!path->mnt || !mediated_filesystem(path->dentry)) 288 if (!path->mnt || !mediated_filesystem(path->dentry))
@@ -327,8 +327,8 @@ static int apparmor_path_rename(struct path *old_dir, struct dentry *old_dentry,
327 if (!unconfined(profile)) { 327 if (!unconfined(profile)) {
328 struct path old_path = { old_dir->mnt, old_dentry }; 328 struct path old_path = { old_dir->mnt, old_dentry };
329 struct path new_path = { new_dir->mnt, new_dentry }; 329 struct path new_path = { new_dir->mnt, new_dentry };
330 struct path_cond cond = { old_dentry->d_inode->i_uid, 330 struct path_cond cond = { d_backing_inode(old_dentry)->i_uid,
331 old_dentry->d_inode->i_mode 331 d_backing_inode(old_dentry)->i_mode
332 }; 332 };
333 333
334 error = aa_path_perm(OP_RENAME_SRC, profile, &old_path, 0, 334 error = aa_path_perm(OP_RENAME_SRC, profile, &old_path, 0,
@@ -354,8 +354,8 @@ static int apparmor_path_chmod(struct path *path, umode_t mode)
354 354
355static int apparmor_path_chown(struct path *path, kuid_t uid, kgid_t gid) 355static int apparmor_path_chown(struct path *path, kuid_t uid, kgid_t gid)
356{ 356{
357 struct path_cond cond = { path->dentry->d_inode->i_uid, 357 struct path_cond cond = { d_backing_inode(path->dentry)->i_uid,
358 path->dentry->d_inode->i_mode 358 d_backing_inode(path->dentry)->i_mode
359 }; 359 };
360 360
361 if (!mediated_filesystem(path->dentry)) 361 if (!mediated_filesystem(path->dentry))
diff --git a/security/commoncap.c b/security/commoncap.c
index f66713bd7450..f2875cd9f677 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -297,7 +297,7 @@ static inline void bprm_clear_caps(struct linux_binprm *bprm)
297 */ 297 */
298int cap_inode_need_killpriv(struct dentry *dentry) 298int cap_inode_need_killpriv(struct dentry *dentry)
299{ 299{
300 struct inode *inode = dentry->d_inode; 300 struct inode *inode = d_backing_inode(dentry);
301 int error; 301 int error;
302 302
303 if (!inode->i_op->getxattr) 303 if (!inode->i_op->getxattr)
@@ -319,7 +319,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
319 */ 319 */
320int cap_inode_killpriv(struct dentry *dentry) 320int cap_inode_killpriv(struct dentry *dentry)
321{ 321{
322 struct inode *inode = dentry->d_inode; 322 struct inode *inode = d_backing_inode(dentry);
323 323
324 if (!inode->i_op->removexattr) 324 if (!inode->i_op->removexattr)
325 return 0; 325 return 0;
@@ -375,7 +375,7 @@ static inline int bprm_caps_from_vfs_caps(struct cpu_vfs_cap_data *caps,
375 */ 375 */
376int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps) 376int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps)
377{ 377{
378 struct inode *inode = dentry->d_inode; 378 struct inode *inode = d_backing_inode(dentry);
379 __u32 magic_etc; 379 __u32 magic_etc;
380 unsigned tocopy, i; 380 unsigned tocopy, i;
381 int size; 381 int size;
diff --git a/security/inode.c b/security/inode.c
index 131a3c49f766..91503b79c5f8 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -27,7 +27,7 @@ static int mount_count;
27 27
28static inline int positive(struct dentry *dentry) 28static inline int positive(struct dentry *dentry)
29{ 29{
30 return dentry->d_inode && !d_unhashed(dentry); 30 return d_really_is_positive(dentry) && !d_unhashed(dentry);
31} 31}
32 32
33static int fill_super(struct super_block *sb, void *data, int silent) 33static int fill_super(struct super_block *sb, void *data, int silent)
@@ -102,14 +102,14 @@ struct dentry *securityfs_create_file(const char *name, umode_t mode,
102 if (!parent) 102 if (!parent)
103 parent = mount->mnt_root; 103 parent = mount->mnt_root;
104 104
105 dir = parent->d_inode; 105 dir = d_inode(parent);
106 106
107 mutex_lock(&dir->i_mutex); 107 mutex_lock(&dir->i_mutex);
108 dentry = lookup_one_len(name, parent, strlen(name)); 108 dentry = lookup_one_len(name, parent, strlen(name));
109 if (IS_ERR(dentry)) 109 if (IS_ERR(dentry))
110 goto out; 110 goto out;
111 111
112 if (dentry->d_inode) { 112 if (d_really_is_positive(dentry)) {
113 error = -EEXIST; 113 error = -EEXIST;
114 goto out1; 114 goto out1;
115 } 115 }
@@ -197,20 +197,20 @@ void securityfs_remove(struct dentry *dentry)
197 return; 197 return;
198 198
199 parent = dentry->d_parent; 199 parent = dentry->d_parent;
200 if (!parent || !parent->d_inode) 200 if (!parent || d_really_is_negative(parent))
201 return; 201 return;
202 202
203 mutex_lock(&parent->d_inode->i_mutex); 203 mutex_lock(&d_inode(parent)->i_mutex);
204 if (positive(dentry)) { 204 if (positive(dentry)) {
205 if (dentry->d_inode) { 205 if (d_really_is_positive(dentry)) {
206 if (d_is_dir(dentry)) 206 if (d_is_dir(dentry))
207 simple_rmdir(parent->d_inode, dentry); 207 simple_rmdir(d_inode(parent), dentry);
208 else 208 else
209 simple_unlink(parent->d_inode, dentry); 209 simple_unlink(d_inode(parent), dentry);
210 dput(dentry); 210 dput(dentry);
211 } 211 }
212 } 212 }
213 mutex_unlock(&parent->d_inode->i_mutex); 213 mutex_unlock(&d_inode(parent)->i_mutex);
214 simple_release_fs(&mount, &mount_count); 214 simple_release_fs(&mount, &mount_count);
215} 215}
216EXPORT_SYMBOL_GPL(securityfs_remove); 216EXPORT_SYMBOL_GPL(securityfs_remove);
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 5e9687f02e1b..159ef3ea4130 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -131,7 +131,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
131 size_t req_xattr_value_len, 131 size_t req_xattr_value_len,
132 char type, char *digest) 132 char type, char *digest)
133{ 133{
134 struct inode *inode = dentry->d_inode; 134 struct inode *inode = d_backing_inode(dentry);
135 struct shash_desc *desc; 135 struct shash_desc *desc;
136 char **xattrname; 136 char **xattrname;
137 size_t xattr_size = 0; 137 size_t xattr_size = 0;
@@ -199,7 +199,7 @@ int evm_calc_hash(struct dentry *dentry, const char *req_xattr_name,
199int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name, 199int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name,
200 const char *xattr_value, size_t xattr_value_len) 200 const char *xattr_value, size_t xattr_value_len)
201{ 201{
202 struct inode *inode = dentry->d_inode; 202 struct inode *inode = d_backing_inode(dentry);
203 struct evm_ima_xattr_data xattr_data; 203 struct evm_ima_xattr_data xattr_data;
204 int rc = 0; 204 int rc = 0;
205 205
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index f589c9a05da2..10f994307a04 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -72,7 +72,7 @@ static void __init evm_init_config(void)
72 72
73static int evm_find_protected_xattrs(struct dentry *dentry) 73static int evm_find_protected_xattrs(struct dentry *dentry)
74{ 74{
75 struct inode *inode = dentry->d_inode; 75 struct inode *inode = d_backing_inode(dentry);
76 char **xattr; 76 char **xattr;
77 int error; 77 int error;
78 int count = 0; 78 int count = 0;
@@ -165,8 +165,8 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
165 /* Replace RSA with HMAC if not mounted readonly and 165 /* Replace RSA with HMAC if not mounted readonly and
166 * not immutable 166 * not immutable
167 */ 167 */
168 if (!IS_RDONLY(dentry->d_inode) && 168 if (!IS_RDONLY(d_backing_inode(dentry)) &&
169 !IS_IMMUTABLE(dentry->d_inode)) 169 !IS_IMMUTABLE(d_backing_inode(dentry)))
170 evm_update_evmxattr(dentry, xattr_name, 170 evm_update_evmxattr(dentry, xattr_name,
171 xattr_value, 171 xattr_value,
172 xattr_value_len); 172 xattr_value_len);
@@ -235,7 +235,7 @@ enum integrity_status evm_verifyxattr(struct dentry *dentry,
235 return INTEGRITY_UNKNOWN; 235 return INTEGRITY_UNKNOWN;
236 236
237 if (!iint) { 237 if (!iint) {
238 iint = integrity_iint_find(dentry->d_inode); 238 iint = integrity_iint_find(d_backing_inode(dentry));
239 if (!iint) 239 if (!iint)
240 return INTEGRITY_UNKNOWN; 240 return INTEGRITY_UNKNOWN;
241 } 241 }
@@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(evm_verifyxattr);
253 */ 253 */
254static enum integrity_status evm_verify_current_integrity(struct dentry *dentry) 254static enum integrity_status evm_verify_current_integrity(struct dentry *dentry)
255{ 255{
256 struct inode *inode = dentry->d_inode; 256 struct inode *inode = d_backing_inode(dentry);
257 257
258 if (!evm_initialized || !S_ISREG(inode->i_mode) || evm_fixmode) 258 if (!evm_initialized || !S_ISREG(inode->i_mode) || evm_fixmode)
259 return 0; 259 return 0;
@@ -293,13 +293,13 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
293 if (evm_status == INTEGRITY_NOXATTRS) { 293 if (evm_status == INTEGRITY_NOXATTRS) {
294 struct integrity_iint_cache *iint; 294 struct integrity_iint_cache *iint;
295 295
296 iint = integrity_iint_find(dentry->d_inode); 296 iint = integrity_iint_find(d_backing_inode(dentry));
297 if (iint && (iint->flags & IMA_NEW_FILE)) 297 if (iint && (iint->flags & IMA_NEW_FILE))
298 return 0; 298 return 0;
299 } 299 }
300out: 300out:
301 if (evm_status != INTEGRITY_PASS) 301 if (evm_status != INTEGRITY_PASS)
302 integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode, 302 integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_backing_inode(dentry),
303 dentry->d_name.name, "appraise_metadata", 303 dentry->d_name.name, "appraise_metadata",
304 integrity_status_msg[evm_status], 304 integrity_status_msg[evm_status],
305 -EPERM, 0); 305 -EPERM, 0);
@@ -379,7 +379,7 @@ void evm_inode_post_setxattr(struct dentry *dentry, const char *xattr_name,
379 */ 379 */
380void evm_inode_post_removexattr(struct dentry *dentry, const char *xattr_name) 380void evm_inode_post_removexattr(struct dentry *dentry, const char *xattr_name)
381{ 381{
382 struct inode *inode = dentry->d_inode; 382 struct inode *inode = d_backing_inode(dentry);
383 383
384 if (!evm_initialized || !evm_protected_xattr(xattr_name)) 384 if (!evm_initialized || !evm_protected_xattr(xattr_name))
385 return; 385 return;
@@ -404,7 +404,7 @@ int evm_inode_setattr(struct dentry *dentry, struct iattr *attr)
404 if ((evm_status == INTEGRITY_PASS) || 404 if ((evm_status == INTEGRITY_PASS) ||
405 (evm_status == INTEGRITY_NOXATTRS)) 405 (evm_status == INTEGRITY_NOXATTRS))
406 return 0; 406 return 0;
407 integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode, 407 integrity_audit_msg(AUDIT_INTEGRITY_METADATA, d_backing_inode(dentry),
408 dentry->d_name.name, "appraise_metadata", 408 dentry->d_name.name, "appraise_metadata",
409 integrity_status_msg[evm_status], -EPERM, 0); 409 integrity_status_msg[evm_status], -EPERM, 0);
410 return -EPERM; 410 return -EPERM;
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index fffcdb0b31f0..4df493e4b3c9 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -165,7 +165,7 @@ void ima_get_hash_algo(struct evm_ima_xattr_data *xattr_value, int xattr_len,
165int ima_read_xattr(struct dentry *dentry, 165int ima_read_xattr(struct dentry *dentry,
166 struct evm_ima_xattr_data **xattr_value) 166 struct evm_ima_xattr_data **xattr_value)
167{ 167{
168 struct inode *inode = dentry->d_inode; 168 struct inode *inode = d_backing_inode(dentry);
169 169
170 if (!inode->i_op->getxattr) 170 if (!inode->i_op->getxattr)
171 return 0; 171 return 0;
@@ -190,7 +190,7 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
190 static const char op[] = "appraise_data"; 190 static const char op[] = "appraise_data";
191 char *cause = "unknown"; 191 char *cause = "unknown";
192 struct dentry *dentry = file->f_path.dentry; 192 struct dentry *dentry = file->f_path.dentry;
193 struct inode *inode = dentry->d_inode; 193 struct inode *inode = d_backing_inode(dentry);
194 enum integrity_status status = INTEGRITY_UNKNOWN; 194 enum integrity_status status = INTEGRITY_UNKNOWN;
195 int rc = xattr_len, hash_start = 0; 195 int rc = xattr_len, hash_start = 0;
196 196
@@ -314,7 +314,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)
314 */ 314 */
315void ima_inode_post_setattr(struct dentry *dentry) 315void ima_inode_post_setattr(struct dentry *dentry)
316{ 316{
317 struct inode *inode = dentry->d_inode; 317 struct inode *inode = d_backing_inode(dentry);
318 struct integrity_iint_cache *iint; 318 struct integrity_iint_cache *iint;
319 int must_appraise, rc; 319 int must_appraise, rc;
320 320
@@ -380,7 +380,7 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
380 if (result == 1) { 380 if (result == 1) {
381 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST)) 381 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
382 return -EINVAL; 382 return -EINVAL;
383 ima_reset_appraise_flags(dentry->d_inode, 383 ima_reset_appraise_flags(d_backing_inode(dentry),
384 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0); 384 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0);
385 result = 0; 385 result = 0;
386 } 386 }
@@ -393,7 +393,7 @@ int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name)
393 393
394 result = ima_protect_xattr(dentry, xattr_name, NULL, 0); 394 result = ima_protect_xattr(dentry, xattr_name, NULL, 0);
395 if (result == 1) { 395 if (result == 1) {
396 ima_reset_appraise_flags(dentry->d_inode, 0); 396 ima_reset_appraise_flags(d_backing_inode(dentry), 0);
397 result = 0; 397 result = 0;
398 } 398 }
399 return result; 399 return result;
diff --git a/security/lsm_audit.c b/security/lsm_audit.c
index b526ddc3add5..1d34277dc402 100644
--- a/security/lsm_audit.c
+++ b/security/lsm_audit.c
@@ -237,7 +237,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
237 237
238 audit_log_d_path(ab, " path=", &a->u.path); 238 audit_log_d_path(ab, " path=", &a->u.path);
239 239
240 inode = a->u.path.dentry->d_inode; 240 inode = d_backing_inode(a->u.path.dentry);
241 if (inode) { 241 if (inode) {
242 audit_log_format(ab, " dev="); 242 audit_log_format(ab, " dev=");
243 audit_log_untrustedstring(ab, inode->i_sb->s_id); 243 audit_log_untrustedstring(ab, inode->i_sb->s_id);
@@ -251,7 +251,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
251 audit_log_format(ab, " name="); 251 audit_log_format(ab, " name=");
252 audit_log_untrustedstring(ab, a->u.dentry->d_name.name); 252 audit_log_untrustedstring(ab, a->u.dentry->d_name.name);
253 253
254 inode = a->u.dentry->d_inode; 254 inode = d_backing_inode(a->u.dentry);
255 if (inode) { 255 if (inode) {
256 audit_log_format(ab, " dev="); 256 audit_log_format(ab, " dev=");
257 audit_log_untrustedstring(ab, inode->i_sb->s_id); 257 audit_log_untrustedstring(ab, inode->i_sb->s_id);
diff --git a/security/security.c b/security/security.c
index 730ac65a5737..8e9b1f4b9b45 100644
--- a/security/security.c
+++ b/security/security.c
@@ -410,7 +410,7 @@ EXPORT_SYMBOL(security_old_inode_init_security);
410int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode, 410int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
411 unsigned int dev) 411 unsigned int dev)
412{ 412{
413 if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) 413 if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
414 return 0; 414 return 0;
415 return security_ops->path_mknod(dir, dentry, mode, dev); 415 return security_ops->path_mknod(dir, dentry, mode, dev);
416} 416}
@@ -418,7 +418,7 @@ EXPORT_SYMBOL(security_path_mknod);
418 418
419int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode) 419int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode)
420{ 420{
421 if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) 421 if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
422 return 0; 422 return 0;
423 return security_ops->path_mkdir(dir, dentry, mode); 423 return security_ops->path_mkdir(dir, dentry, mode);
424} 424}
@@ -426,14 +426,14 @@ EXPORT_SYMBOL(security_path_mkdir);
426 426
427int security_path_rmdir(struct path *dir, struct dentry *dentry) 427int security_path_rmdir(struct path *dir, struct dentry *dentry)
428{ 428{
429 if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) 429 if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
430 return 0; 430 return 0;
431 return security_ops->path_rmdir(dir, dentry); 431 return security_ops->path_rmdir(dir, dentry);
432} 432}
433 433
434int security_path_unlink(struct path *dir, struct dentry *dentry) 434int security_path_unlink(struct path *dir, struct dentry *dentry)
435{ 435{
436 if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) 436 if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
437 return 0; 437 return 0;
438 return security_ops->path_unlink(dir, dentry); 438 return security_ops->path_unlink(dir, dentry);
439} 439}
@@ -442,7 +442,7 @@ EXPORT_SYMBOL(security_path_unlink);
442int security_path_symlink(struct path *dir, struct dentry *dentry, 442int security_path_symlink(struct path *dir, struct dentry *dentry,
443 const char *old_name) 443 const char *old_name)
444{ 444{
445 if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) 445 if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
446 return 0; 446 return 0;
447 return security_ops->path_symlink(dir, dentry, old_name); 447 return security_ops->path_symlink(dir, dentry, old_name);
448} 448}
@@ -450,7 +450,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
450int security_path_link(struct dentry *old_dentry, struct path *new_dir, 450int security_path_link(struct dentry *old_dentry, struct path *new_dir,
451 struct dentry *new_dentry) 451 struct dentry *new_dentry)
452{ 452{
453 if (unlikely(IS_PRIVATE(old_dentry->d_inode))) 453 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
454 return 0; 454 return 0;
455 return security_ops->path_link(old_dentry, new_dir, new_dentry); 455 return security_ops->path_link(old_dentry, new_dir, new_dentry);
456} 456}
@@ -459,8 +459,8 @@ int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
459 struct path *new_dir, struct dentry *new_dentry, 459 struct path *new_dir, struct dentry *new_dentry,
460 unsigned int flags) 460 unsigned int flags)
461{ 461{
462 if (unlikely(IS_PRIVATE(old_dentry->d_inode) || 462 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
463 (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) 463 (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
464 return 0; 464 return 0;
465 465
466 if (flags & RENAME_EXCHANGE) { 466 if (flags & RENAME_EXCHANGE) {
@@ -477,21 +477,21 @@ EXPORT_SYMBOL(security_path_rename);
477 477
478int security_path_truncate(struct path *path) 478int security_path_truncate(struct path *path)
479{ 479{
480 if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 480 if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
481 return 0; 481 return 0;
482 return security_ops->path_truncate(path); 482 return security_ops->path_truncate(path);
483} 483}
484 484
485int security_path_chmod(struct path *path, umode_t mode) 485int security_path_chmod(struct path *path, umode_t mode)
486{ 486{
487 if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 487 if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
488 return 0; 488 return 0;
489 return security_ops->path_chmod(path, mode); 489 return security_ops->path_chmod(path, mode);
490} 490}
491 491
492int security_path_chown(struct path *path, kuid_t uid, kgid_t gid) 492int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
493{ 493{
494 if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 494 if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
495 return 0; 495 return 0;
496 return security_ops->path_chown(path, uid, gid); 496 return security_ops->path_chown(path, uid, gid);
497} 497}
@@ -513,14 +513,14 @@ EXPORT_SYMBOL_GPL(security_inode_create);
513int security_inode_link(struct dentry *old_dentry, struct inode *dir, 513int security_inode_link(struct dentry *old_dentry, struct inode *dir,
514 struct dentry *new_dentry) 514 struct dentry *new_dentry)
515{ 515{
516 if (unlikely(IS_PRIVATE(old_dentry->d_inode))) 516 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
517 return 0; 517 return 0;
518 return security_ops->inode_link(old_dentry, dir, new_dentry); 518 return security_ops->inode_link(old_dentry, dir, new_dentry);
519} 519}
520 520
521int security_inode_unlink(struct inode *dir, struct dentry *dentry) 521int security_inode_unlink(struct inode *dir, struct dentry *dentry)
522{ 522{
523 if (unlikely(IS_PRIVATE(dentry->d_inode))) 523 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
524 return 0; 524 return 0;
525 return security_ops->inode_unlink(dir, dentry); 525 return security_ops->inode_unlink(dir, dentry);
526} 526}
@@ -543,7 +543,7 @@ EXPORT_SYMBOL_GPL(security_inode_mkdir);
543 543
544int security_inode_rmdir(struct inode *dir, struct dentry *dentry) 544int security_inode_rmdir(struct inode *dir, struct dentry *dentry)
545{ 545{
546 if (unlikely(IS_PRIVATE(dentry->d_inode))) 546 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
547 return 0; 547 return 0;
548 return security_ops->inode_rmdir(dir, dentry); 548 return security_ops->inode_rmdir(dir, dentry);
549} 549}
@@ -559,8 +559,8 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
559 struct inode *new_dir, struct dentry *new_dentry, 559 struct inode *new_dir, struct dentry *new_dentry,
560 unsigned int flags) 560 unsigned int flags)
561{ 561{
562 if (unlikely(IS_PRIVATE(old_dentry->d_inode) || 562 if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
563 (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) 563 (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
564 return 0; 564 return 0;
565 565
566 if (flags & RENAME_EXCHANGE) { 566 if (flags & RENAME_EXCHANGE) {
@@ -576,14 +576,14 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
576 576
577int security_inode_readlink(struct dentry *dentry) 577int security_inode_readlink(struct dentry *dentry)
578{ 578{
579 if (unlikely(IS_PRIVATE(dentry->d_inode))) 579 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
580 return 0; 580 return 0;
581 return security_ops->inode_readlink(dentry); 581 return security_ops->inode_readlink(dentry);
582} 582}
583 583
584int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd) 584int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
585{ 585{
586 if (unlikely(IS_PRIVATE(dentry->d_inode))) 586 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
587 return 0; 587 return 0;
588 return security_ops->inode_follow_link(dentry, nd); 588 return security_ops->inode_follow_link(dentry, nd);
589} 589}
@@ -599,7 +599,7 @@ int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
599{ 599{
600 int ret; 600 int ret;
601 601
602 if (unlikely(IS_PRIVATE(dentry->d_inode))) 602 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
603 return 0; 603 return 0;
604 ret = security_ops->inode_setattr(dentry, attr); 604 ret = security_ops->inode_setattr(dentry, attr);
605 if (ret) 605 if (ret)
@@ -610,7 +610,7 @@ EXPORT_SYMBOL_GPL(security_inode_setattr);
610 610
611int security_inode_getattr(const struct path *path) 611int security_inode_getattr(const struct path *path)
612{ 612{
613 if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 613 if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
614 return 0; 614 return 0;
615 return security_ops->inode_getattr(path); 615 return security_ops->inode_getattr(path);
616} 616}
@@ -620,7 +620,7 @@ int security_inode_setxattr(struct dentry *dentry, const char *name,
620{ 620{
621 int ret; 621 int ret;
622 622
623 if (unlikely(IS_PRIVATE(dentry->d_inode))) 623 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
624 return 0; 624 return 0;
625 ret = security_ops->inode_setxattr(dentry, name, value, size, flags); 625 ret = security_ops->inode_setxattr(dentry, name, value, size, flags);
626 if (ret) 626 if (ret)
@@ -634,7 +634,7 @@ int security_inode_setxattr(struct dentry *dentry, const char *name,
634void security_inode_post_setxattr(struct dentry *dentry, const char *name, 634void security_inode_post_setxattr(struct dentry *dentry, const char *name,
635 const void *value, size_t size, int flags) 635 const void *value, size_t size, int flags)
636{ 636{
637 if (unlikely(IS_PRIVATE(dentry->d_inode))) 637 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
638 return; 638 return;
639 security_ops->inode_post_setxattr(dentry, name, value, size, flags); 639 security_ops->inode_post_setxattr(dentry, name, value, size, flags);
640 evm_inode_post_setxattr(dentry, name, value, size); 640 evm_inode_post_setxattr(dentry, name, value, size);
@@ -642,14 +642,14 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,
642 642
643int security_inode_getxattr(struct dentry *dentry, const char *name) 643int security_inode_getxattr(struct dentry *dentry, const char *name)
644{ 644{
645 if (unlikely(IS_PRIVATE(dentry->d_inode))) 645 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
646 return 0; 646 return 0;
647 return security_ops->inode_getxattr(dentry, name); 647 return security_ops->inode_getxattr(dentry, name);
648} 648}
649 649
650int security_inode_listxattr(struct dentry *dentry) 650int security_inode_listxattr(struct dentry *dentry)
651{ 651{
652 if (unlikely(IS_PRIVATE(dentry->d_inode))) 652 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
653 return 0; 653 return 0;
654 return security_ops->inode_listxattr(dentry); 654 return security_ops->inode_listxattr(dentry);
655} 655}
@@ -658,7 +658,7 @@ int security_inode_removexattr(struct dentry *dentry, const char *name)
658{ 658{
659 int ret; 659 int ret;
660 660
661 if (unlikely(IS_PRIVATE(dentry->d_inode))) 661 if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
662 return 0; 662 return 0;
663 ret = security_ops->inode_removexattr(dentry, name); 663 ret = security_ops->inode_removexattr(dentry, name);
664 if (ret) 664 if (ret)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index c318b304ee2f..7dade28affba 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -414,7 +414,7 @@ static int sb_finish_set_opts(struct super_block *sb)
414{ 414{
415 struct superblock_security_struct *sbsec = sb->s_security; 415 struct superblock_security_struct *sbsec = sb->s_security;
416 struct dentry *root = sb->s_root; 416 struct dentry *root = sb->s_root;
417 struct inode *root_inode = root->d_inode; 417 struct inode *root_inode = d_backing_inode(root);
418 int rc = 0; 418 int rc = 0;
419 419
420 if (sbsec->behavior == SECURITY_FS_USE_XATTR) { 420 if (sbsec->behavior == SECURITY_FS_USE_XATTR) {
@@ -552,7 +552,7 @@ static int selinux_get_mnt_opts(const struct super_block *sb,
552 opts->mnt_opts_flags[i++] = DEFCONTEXT_MNT; 552 opts->mnt_opts_flags[i++] = DEFCONTEXT_MNT;
553 } 553 }
554 if (sbsec->flags & ROOTCONTEXT_MNT) { 554 if (sbsec->flags & ROOTCONTEXT_MNT) {
555 struct inode *root = sbsec->sb->s_root->d_inode; 555 struct inode *root = d_backing_inode(sbsec->sb->s_root);
556 struct inode_security_struct *isec = root->i_security; 556 struct inode_security_struct *isec = root->i_security;
557 557
558 rc = security_sid_to_context(isec->sid, &context, &len); 558 rc = security_sid_to_context(isec->sid, &context, &len);
@@ -608,7 +608,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,
608 int rc = 0, i; 608 int rc = 0, i;
609 struct superblock_security_struct *sbsec = sb->s_security; 609 struct superblock_security_struct *sbsec = sb->s_security;
610 const char *name = sb->s_type->name; 610 const char *name = sb->s_type->name;
611 struct inode *inode = sbsec->sb->s_root->d_inode; 611 struct inode *inode = d_backing_inode(sbsec->sb->s_root);
612 struct inode_security_struct *root_isec = inode->i_security; 612 struct inode_security_struct *root_isec = inode->i_security;
613 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0; 613 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0;
614 u32 defcontext_sid = 0; 614 u32 defcontext_sid = 0;
@@ -835,8 +835,8 @@ static int selinux_cmp_sb_context(const struct super_block *oldsb,
835 if ((oldflags & DEFCONTEXT_MNT) && old->def_sid != new->def_sid) 835 if ((oldflags & DEFCONTEXT_MNT) && old->def_sid != new->def_sid)
836 goto mismatch; 836 goto mismatch;
837 if (oldflags & ROOTCONTEXT_MNT) { 837 if (oldflags & ROOTCONTEXT_MNT) {
838 struct inode_security_struct *oldroot = oldsb->s_root->d_inode->i_security; 838 struct inode_security_struct *oldroot = d_backing_inode(oldsb->s_root)->i_security;
839 struct inode_security_struct *newroot = newsb->s_root->d_inode->i_security; 839 struct inode_security_struct *newroot = d_backing_inode(newsb->s_root)->i_security;
840 if (oldroot->sid != newroot->sid) 840 if (oldroot->sid != newroot->sid)
841 goto mismatch; 841 goto mismatch;
842 } 842 }
@@ -886,16 +886,16 @@ static int selinux_sb_clone_mnt_opts(const struct super_block *oldsb,
886 if (!set_fscontext) 886 if (!set_fscontext)
887 newsbsec->sid = sid; 887 newsbsec->sid = sid;
888 if (!set_rootcontext) { 888 if (!set_rootcontext) {
889 struct inode *newinode = newsb->s_root->d_inode; 889 struct inode *newinode = d_backing_inode(newsb->s_root);
890 struct inode_security_struct *newisec = newinode->i_security; 890 struct inode_security_struct *newisec = newinode->i_security;
891 newisec->sid = sid; 891 newisec->sid = sid;
892 } 892 }
893 newsbsec->mntpoint_sid = sid; 893 newsbsec->mntpoint_sid = sid;
894 } 894 }
895 if (set_rootcontext) { 895 if (set_rootcontext) {
896 const struct inode *oldinode = oldsb->s_root->d_inode; 896 const struct inode *oldinode = d_backing_inode(oldsb->s_root);
897 const struct inode_security_struct *oldisec = oldinode->i_security; 897 const struct inode_security_struct *oldisec = oldinode->i_security;
898 struct inode *newinode = newsb->s_root->d_inode; 898 struct inode *newinode = d_backing_inode(newsb->s_root);
899 struct inode_security_struct *newisec = newinode->i_security; 899 struct inode_security_struct *newisec = newinode->i_security;
900 900
901 newisec->sid = oldisec->sid; 901 newisec->sid = oldisec->sid;
@@ -1610,7 +1610,7 @@ static inline int dentry_has_perm(const struct cred *cred,
1610 struct dentry *dentry, 1610 struct dentry *dentry,
1611 u32 av) 1611 u32 av)
1612{ 1612{
1613 struct inode *inode = dentry->d_inode; 1613 struct inode *inode = d_backing_inode(dentry);
1614 struct common_audit_data ad; 1614 struct common_audit_data ad;
1615 1615
1616 ad.type = LSM_AUDIT_DATA_DENTRY; 1616 ad.type = LSM_AUDIT_DATA_DENTRY;
@@ -1625,7 +1625,7 @@ static inline int path_has_perm(const struct cred *cred,
1625 const struct path *path, 1625 const struct path *path,
1626 u32 av) 1626 u32 av)
1627{ 1627{
1628 struct inode *inode = path->dentry->d_inode; 1628 struct inode *inode = d_backing_inode(path->dentry);
1629 struct common_audit_data ad; 1629 struct common_audit_data ad;
1630 1630
1631 ad.type = LSM_AUDIT_DATA_PATH; 1631 ad.type = LSM_AUDIT_DATA_PATH;
@@ -1753,7 +1753,7 @@ static int may_link(struct inode *dir,
1753 int rc; 1753 int rc;
1754 1754
1755 dsec = dir->i_security; 1755 dsec = dir->i_security;
1756 isec = dentry->d_inode->i_security; 1756 isec = d_backing_inode(dentry)->i_security;
1757 1757
1758 ad.type = LSM_AUDIT_DATA_DENTRY; 1758 ad.type = LSM_AUDIT_DATA_DENTRY;
1759 ad.u.dentry = dentry; 1759 ad.u.dentry = dentry;
@@ -1797,7 +1797,7 @@ static inline int may_rename(struct inode *old_dir,
1797 int rc; 1797 int rc;
1798 1798
1799 old_dsec = old_dir->i_security; 1799 old_dsec = old_dir->i_security;
1800 old_isec = old_dentry->d_inode->i_security; 1800 old_isec = d_backing_inode(old_dentry)->i_security;
1801 old_is_dir = d_is_dir(old_dentry); 1801 old_is_dir = d_is_dir(old_dentry);
1802 new_dsec = new_dir->i_security; 1802 new_dsec = new_dir->i_security;
1803 1803
@@ -1827,7 +1827,7 @@ static inline int may_rename(struct inode *old_dir,
1827 if (rc) 1827 if (rc)
1828 return rc; 1828 return rc;
1829 if (d_is_positive(new_dentry)) { 1829 if (d_is_positive(new_dentry)) {
1830 new_isec = new_dentry->d_inode->i_security; 1830 new_isec = d_backing_inode(new_dentry)->i_security;
1831 new_is_dir = d_is_dir(new_dentry); 1831 new_is_dir = d_is_dir(new_dentry);
1832 rc = avc_has_perm(sid, new_isec->sid, 1832 rc = avc_has_perm(sid, new_isec->sid,
1833 new_isec->sclass, 1833 new_isec->sclass,
@@ -1963,7 +1963,7 @@ static int selinux_binder_transfer_file(struct task_struct *from,
1963{ 1963{
1964 u32 sid = task_sid(to); 1964 u32 sid = task_sid(to);
1965 struct file_security_struct *fsec = file->f_security; 1965 struct file_security_struct *fsec = file->f_security;
1966 struct inode *inode = file->f_path.dentry->d_inode; 1966 struct inode *inode = d_backing_inode(file->f_path.dentry);
1967 struct inode_security_struct *isec = inode->i_security; 1967 struct inode_security_struct *isec = inode->i_security;
1968 struct common_audit_data ad; 1968 struct common_audit_data ad;
1969 int rc; 1969 int rc;
@@ -2627,7 +2627,7 @@ static int selinux_sb_remount(struct super_block *sb, void *data)
2627 break; 2627 break;
2628 case ROOTCONTEXT_MNT: { 2628 case ROOTCONTEXT_MNT: {
2629 struct inode_security_struct *root_isec; 2629 struct inode_security_struct *root_isec;
2630 root_isec = sb->s_root->d_inode->i_security; 2630 root_isec = d_backing_inode(sb->s_root)->i_security;
2631 2631
2632 if (bad_option(sbsec, ROOTCONTEXT_MNT, root_isec->sid, sid)) 2632 if (bad_option(sbsec, ROOTCONTEXT_MNT, root_isec->sid, sid))
2633 goto out_bad_option; 2633 goto out_bad_option;
@@ -2727,7 +2727,7 @@ static int selinux_dentry_init_security(struct dentry *dentry, int mode,
2727 struct task_security_struct *tsec; 2727 struct task_security_struct *tsec;
2728 struct inode_security_struct *dsec; 2728 struct inode_security_struct *dsec;
2729 struct superblock_security_struct *sbsec; 2729 struct superblock_security_struct *sbsec;
2730 struct inode *dir = dentry->d_parent->d_inode; 2730 struct inode *dir = d_backing_inode(dentry->d_parent);
2731 u32 newsid; 2731 u32 newsid;
2732 int rc; 2732 int rc;
2733 2733
@@ -2982,7 +2982,7 @@ static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name)
2982static int selinux_inode_setxattr(struct dentry *dentry, const char *name, 2982static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
2983 const void *value, size_t size, int flags) 2983 const void *value, size_t size, int flags)
2984{ 2984{
2985 struct inode *inode = dentry->d_inode; 2985 struct inode *inode = d_backing_inode(dentry);
2986 struct inode_security_struct *isec = inode->i_security; 2986 struct inode_security_struct *isec = inode->i_security;
2987 struct superblock_security_struct *sbsec; 2987 struct superblock_security_struct *sbsec;
2988 struct common_audit_data ad; 2988 struct common_audit_data ad;
@@ -3059,7 +3059,7 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
3059 const void *value, size_t size, 3059 const void *value, size_t size,
3060 int flags) 3060 int flags)
3061{ 3061{
3062 struct inode *inode = dentry->d_inode; 3062 struct inode *inode = d_backing_inode(dentry);
3063 struct inode_security_struct *isec = inode->i_security; 3063 struct inode_security_struct *isec = inode->i_security;
3064 u32 newsid; 3064 u32 newsid;
3065 int rc; 3065 int rc;
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 5fde34326dcf..d2787cca1fcb 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1737,7 +1737,7 @@ static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
1737 inc_nlink(inode); 1737 inc_nlink(inode);
1738 d_add(dentry, inode); 1738 d_add(dentry, inode);
1739 /* bump link count on parent directory, too */ 1739 /* bump link count on parent directory, too */
1740 inc_nlink(dir->d_inode); 1740 inc_nlink(d_inode(dir));
1741 1741
1742 return dentry; 1742 return dentry;
1743} 1743}
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 69fdc384af30..b644757886bc 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -593,7 +593,7 @@ static int smack_sb_copy_data(char *orig, char *smackopts)
593static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data) 593static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data)
594{ 594{
595 struct dentry *root = sb->s_root; 595 struct dentry *root = sb->s_root;
596 struct inode *inode = root->d_inode; 596 struct inode *inode = d_backing_inode(root);
597 struct superblock_smack *sp = sb->s_security; 597 struct superblock_smack *sp = sb->s_security;
598 struct inode_smack *isp; 598 struct inode_smack *isp;
599 struct smack_known *skp; 599 struct smack_known *skp;
@@ -889,15 +889,15 @@ static int smack_inode_link(struct dentry *old_dentry, struct inode *dir,
889 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 889 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
890 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); 890 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry);
891 891
892 isp = smk_of_inode(old_dentry->d_inode); 892 isp = smk_of_inode(d_backing_inode(old_dentry));
893 rc = smk_curacc(isp, MAY_WRITE, &ad); 893 rc = smk_curacc(isp, MAY_WRITE, &ad);
894 rc = smk_bu_inode(old_dentry->d_inode, MAY_WRITE, rc); 894 rc = smk_bu_inode(d_backing_inode(old_dentry), MAY_WRITE, rc);
895 895
896 if (rc == 0 && d_is_positive(new_dentry)) { 896 if (rc == 0 && d_is_positive(new_dentry)) {
897 isp = smk_of_inode(new_dentry->d_inode); 897 isp = smk_of_inode(d_backing_inode(new_dentry));
898 smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry); 898 smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry);
899 rc = smk_curacc(isp, MAY_WRITE, &ad); 899 rc = smk_curacc(isp, MAY_WRITE, &ad);
900 rc = smk_bu_inode(new_dentry->d_inode, MAY_WRITE, rc); 900 rc = smk_bu_inode(d_backing_inode(new_dentry), MAY_WRITE, rc);
901 } 901 }
902 902
903 return rc; 903 return rc;
@@ -913,7 +913,7 @@ static int smack_inode_link(struct dentry *old_dentry, struct inode *dir,
913 */ 913 */
914static int smack_inode_unlink(struct inode *dir, struct dentry *dentry) 914static int smack_inode_unlink(struct inode *dir, struct dentry *dentry)
915{ 915{
916 struct inode *ip = dentry->d_inode; 916 struct inode *ip = d_backing_inode(dentry);
917 struct smk_audit_info ad; 917 struct smk_audit_info ad;
918 int rc; 918 int rc;
919 919
@@ -956,8 +956,8 @@ static int smack_inode_rmdir(struct inode *dir, struct dentry *dentry)
956 /* 956 /*
957 * You need write access to the thing you're removing 957 * You need write access to the thing you're removing
958 */ 958 */
959 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); 959 rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
960 rc = smk_bu_inode(dentry->d_inode, MAY_WRITE, rc); 960 rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
961 if (rc == 0) { 961 if (rc == 0) {
962 /* 962 /*
963 * You also need write access to the containing directory 963 * You also need write access to the containing directory
@@ -995,15 +995,15 @@ static int smack_inode_rename(struct inode *old_inode,
995 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 995 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
996 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry); 996 smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry);
997 997
998 isp = smk_of_inode(old_dentry->d_inode); 998 isp = smk_of_inode(d_backing_inode(old_dentry));
999 rc = smk_curacc(isp, MAY_READWRITE, &ad); 999 rc = smk_curacc(isp, MAY_READWRITE, &ad);
1000 rc = smk_bu_inode(old_dentry->d_inode, MAY_READWRITE, rc); 1000 rc = smk_bu_inode(d_backing_inode(old_dentry), MAY_READWRITE, rc);
1001 1001
1002 if (rc == 0 && d_is_positive(new_dentry)) { 1002 if (rc == 0 && d_is_positive(new_dentry)) {
1003 isp = smk_of_inode(new_dentry->d_inode); 1003 isp = smk_of_inode(d_backing_inode(new_dentry));
1004 smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry); 1004 smk_ad_setfield_u_fs_path_dentry(&ad, new_dentry);
1005 rc = smk_curacc(isp, MAY_READWRITE, &ad); 1005 rc = smk_curacc(isp, MAY_READWRITE, &ad);
1006 rc = smk_bu_inode(new_dentry->d_inode, MAY_READWRITE, rc); 1006 rc = smk_bu_inode(d_backing_inode(new_dentry), MAY_READWRITE, rc);
1007 } 1007 }
1008 return rc; 1008 return rc;
1009} 1009}
@@ -1060,8 +1060,8 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)
1060 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 1060 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
1061 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 1061 smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
1062 1062
1063 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); 1063 rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
1064 rc = smk_bu_inode(dentry->d_inode, MAY_WRITE, rc); 1064 rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
1065 return rc; 1065 return rc;
1066} 1066}
1067 1067
@@ -1075,7 +1075,7 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)
1075static int smack_inode_getattr(const struct path *path) 1075static int smack_inode_getattr(const struct path *path)
1076{ 1076{
1077 struct smk_audit_info ad; 1077 struct smk_audit_info ad;
1078 struct inode *inode = path->dentry->d_inode; 1078 struct inode *inode = d_backing_inode(path->dentry);
1079 int rc; 1079 int rc;
1080 1080
1081 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); 1081 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
@@ -1142,8 +1142,8 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name,
1142 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 1142 smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
1143 1143
1144 if (rc == 0) { 1144 if (rc == 0) {
1145 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); 1145 rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
1146 rc = smk_bu_inode(dentry->d_inode, MAY_WRITE, rc); 1146 rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
1147 } 1147 }
1148 1148
1149 return rc; 1149 return rc;
@@ -1164,7 +1164,7 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
1164 const void *value, size_t size, int flags) 1164 const void *value, size_t size, int flags)
1165{ 1165{
1166 struct smack_known *skp; 1166 struct smack_known *skp;
1167 struct inode_smack *isp = dentry->d_inode->i_security; 1167 struct inode_smack *isp = d_backing_inode(dentry)->i_security;
1168 1168
1169 if (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) { 1169 if (strcmp(name, XATTR_NAME_SMACKTRANSMUTE) == 0) {
1170 isp->smk_flags |= SMK_INODE_TRANSMUTE; 1170 isp->smk_flags |= SMK_INODE_TRANSMUTE;
@@ -1209,8 +1209,8 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
1209 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 1209 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
1210 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 1210 smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
1211 1211
1212 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad); 1212 rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_READ, &ad);
1213 rc = smk_bu_inode(dentry->d_inode, MAY_READ, rc); 1213 rc = smk_bu_inode(d_backing_inode(dentry), MAY_READ, rc);
1214 return rc; 1214 return rc;
1215} 1215}
1216 1216
@@ -1246,12 +1246,12 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name)
1246 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY); 1246 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
1247 smk_ad_setfield_u_fs_path_dentry(&ad, dentry); 1247 smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
1248 1248
1249 rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad); 1249 rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
1250 rc = smk_bu_inode(dentry->d_inode, MAY_WRITE, rc); 1250 rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
1251 if (rc != 0) 1251 if (rc != 0)
1252 return rc; 1252 return rc;
1253 1253
1254 isp = dentry->d_inode->i_security; 1254 isp = d_backing_inode(dentry)->i_security;
1255 /* 1255 /*
1256 * Don't do anything special for these. 1256 * Don't do anything special for these.
1257 * XATTR_NAME_SMACKIPIN 1257 * XATTR_NAME_SMACKIPIN
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 06f719ed63c9..d9682985349e 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2490,7 +2490,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
2490 return rc; 2490 return rc;
2491 } 2491 }
2492 2492
2493 root_inode = sb->s_root->d_inode; 2493 root_inode = d_inode(sb->s_root);
2494 2494
2495 return 0; 2495 return 0;
2496} 2496}
diff --git a/security/tomoyo/condition.c b/security/tomoyo/condition.c
index 63681e8be628..6c4528d4b48f 100644
--- a/security/tomoyo/condition.c
+++ b/security/tomoyo/condition.c
@@ -714,7 +714,7 @@ void tomoyo_get_attributes(struct tomoyo_obj_info *obj)
714 dentry = dget_parent(dentry); 714 dentry = dget_parent(dentry);
715 break; 715 break;
716 } 716 }
717 inode = dentry->d_inode; 717 inode = d_backing_inode(dentry);
718 if (inode) { 718 if (inode) {
719 struct tomoyo_mini_stat *stat = &obj->stat[i]; 719 struct tomoyo_mini_stat *stat = &obj->stat[i];
720 stat->uid = inode->i_uid; 720 stat->uid = inode->i_uid;
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 1e0d480ff6a6..5077f1968841 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -97,7 +97,7 @@ static char *tomoyo_get_absolute_path(const struct path *path, char * const buff
97 /* go to whatever namespace root we are under */ 97 /* go to whatever namespace root we are under */
98 pos = d_absolute_path(path, buffer, buflen - 1); 98 pos = d_absolute_path(path, buffer, buflen - 1);
99 if (!IS_ERR(pos) && *pos == '/' && pos[1]) { 99 if (!IS_ERR(pos) && *pos == '/' && pos[1]) {
100 struct inode *inode = path->dentry->d_inode; 100 struct inode *inode = d_backing_inode(path->dentry);
101 if (inode && S_ISDIR(inode->i_mode)) { 101 if (inode && S_ISDIR(inode->i_mode)) {
102 buffer[buflen - 2] = '/'; 102 buffer[buflen - 2] = '/';
103 buffer[buflen - 1] = '\0'; 103 buffer[buflen - 1] = '\0';
@@ -125,7 +125,7 @@ static char *tomoyo_get_dentry_path(struct dentry *dentry, char * const buffer,
125 if (buflen >= 256) { 125 if (buflen >= 256) {
126 pos = dentry_path_raw(dentry, buffer, buflen - 1); 126 pos = dentry_path_raw(dentry, buffer, buflen - 1);
127 if (!IS_ERR(pos) && *pos == '/' && pos[1]) { 127 if (!IS_ERR(pos) && *pos == '/' && pos[1]) {
128 struct inode *inode = dentry->d_inode; 128 struct inode *inode = d_backing_inode(dentry);
129 if (inode && S_ISDIR(inode->i_mode)) { 129 if (inode && S_ISDIR(inode->i_mode)) {
130 buffer[buflen - 2] = '/'; 130 buffer[buflen - 2] = '/';
131 buffer[buflen - 1] = '\0'; 131 buffer[buflen - 1] = '\0';
@@ -168,7 +168,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
168 if (!MAJOR(sb->s_dev)) 168 if (!MAJOR(sb->s_dev))
169 goto prepend_filesystem_name; 169 goto prepend_filesystem_name;
170 { 170 {
171 struct inode *inode = sb->s_root->d_inode; 171 struct inode *inode = d_backing_inode(sb->s_root);
172 /* 172 /*
173 * Use filesystem name if filesystem does not support rename() 173 * Use filesystem name if filesystem does not support rename()
174 * operation. 174 * operation.
@@ -219,7 +219,7 @@ out:
219static char *tomoyo_get_socket_name(const struct path *path, char * const buffer, 219static char *tomoyo_get_socket_name(const struct path *path, char * const buffer,
220 const int buflen) 220 const int buflen)
221{ 221{
222 struct inode *inode = path->dentry->d_inode; 222 struct inode *inode = d_backing_inode(path->dentry);
223 struct socket *sock = inode ? SOCKET_I(inode) : NULL; 223 struct socket *sock = inode ? SOCKET_I(inode) : NULL;
224 struct sock *sk = sock ? sock->sk : NULL; 224 struct sock *sk = sock ? sock->sk : NULL;
225 if (sk) { 225 if (sk) {
@@ -277,7 +277,7 @@ char *tomoyo_realpath_from_path(const struct path *path)
277 pos = dentry->d_op->d_dname(dentry, buf, buf_len - 1); 277 pos = dentry->d_op->d_dname(dentry, buf, buf_len - 1);
278 goto encode; 278 goto encode;
279 } 279 }
280 inode = sb->s_root->d_inode; 280 inode = d_backing_inode(sb->s_root);
281 /* 281 /*
282 * Get local name for filesystems without rename() operation 282 * Get local name for filesystems without rename() operation
283 * or dentry without vfsmount. 283 * or dentry without vfsmount.