Commit 9da7cb2a authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Thadeu Lima de Souza Cascardo

ovl: check mounter creds on underlying lookup

BugLink: http://bugs.launchpad.net/bugs/1659417

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 3c9fe8cd ("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: default avatarMiklos Szeredi <mszeredi@redhat.com>
Fixes: 8387ff25 ("vfs: make the string hashes salt the hash")
(backported from commit c1b2cc1a)
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarTim Gardner <tim.gardner@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent 73c42eac
...@@ -456,14 +456,18 @@ static bool ovl_dentry_weird(struct dentry *dentry) ...@@ -456,14 +456,18 @@ static bool ovl_dentry_weird(struct dentry *dentry)
DCACHE_OP_COMPARE); DCACHE_OP_COMPARE);
} }
static inline struct dentry *ovl_lookup_real(struct dentry *dir, static inline struct dentry *ovl_lookup_real(struct super_block *ovl_sb,
struct dentry *dir,
struct qstr *name) struct qstr *name)
{ {
const struct cred *old_cred;
struct dentry *dentry; struct dentry *dentry;
old_cred = ovl_override_creds(ovl_sb);
mutex_lock(&dir->d_inode->i_mutex); mutex_lock(&dir->d_inode->i_mutex);
dentry = lookup_one_len(name->name, dir, name->len); dentry = lookup_one_len(name->name, dir, name->len);
mutex_unlock(&dir->d_inode->i_mutex); mutex_unlock(&dir->d_inode->i_mutex);
revert_creds(old_cred);
if (IS_ERR(dentry)) { if (IS_ERR(dentry)) {
if (PTR_ERR(dentry) == -ENOENT) if (PTR_ERR(dentry) == -ENOENT)
...@@ -517,7 +521,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, ...@@ -517,7 +521,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
upperdir = ovl_upperdentry_dereference(poe); upperdir = ovl_upperdentry_dereference(poe);
if (upperdir) { if (upperdir) {
this = ovl_lookup_real(upperdir, &dentry->d_name); this = ovl_lookup_real(dentry->d_sb, upperdir, &dentry->d_name);
err = PTR_ERR(this); err = PTR_ERR(this);
if (IS_ERR(this)) if (IS_ERR(this))
goto out; goto out;
...@@ -550,7 +554,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, ...@@ -550,7 +554,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
bool opaque = false; bool opaque = false;
struct path lowerpath = poe->lowerstack[i]; struct path lowerpath = poe->lowerstack[i];
this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name); this = ovl_lookup_real(dentry->d_sb,
lowerpath.dentry, &dentry->d_name);
err = PTR_ERR(this); err = PTR_ERR(this);
if (IS_ERR(this)) { if (IS_ERR(this)) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment