Commit 899bf2ce authored by Christian Brauner's avatar Christian Brauner

nfs: do not export idmapped mounts

Prevent nfs from exporting idmapped mounts until we have ported it to
support exporting idmapped mounts.

Link: https://lore.kernel.org/linux-api/20210123130958.3t6kvgkl634njpsm@wittgenstein
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: "J. Bruce Fields" <bfields@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 029a52ad
...@@ -369,8 +369,9 @@ static struct svc_export *svc_export_update(struct svc_export *new, ...@@ -369,8 +369,9 @@ static struct svc_export *svc_export_update(struct svc_export *new,
struct svc_export *old); struct svc_export *old);
static struct svc_export *svc_export_lookup(struct svc_export *); static struct svc_export *svc_export_lookup(struct svc_export *);
static int check_export(struct inode *inode, int *flags, unsigned char *uuid) static int check_export(struct path *path, int *flags, unsigned char *uuid)
{ {
struct inode *inode = d_inode(path->dentry);
/* /*
* We currently export only dirs, regular files, and (for v4 * We currently export only dirs, regular files, and (for v4
...@@ -394,6 +395,7 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid) ...@@ -394,6 +395,7 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid)
* or an FSID number (so NFSEXP_FSID or ->uuid is needed). * or an FSID number (so NFSEXP_FSID or ->uuid is needed).
* 2: We must be able to find an inode from a filehandle. * 2: We must be able to find an inode from a filehandle.
* This means that s_export_op must be set. * This means that s_export_op must be set.
* 3: We must not currently be on an idmapped mount.
*/ */
if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) && if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
!(*flags & NFSEXP_FSID) && !(*flags & NFSEXP_FSID) &&
...@@ -408,6 +410,11 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid) ...@@ -408,6 +410,11 @@ static int check_export(struct inode *inode, int *flags, unsigned char *uuid)
return -EINVAL; return -EINVAL;
} }
if (mnt_user_ns(path->mnt) != &init_user_ns) {
dprintk("exp_export: export of idmapped mounts not yet supported.\n");
return -EINVAL;
}
if (inode->i_sb->s_export_op->flags & EXPORT_OP_NOSUBTREECHK && if (inode->i_sb->s_export_op->flags & EXPORT_OP_NOSUBTREECHK &&
!(*flags & NFSEXP_NOSUBTREECHECK)) { !(*flags & NFSEXP_NOSUBTREECHECK)) {
dprintk("%s: %s does not support subtree checking!\n", dprintk("%s: %s does not support subtree checking!\n",
...@@ -636,8 +643,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) ...@@ -636,8 +643,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
goto out4; goto out4;
} }
err = check_export(d_inode(exp.ex_path.dentry), &exp.ex_flags, err = check_export(&exp.ex_path, &exp.ex_flags, exp.ex_uuid);
exp.ex_uuid);
if (err) if (err)
goto out4; goto out4;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment