userns mount and metacopy redirects (Was: Re: [PATCH v3 0/6] Composefs: an opportunistically sharing verified image filesystem)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[spawning overlayfs sub-topic]

On Wed, Jan 25, 2023 at 10:29 PM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> On Wed, Jan 25, 2023 at 10:23 PM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
> >
> > On Wed, Jan 25, 2023 at 9:45 PM Giuseppe Scrivano <gscrivan@xxxxxxxxxx> wrote:
> > >
> > > Amir Goldstein <amir73il@xxxxxxxxx> 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.



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux