[PATCH v6 24/40] fs: make helpers idmap mount aware

Linus Torvalds torvalds at linux-foundation.org
Mon Apr 12 16:23:38 UTC 2021

On Mon, Apr 12, 2021 at 5:05 AM Anton Altaparmakov <anton at tuxera.com> wrote:
> Shouldn't that be using mnt_userns instead of &init_user_ns both for the setattr_prepare() and setattr_copy() calls?

It doesn't matter for a filesystem that hasn't marked itself as
supporting idmaps.

If the filesystem doesn't set FS_ALLOW_IDMAP, then mnt_userns is
always going to be &init_user_ns.

That said, I don't think you are wrong - it would probably be a good
idea to pass down the 'mnt_userns' argument just to avoid confusion.
But if you look at the history, you'll see that adding the mount
namespace argument to the helper functions (like setattr_copy())
happened before the actual "switch the filesystem setattr() function
over to get the namespace argument".

So the current situation is partly an artifact of how the incremental
filesystem changes were done.


More information about the Linux-security-module-archive mailing list