aboutsummaryrefslogtreecommitdiffstats
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-07-29 06:05:22 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2016-07-29 06:05:22 -0400
commitc1b2cc1a765aff4df7b22abe6b66014236f73eba (patch)
tree4c636a9e95f0c0baf9cc4906bca897d8daab7558 /fs/overlayfs
parent1b91dbdd2938a0102fea2d8853073159f2b08deb (diff)
ovl: check mounter creds on underlying lookup
The hash salting changes meant that we can no longer reuse the hash in the overlay dentry to look up the underlying dentry. Instead of lookup_hash(), use lookup_one_len_unlocked() and swith to mounter's creds (like we do for all other operations later in the series). Now the lookup_hash() export introduced in 4.6 by 3c9fe8cdff1b ("vfs: add lookup_hash() helper") is unused and can possibly be removed; its usefulness negated by the hash salting and the idea that mounter's creds should be used on operations on underlying filesystems. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: 8387ff2577eb ("vfs: make the string hashes salt the hash")
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/super.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5e254b3a8c56..cbfa0398f9da 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -423,12 +423,16 @@ static bool ovl_dentry_weird(struct dentry *dentry)
423 DCACHE_OP_COMPARE); 423 DCACHE_OP_COMPARE);
424} 424}
425 425
426static inline struct dentry *ovl_lookup_real(struct dentry *dir, 426static inline struct dentry *ovl_lookup_real(struct super_block *ovl_sb,
427 struct dentry *dir,
427 struct qstr *name) 428 struct qstr *name)
428{ 429{
430 const struct cred *old_cred;
429 struct dentry *dentry; 431 struct dentry *dentry;
430 432
431 dentry = lookup_hash(name, dir); 433 old_cred = ovl_override_creds(ovl_sb);
434 dentry = lookup_one_len_unlocked(name->name, dir, name->len);
435 revert_creds(old_cred);
432 436
433 if (IS_ERR(dentry)) { 437 if (IS_ERR(dentry)) {
434 if (PTR_ERR(dentry) == -ENOENT) 438 if (PTR_ERR(dentry) == -ENOENT)
@@ -481,7 +485,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
481 485
482 upperdir = ovl_upperdentry_dereference(poe); 486 upperdir = ovl_upperdentry_dereference(poe);
483 if (upperdir) { 487 if (upperdir) {
484 this = ovl_lookup_real(upperdir, &dentry->d_name); 488 this = ovl_lookup_real(dentry->d_sb, upperdir, &dentry->d_name);
485 err = PTR_ERR(this); 489 err = PTR_ERR(this);
486 if (IS_ERR(this)) 490 if (IS_ERR(this))
487 goto out; 491 goto out;
@@ -514,7 +518,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
514 bool opaque = false; 518 bool opaque = false;
515 struct path lowerpath = poe->lowerstack[i]; 519 struct path lowerpath = poe->lowerstack[i];
516 520
517 this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name); 521 this = ovl_lookup_real(dentry->d_sb,
522 lowerpath.dentry, &dentry->d_name);
518 err = PTR_ERR(this); 523 err = PTR_ERR(this);
519 if (IS_ERR(this)) { 524 if (IS_ERR(this)) {
520 /* 525 /*