Since data-only layers no longer require metacopy=on, which conflicts with nfs_export=on, an overlay with data-only layers can be mounted with nfs_export=on. Decoding a file handle of a lower metacopy file whose data is in a data-only layer builds the inode only from the decoded lower dentry, without the lazy lowerdata redirect, so the data of the file would be read from the metacopy file in the lower layer. Fail the mount with explicit nfs_export=on and data-only layers and otherwise disable nfs_export with data-only layers. Fixes: 5ef7bcdeecc9 ("ovl: relax redirect/metacopy requirements for lower -> data redirect") Cc: stable@vger.kernel.org Signed-off-by: Amir Goldstein --- fs/overlayfs/params.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c index ad7f30177ef4c..7a4e1be5225fa 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -931,6 +931,16 @@ int ovl_fs_params_verify(const struct ovl_fs_context *ctx, } } + /* Resolve nfs_export -> !data-only layers dependency */ + if (config->nfs_export && ctx->nr_data) { + if (set.nfs_export) { + pr_err("NFS export is not supported with data-only layers\n"); + return -EINVAL; + } + pr_info("disabling nfs_export due to data-only layers\n"); + config->nfs_export = false; + } + /* Resolve nfs_export -> index dependency */ if (config->nfs_export && !config->index) { if (!config->upperdir && -- 2.56.0