Re: [PATCH 31/34] vfs: syscall: Add fspick() to select a superblock for reconfiguration [ver #12]

From: Alan Jenkins
Date: Wed Oct 17 2018 - 13:41:30 EST

On 17/10/2018 16:45, David Howells wrote:
Alan Jenkins <alan.christopher.jenkins@xxxxxxxxx> wrote:

I agree. I'm happy to see this is using the same check as do_remount().

* change filesystem flags. dir should be a physical root of filesystem.
* If you've mounted a non-root directory somewhere and want to do remount
* on it - tough luck.
Are you suggesting that it should only work at the ultimate root of a
superblock and not a bind mount somewhere within?

That's tricky to make work for NFS because s_root is a dummy dentry.


Retro-actively: I do not suggest that.

I tried to answer this question in my reply to Eric correcting me. Eric was right to correct me. I now understand the comment above do_remount() is incorrect. I re-reviewed your diff in light of that. I re-endorse your diff as a way to solve the problem I raised.

(I think it would be useful to remove the misleading comment above do_remount(), to avoid future confusion.)

> @@ -186,6 +186,10 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags

if (ret < 0)
goto err;
+ ret = -EINVAL;
+ if (target.mnt->mnt_root != target.dentry)
+ goto err_path;

( the "if" statement it adds to fspick() is equivalent to the second "if" statement in do_remount(): )

static int do_remount <>(struct path <> *path <>, int ms_flags, int sb_flags,
int mnt_flags, void *data)
int err;
struct super_block <> *sb = path <>->mnt <>->mnt_sb;
struct mount <> *mnt <> = real_mount <>(path <>->mnt <>);

if (!check_mnt <>(mnt <>))
return -EINVAL <>;

if (path <>->dentry != path <>->mnt <>->mnt_root)
return -EINVAL <>;