OSDN Git Service

ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
authorAmir Goldstein <amir73il@gmail.com>
Sun, 22 Dec 2019 20:47:54 +0000 (22:47 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 22 Jan 2020 19:11:41 +0000 (20:11 +0100)
The WARN_ON() that child entry is always on overlay st_dev became wrong
when we allowed this function to update d_ino in non-samefs setup with xino
enabled.

It is not true in case of xino bits overflow on a non-dir inode.  Leave the
WARN_ON() only for directories, where assertion is still true.

Fixes: adbf4f7ea834 ("ovl: consistent d_ino for non-samefs with xino")
Cc: <stable@vger.kernel.org> # v4.17+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/readdir.c

index 47a91c9..7255e6a 100644 (file)
@@ -504,7 +504,13 @@ get:
                if (err)
                        goto fail;
 
-               WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev);
+               /*
+                * Directory inode is always on overlay st_dev.
+                * Non-dir with ovl_same_dev() could be on pseudo st_dev in case
+                * of xino bits overflow.
+                */
+               WARN_ON_ONCE(S_ISDIR(stat.mode) &&
+                            dir->d_sb->s_dev != stat.dev);
                ino = stat.ino;
        } else if (xinobits && !OVL_TYPE_UPPER(type)) {
                ino = ovl_remap_lower_ino(ino, xinobits,