linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Giuseppe Scrivano <gscrivan@redhat.com>
Cc: Alexander Larsson <alexl@redhat.com>,
	Christian Brauner <brauner@kernel.org>,
	Vivek Goyal <vgoyal@redhat.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	overlayfs <linux-unionfs@vger.kernel.org>
Subject: userns mount and metacopy redirects (Was: Re: [PATCH v3 0/6] Composefs: an opportunistically sharing verified image filesystem)
Date: Thu, 26 Jan 2023 07:26:49 +0200	[thread overview]
Message-ID: <CAOQ4uxi5zpnX1EX3P1Ya4OkRa867NkdtkGcHjTJ9ftvnTL+EhQ@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxiZ4iB82F4i2zMPcyCB8EBFGObdAoBEcar0KE7sA5BoNA@mail.gmail.com>

[spawning overlayfs sub-topic]

On Wed, Jan 25, 2023 at 10:29 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Wed, Jan 25, 2023 at 10:23 PM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > On Wed, Jan 25, 2023 at 9:45 PM Giuseppe Scrivano <gscrivan@redhat.com> wrote:
> > >
> > > Amir Goldstein <amir73il@gmail.com> writes:
> > >
> > > >> >> I previously mentioned my wish of using it from a user namespace, the
> > > >> >> goal seems more challenging with EROFS or any other block devices.  I

For those who are starting to read here, the context is userns mounting
of overlayfs with a lower EROFS layer containing metacopy references to
lower data blobs in another fs (a.k.a the composefs model).

IMO, mounting a readonly image of whatever on-disk format
is a very high risk for userns mount.
A privileged mount helper that verifies and mounts the EROFS
layer sounds like a more feasible solution.

> > > >> >> don't know about the difficulty of getting overlay metacopy working in a
> > > >> >> user namespace, even though it would be helpful for other use cases as
> > > >> >> well.
> > > >> >>
> > > >> >
> > > >> > There is no restriction of metacopy in user namespace.
> > > >> > overlayfs needs to be mounted with -o userxattr and the overlay
> > > >> > xattrs needs to use user.overlay. prefix.
> > > >>
> > > >> if I specify both userxattr and metacopy=on then the mount ends up in
> > > >> the following check:
> > > >>
> > > >> if (config->userxattr) {
> > > >>         [...]
> > > >>         if (config->metacopy && metacopy_opt) {
> > > >>                 pr_err("conflicting options: userxattr,metacopy=on\n");
> > > >>                 return -EINVAL;
> > > >>         }
> > > >> }
> > > >>
> > > >
> > > > Right, my bad.
> > > >
> > > >> to me it looks like it was done on purpose to prevent metacopy from a
> > > >> user namespace, but I don't know the reason for sure.
> > > >>
> > > >
> > > > With hand crafted metacopy, an unpriv user can chmod
> > > > any files to anything by layering another file with different
> > > > mode on top of it....
> > >
> > > I might be missing something obvious about metacopy, so please correct
> > > me if I am wrong, but I don't see how it is any different than just
> > > copying the file and chowning it.  Of course, as long as overlay uses
> > > the same security model so that a file that wasn't originally possible
> > > to access must be still blocked, even if referenced through metacopy.
> > >
> >
> > You're right.
> > The reason for mutual exclusion maybe related to the
> > comment in ovl_check_metacopy_xattr() about EACCES.
> > Need to check with Vivek or Miklos.
> >
> > But get this - you do not need metacopy=on to follow lower inode.
> > It should work without metacopy=on.
> > metacopy=on only instructs overlayfs whether to copy up data
> > or only metadata when changing metadata of lower object, so it is
> > not relevant for readonly mount.
> >
>
> However, you do need redirect=follow and that one is only mutually
> exclusive with userxattr.
> Again, need to ask Miklos whether that could be relaxed under
> some conditions.
>

I can see some possible problems with userns mount and redirect:
- referencing same dir inode from different paths
- referencing same inode from different paths with
  wrong nlink and inconsistent metadata

However, I think a mode that only follows a redirect from a
lower metacopy file to its data should be safe for userns mount.

In this special case (lower metacopy file) we may also be able to
implement the lazy lookup of the data file on open to optimize
'find' performance, but need to figure out what to do with st_blocks
of stat() in that case.

Thanks,
Amir.

       reply	other threads:[~2023-01-26  5:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1674227308.git.alexl@redhat.com>
     [not found] ` <CAOQ4uxgGc33_QVBXMbQTnmbpHio4amv=W7ax2vQ1UMet0k_KoA@mail.gmail.com>
     [not found]   ` <1ea88c8d1e666b85342374ed7c0ddf7d661e0ee1.camel@redhat.com>
     [not found]     ` <CAOQ4uxinsBB-LpGh4h44m6Afv0VT5yWRveDG7sNvE2uJyEGOkg@mail.gmail.com>
     [not found]       ` <5fb32a1297821040edd8c19ce796fc0540101653.camel@redhat.com>
     [not found]         ` <CAOQ4uxhGX9NVxwsiBMP0q21ZRot6-UA0nGPp1wGNjgmKBjjBBA@mail.gmail.com>
     [not found]           ` <20230125041835.GD937597@dread.disaster.area>
     [not found]             ` <CAOQ4uxhqdjRbNFs_LohwXdTpE=MaFv-e8J3D2R57FyJxp_f3nA@mail.gmail.com>
     [not found]               ` <87wn5ac2z6.fsf@redhat.com>
     [not found]                 ` <CAOQ4uxiPLHHnr2=XH4gN4bAjizH-=4mbZMe_sx99FKuPo-fDMQ@mail.gmail.com>
     [not found]                   ` <87o7qmbxv4.fsf@redhat.com>
     [not found]                     ` <CAOQ4uximBLqXDtq9vDhqR__1ctiiOMhMd03HCFUR_Bh_JFE-UQ@mail.gmail.com>
     [not found]                       ` <87fsbybvzq.fsf@redhat.com>
     [not found]                         ` <CAOQ4uxgos8m72icX+u2_6Gh7eMmctTTt6XZ=BRt3VzeOZH+UuQ@mail.gmail.com>
     [not found]                           ` <87wn5a9z4m.fsf@redhat.com>
     [not found]                             ` <CAOQ4uxi7GHVkaqxsQV6ninD9fhvMAPk1xFRM2aMRFXQZUV-s3Q@mail.gmail.com>
     [not found]                               ` <CAOQ4uxiZ4iB82F4i2zMPcyCB8EBFGObdAoBEcar0KE7sA5BoNA@mail.gmail.com>
2023-01-26  5:26                                 ` Amir Goldstein [this message]
2023-01-26  8:22                                   ` userns mount and metacopy redirects (Was: Re: [PATCH v3 0/6] Composefs: an opportunistically sharing verified image filesystem) Christian Brauner
     [not found]           ` <b8601c976d6e5d3eccf6ef489da9768ad72f9571.camel@redhat.com>
     [not found]             ` <e840d413-c1a7-d047-1a63-468b42571846@linux.alibaba.com>
     [not found]               ` <2ef122849d6f35712b56ffbcc95805672980e185.camel@redhat.com>
     [not found]                 ` <8ffa28f5-77f6-6bde-5645-5fb799019bca@linux.alibaba.com>
     [not found]                   ` <51d9d1b3-2b2a-9b58-2f7f-f3a56c9e04ac@linux.alibaba.com>
     [not found]                     ` <071074ad149b189661681aada453995741f75039.camel@redhat.com>
     [not found]                       ` <0d2ef9d6-3b0e-364d-ec2f-c61b19d638e2@linux.alibaba.com>
     [not found]                         ` <de57aefc-30e8-470d-bf61-a1cca6514988@linux.alibaba.com>
     [not found]                           ` <CAOQ4uxgS+-MxydqgO8+NQfOs9N881bHNbov28uJYX9XpthPPiw@mail.gmail.com>
     [not found]                             ` <9c8e76a3-a60a-90a2-f726-46db39bc6558@linux.alibaba.com>
     [not found]                               ` <02edb5d6-a232-eed6-0338-26f9a63cfdb6@linux.alibaba.com>
     [not found]                                 ` <3d4b17795413a696b373553147935bf1560bb8c0.camel@redhat.com>
     [not found]                                   ` <CAOQ4uxjNmM81mgKOBJeScnmeR9+jG_aWvDWxAx7w_dGh0XHg3Q@mail.gmail.com>
     [not found]                                     ` <5fbca304-369d-aeb8-bc60-fdb333ca7a44@linux.alibaba.com>
     [not found]                                       ` <CAOQ4uximQZ_DL1atbrCg0bQ8GN8JfrEartxDSP+GB_hFvYQOhg@mail.gmail.com>
     [not found]                                         ` <CAJfpegtRacAoWdhVxCE8gpLVmQege4yz8u11mvXCs2weBBQ4jg@mail.gmail.com>
     [not found]                                           ` <CAOQ4uxiW0=DJpRAu90pJic0qu=pS6f2Eo7v-Uw3pmd0zsvFuuw@mail.gmail.com>
     [not found]                                             ` <CAJfpeguczp-qOWJgsnKqx6CjCJLV49j1BOWs0Yxv93VUsTZ9AQ@mail.gmail.com>
     [not found]                                               ` <CAOQ4uxg=1zSyTBZ-0_q=5PVuqs=4yQiMQJr1tNk7Kytxv=vuvA@mail.gmail.com>
2023-02-06 18:17                                                 ` [PATCH v3 0/6] Composefs: an opportunistically sharing verified image filesystem Amir Goldstein
2023-04-03 19:00                                                 ` Lazy lowerdata lookup and data-only layers (Was: Re: Composefs:) Amir Goldstein
2023-04-11 15:50                                                   ` Miklos Szeredi
2023-04-12 14:06                                                     ` Amir Goldstein
2023-04-12 14:20                                                       ` Miklos Szeredi
2023-04-12 15:41                                                         ` Amir Goldstein

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=CAOQ4uxi5zpnX1EX3P1Ya4OkRa867NkdtkGcHjTJ9ftvnTL+EhQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=alexl@redhat.com \
    --cc=brauner@kernel.org \
    --cc=gscrivan@redhat.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@redhat.com \
    /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).