[PATCH 3/3] ovl: do not follow non-dir origin with redirect_dir=nofollow

Amir Goldstein
2020-07-13T14:20:00Z

Following non-dir origin can result in some bugs when underlying layers
are edited offline. To be on the safe side, do not follow non-dir
origin when not following redirects. This will make overlay lookup
with "redirect_dir=nofollow" behave as pre kernel v4.12 lookup, before
the introduction of the origin xattr.

Link: https://lore.kernel.org/linux-unionfs/CAJfpegv9h7ubuGy_6K4OCdZd3R7Z4HGmCDB2L7mO5bVoGd6MSA@mail.gmail.com/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index ae1c1216a038..31ee5a519736 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -861,7 +861,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
err = -EREMOTE;
goto out;
}
- if (upperdentry && !d.is_dir) {
+ if (upperdentry && !d.is_dir && ofs->config.redirect_follow) {
unsigned int origin_ctr = 0;

/*
--
2.17.1