ovl: fix EIO from lookup of non-indexed upper
authorAmir Goldstein <amir73il@gmail.com>
Thu, 12 Oct 2017 16:03:04 +0000 (19:03 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 24 Oct 2017 14:06:16 +0000 (16:06 +0200)
commit6eaf011144af10cad34c0d46f82e50d382c8e926
tree1b4e2491fe0a90dd60bad88c1bfa14b488cf6677
parent0ce5cdc9d79277e55c3d80bf7d2b1adea2752078
ovl: fix EIO from lookup of non-indexed upper

Commit fbaf94ee3cd5 ("ovl: don't set origin on broken lower hardlink")
attempt to avoid the condition of non-indexed upper inode with lower
hardlink as origin. If this condition is found, lookup returns EIO.

The protection of commit mentioned above does not cover the case of lower
that is not a hardlink when it is copied up (with either index=off/on)
and then lower is hardlinked while overlay is offline.

Changes to lower layer while overlayfs is offline should not result in
unexpected behavior, so a permanent EIO error after creating a link in
lower layer should not be considered as correct behavior.

This fix replaces EIO error with success in cases where upper has origin
but no index is found, or index is found that does not match upper
inode. In those cases, lookup will not fail and the returned overlay inode
will be hashed by upper inode instead of by lower origin inode.

Fixes: 359f392ca53e ("ovl: lookup index entry for copy up origin")
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/inode.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h