ovl: lookup ENAMETOOLONG on lower means ENOENT
authorMiklos Szeredi <mszeredi@suse.cz>
Fri, 12 Dec 2014 23:59:45 +0000 (00:59 +0100)
committerMiklos Szeredi <mszeredi@suse.cz>
Fri, 12 Dec 2014 23:59:45 +0000 (00:59 +0100)
"Suppose you have in one of the lower layers a filesystem with
->lookup()-enforced upper limit on name length.  Pretty much every local fs
has one, but... they are not all equal.  255 characters is the common upper
limit, but e.g. jffs2 stops at 254, minixfs upper limit is somewhere from
14 to 60, depending upon version, etc.  You are doing a lookup for
something that is present in upper layer, but happens to be too long for
one of the lower layers.  Too bad - ENAMETOOLONG for you..."

Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
fs/overlayfs/super.c

index 5dbc678..110c968 100644 (file)
@@ -376,8 +376,14 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
                opaque = false;
                this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name);
                err = PTR_ERR(this);
-               if (IS_ERR(this))
+               if (IS_ERR(this)) {
+                       /*
+                        * If it's positive, then treat ENAMETOOLONG as ENOENT.
+                        */
+                       if (err == -ENAMETOOLONG && (upperdentry || ctr))
+                               continue;
                        goto out_put;
+               }
                if (!this)
                        continue;
                if (ovl_is_whiteout(this)) {