linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Seth Forshee <sforshee@digitalocean.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Amir Goldstein <amir73il@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	Christian Brauner <christian.brauner@ubuntu.com>
Subject: Re: [PATCH v2 05/10] docs: update mapping documentation
Date: Thu, 2 Dec 2021 11:27:19 -0600	[thread overview]
Message-ID: <YakB9wVjcEHYuZUr@do-x1extreme> (raw)
In-Reply-To: <20211130121032.3753852-6-brauner@kernel.org>

On Tue, Nov 30, 2021 at 01:10:27PM +0100, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@ubuntu.com>
> 
> Now that we implement the full remapping algorithms described in our
> documentation remove the section about shortcircuting them.
> 
> Link: https://lore.kernel.org/r/20211123114227.3124056-6-brauner@kernel.org (v1)
> Cc: Seth Forshee <sforshee@digitalocean.com>
> Cc: Amir Goldstein <amir73il@gmail.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> CC: linux-fsdevel@vger.kernel.org
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

Reviewed-by: Seth Forshee <sforshee@digitalocean.com>

> ---
> /* v2 */
> unchanged
> ---
>  Documentation/filesystems/idmappings.rst | 72 ------------------------
>  1 file changed, 72 deletions(-)
> 
> diff --git a/Documentation/filesystems/idmappings.rst b/Documentation/filesystems/idmappings.rst
> index 1229a75ec75d..7a879ec3b6bf 100644
> --- a/Documentation/filesystems/idmappings.rst
> +++ b/Documentation/filesystems/idmappings.rst
> @@ -952,75 +952,3 @@ The raw userspace id that is put on disk is ``u1000`` so when the user takes
>  their home directory back to their home computer where they are assigned
>  ``u1000`` using the initial idmapping and mount the filesystem with the initial
>  idmapping they will see all those files owned by ``u1000``.
> -
> -Shortcircuting
> ---------------
> -
> -Currently, the implementation of idmapped mounts enforces that the filesystem
> -is mounted with the initial idmapping. The reason is simply that none of the
> -filesystems that we targeted were mountable with a non-initial idmapping. But
> -that might change soon enough. As we've seen above, thanks to the properties of
> -idmappings the translation works for both filesystems mounted with the initial
> -idmapping and filesystem with non-initial idmappings.
> -
> -Based on this current restriction to filesystem mounted with the initial
> -idmapping two noticeable shortcuts have been taken:
> -
> -1. We always stash a reference to the initial user namespace in ``struct
> -   vfsmount``. Idmapped mounts are thus mounts that have a non-initial user
> -   namespace attached to them.
> -
> -   In order to support idmapped mounts this needs to be changed. Instead of
> -   stashing the initial user namespace the user namespace the filesystem was
> -   mounted with must be stashed. An idmapped mount is then any mount that has
> -   a different user namespace attached then the filesystem was mounted with.
> -   This has no user-visible consequences.
> -
> -2. The translation algorithms in ``mapped_fs*id()`` and ``i_*id_into_mnt()``
> -   are simplified.
> -
> -   Let's consider ``mapped_fs*id()`` first. This function translates the
> -   caller's kernel id into a kernel id in the filesystem's idmapping via
> -   a mount's idmapping. The full algorithm is::
> -
> -    mapped_fsuid(kid):
> -      /* Map the kernel id up into a userspace id in the mount's idmapping. */
> -      from_kuid(mount-idmapping, kid) = uid
> -
> -      /* Map the userspace id down into a kernel id in the filesystem's idmapping. */
> -      make_kuid(filesystem-idmapping, uid) = kuid
> -
> -   We know that the filesystem is always mounted with the initial idmapping as
> -   we enforce this in ``mount_setattr()``. So this can be shortened to::
> -
> -    mapped_fsuid(kid):
> -      /* Map the kernel id up into a userspace id in the mount's idmapping. */
> -      from_kuid(mount-idmapping, kid) = uid
> -
> -      /* Map the userspace id down into a kernel id in the filesystem's idmapping. */
> -      KUIDT_INIT(uid) = kuid
> -
> -   Similarly, for ``i_*id_into_mnt()`` which translated the filesystem's kernel
> -   id into a mount's kernel id::
> -
> -    i_uid_into_mnt(kid):
> -      /* Map the kernel id up into a userspace id in the filesystem's idmapping. */
> -      from_kuid(filesystem-idmapping, kid) = uid
> -
> -      /* Map the userspace id down into a kernel id in the mounts's idmapping. */
> -      make_kuid(mount-idmapping, uid) = kuid
> -
> -   Again, we know that the filesystem is always mounted with the initial
> -   idmapping as we enforce this in ``mount_setattr()``. So this can be
> -   shortened to::
> -
> -    i_uid_into_mnt(kid):
> -      /* Map the kernel id up into a userspace id in the filesystem's idmapping. */
> -      __kuid_val(kid) = uid
> -
> -      /* Map the userspace id down into a kernel id in the mounts's idmapping. */
> -      make_kuid(mount-idmapping, uid) = kuid
> -
> -Handling filesystems mounted with non-initial idmappings requires that the
> -translation functions be converted to their full form. They can still be
> -shortcircuited on non-idmapped mounts. This has no user-visible consequences.
> -- 
> 2.30.2
> 

  reply	other threads:[~2021-12-02 17:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 12:10 [PATCH v2 00/10] Extend and tweak mapping support Christian Brauner
2021-11-30 12:10 ` [PATCH v2 01/10] fs: add is_idmapped_mnt() helper Christian Brauner
2021-12-02 17:09   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 02/10] fs: move mapping helpers Christian Brauner
2021-12-02 17:10   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 03/10] fs: tweak fsuidgid_has_mapping() Christian Brauner
2021-12-02 17:12   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 04/10] fs: account for filesystem mappings Christian Brauner
2021-12-02 17:13   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 05/10] docs: update mapping documentation Christian Brauner
2021-12-02 17:27   ` Seth Forshee [this message]
2021-11-30 12:10 ` [PATCH v2 06/10] fs: use low-level mapping helpers Christian Brauner
2021-12-02 17:34   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 07/10] fs: remove unused " Christian Brauner
2021-12-02 17:39   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 08/10] fs: port higher-level " Christian Brauner
2021-12-02 17:40   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 09/10] fs: add i_user_ns() helper Christian Brauner
2021-12-02 17:40   ` Seth Forshee
2021-11-30 12:10 ` [PATCH v2 10/10] fs: support mapped mounts of mapped filesystems Christian Brauner
2021-12-02 17:50   ` Seth Forshee
2021-12-02 19:20     ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YakB9wVjcEHYuZUr@do-x1extreme \
    --to=sforshee@digitalocean.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).