[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230914-umtriebe-fahrwasser-7c789fc442f7@brauner>
Date: Thu, 14 Sep 2023 12:01:04 +0200
From: Christian Brauner <brauner@...nel.org>
To: Miklos Szeredi <miklos@...redi.hu>
Cc: Amir Goldstein <amir73il@...il.com>,
Miklos Szeredi <mszeredi@...hat.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-api@...r.kernel.org, linux-man@...r.kernel.org,
linux-security-module@...r.kernel.org, Karel Zak <kzak@...hat.com>,
Ian Kent <raven@...maw.net>,
David Howells <dhowells@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <christian@...uner.io>
Subject: Re: [RFC PATCH 3/3] add listmnt(2) syscall
On Thu, Sep 14, 2023 at 10:50:04AM +0200, Miklos Szeredi wrote:
> On Thu, 14 Sept 2023 at 08:00, Amir Goldstein <amir73il@...il.com> wrote:
>
> > > + if (ctr >= bufsize)
> > > + return -EOVERFLOW;
> > > + if (put_user(r->mnt_id_unique, buf + ctr))
> > > + return -EFAULT;
> > > + ctr++;
> > > + if (ctr < 0)
> > > + return -ERANGE;
> >
> > I think it'd be good for userspace to be able to query required
> > bufsize with NULL buf, listattr style, rather than having to
> > guess and re-guess on EOVERFLOW.
>
> The getxattr/listxattr style encourages the following code:
>
> size = get(NULL, 0);
> buf = alloc(size);
> err = get(buf, size);
> if (err)
> /* failure */
>
> Which is wrong, since the needed buffer size could change between the two calls.
Not a fan of this either tbh.
>
> Doing it iteratively is the only correct way, and then adding
> complexity to both userspace and the kernel for *optimizing* the
> iteration is not really worth it, IMO.
So realistically, userspace nows that an upper bound on the number of
mounts in a mount namespace (expressed in /proc/sys/fs/mount-max usually
100000 - which is often too much ofc).
This is probably insane but I'll power through it: ideally we'd have an
iterator interface that keeps state between calls so we can continue
iterating similar to how readdir/getdents does.
Powered by blists - more mailing lists