aboutsummaryrefslogtreecommitdiffstats
path: root/fs/overlayfs/namei.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-12-16 11:02:56 +0100
committerMiklos Szeredi <mszeredi@redhat.com>2016-12-16 11:02:56 +0100
commit6b2d5fe46fa8f4fc1c5262c73930b9a2a94db2e3 (patch)
tree1a4992b61001040deba77869064b265ef433f143 /fs/overlayfs/namei.c
parentovl: split super.c (diff)
downloadlinux-dev-6b2d5fe46fa8f4fc1c5262c73930b9a2a94db2e3.tar.xz
linux-dev-6b2d5fe46fa8f4fc1c5262c73930b9a2a94db2e3.zip
ovl: check namelen
We already calculate f_namelen in statfs as the maximum of the name lengths provided by the filesystems taking part in the overlay. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/namei.c')
-rw-r--r--fs/overlayfs/namei.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index f4057fcb0246..2e0b84c68ef6 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -20,7 +20,8 @@ static struct dentry *ovl_lookup_real(struct dentry *dir,
dentry = lookup_one_len_unlocked(name->name, dir, name->len);
if (IS_ERR(dentry)) {
- if (PTR_ERR(dentry) == -ENOENT)
+ if (PTR_ERR(dentry) == -ENOENT ||
+ PTR_ERR(dentry) == -ENAMETOOLONG)
dentry = NULL;
} else if (!dentry->d_inode) {
dput(dentry);
@@ -74,6 +75,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
{
struct ovl_entry *oe;
const struct cred *old_cred;
+ struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
struct ovl_entry *poe = dentry->d_parent->d_fsdata;
struct path *stack = NULL;
struct dentry *upperdir, *upperdentry = NULL;
@@ -86,6 +88,9 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
unsigned int i;
int err;
+ if (dentry->d_name.len > ofs->namelen)
+ return ERR_PTR(-ENAMETOOLONG);
+
old_cred = ovl_override_creds(dentry->d_sb);
upperdir = ovl_upperdentry_dereference(poe);
if (upperdir) {
@@ -127,14 +132,9 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name);
err = PTR_ERR(this);
- if (IS_ERR(this)) {
- /*
- * If it's positive, then treat ENAMETOOLONG as ENOENT.
- */
- if (err == -ENAMETOOLONG && (upperdentry || ctr))
- continue;
+ if (IS_ERR(this))
goto out_put;
- }
+
if (!this)
continue;
if (ovl_is_whiteout(this)) {