lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 May 2020 18:32:59 +0200
From:   Miklos Szeredi <mszeredi@...hat.com>
To:     Al Viro <viro@...iv.linux.org.uk>
Cc:     overlayfs <linux-unionfs@...r.kernel.org>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ovl: make private mounts longterm

On Fri, May 22, 2020 at 6:08 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> On Fri, May 22, 2020 at 10:57:23AM +0200, Miklos Szeredi wrote:
> > Overlayfs is using clone_private_mount() to create internal mounts for
> > underlying layers.  These are used for operations requiring a path, such as
> > dentry_open().
> >
> > Since these private mounts are not in any namespace they are treated as
> > short term, "detached" mounts and mntput() involves taking the global
> > mount_lock, which can result in serious cacheline pingpong.
> >
> > Make these private mounts longterm instead, which trade the penalty on
> > mntput() for a slightly longer shutdown time due to an added RCU grace
> > period when putting these mounts.
> >
> > Introduce a new helper kern_unmount_many() that can take care of multiple
> > longterm mounts with a single RCU grace period.
>
> Umm...
>
> 1) Documentation/filesystems/porting - something along the lines
> of "clone_private_mount() returns a longterm mount now, so the proper
> destructor of its result is kern_unmount()"
>
> 2) the name kern_unmount_many() has an unfortunate clash with
> fput_many(), with arguments that look similar and mean something
> entirely different.  How about kern_unmount_array()?
>
> 3)
> > -     mntput(ofs->upper_mnt);
> > -     for (i = 1; i < ofs->numlayer; i++) {
> > -             iput(ofs->layers[i].trap);
> > -             mntput(ofs->layers[i].mnt);
> > +
> > +     if (!ofs->layers) {
> > +             /* Deal with partial setup */
> > +             kern_unmount(ofs->upper_mnt);
> > +     } else {
> > +             /* Hack!  Reuse ofs->layers as a mounts array */
> > +             struct vfsmount **mounts = (struct vfsmount **) ofs->layers;
> > +
> > +             for (i = 0; i < ofs->numlayer; i++) {
> > +                     iput(ofs->layers[i].trap);
> > +                     mounts[i] = ofs->layers[i].mnt;
> > +             }
> > +             kern_unmount_many(mounts, ofs->numlayer);
> > +             kfree(ofs->layers);
>
> That's _way_ too subtle.  AFAICS, you rely upon ->upper_mnt == ->layers[0].mnt,
> ->layers[0].trap == NULL, without even mentioning that.  And the hack you do
> mention...  Yecchhh...  How many layers are possible, again?

500, mounts array would fit inside a page and a page can be allocated
with __GFP_NOFAIL. But why bother?  It's not all that bad, is it?

Thanks,
Miklos

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ