From: Amir Goldstein Date: Wed, 10 Jan 2018 20:29:38 +0000 (+0200) Subject: ovl: verify stored origin fh matches lower dir X-Git-Tag: rel_imx_4.19.35_1.1.0~10739^2~35 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=37b12916c0f802d956c767db984801d3100c6524;p=linux.git ovl: verify stored origin fh matches lower dir When the NFS export feature is enabled, overlayfs implicitly enables the feature "verify_lower". When the "verify_lower" feature is enabled, a directory inode found in lower layer by name or by redirect_dir is verified against the file handle of the copy up origin that is stored in the upper layer. This introduces a change of behavior for the case of lower layer modification while overlay is offline. A lower directory created or moved offline under an exisitng upper directory, will not be merged with that upper directory. The NFS export feature should not be used after copying layers, because the new lower directory inodes would fail verification and won't be merged with upper directories. Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 11e164cb2593..69ca8eb07519 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -737,6 +737,18 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, } } + /* + * When "verify_lower" feature is enabled, do not merge with a + * lower dir that does not match a stored origin xattr. + */ + if (upperdentry && !ctr && ovl_verify_lower(dentry->d_sb)) { + err = ovl_verify_origin(upperdentry, this, false); + if (err) { + dput(this); + break; + } + } + stack[ctr].dentry = this; stack[ctr].layer = lower.layer; ctr++;