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] [day] [month] [year] [list]
Message-ID: <ZGxjZXHvvJcCafxT@ip-172-31-38-16.us-west-2.compute.internal>
Date:   Tue, 23 May 2023 06:55:33 +0000
From:   Alok Tiagi <aloktiagi@...il.com>
To:     Christian Brauner <brauner@...nel.org>
Cc:     viro@...iv.linux.org.uk, willy@...radead.org,
        David.Laight@...lab.com, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, keescook@...omium.org,
        hch@...radead.org, tycho@...ho.pizza, aloktiagi@...il.com
Subject: Re: [RFC v5 1/2] epoll: Implement eventpoll_replace_file()

On Sat, May 20, 2023 at 03:03:48PM +0200, Christian Brauner wrote:
> On Sat, Apr 29, 2023 at 05:49:54AM +0000, aloktiagi wrote:
> > Introduce a mechanism to replace a file linked in the epoll interface with a new
> > file.
> > 
> > eventpoll_replace() finds all instances of the file to be replaced and replaces
> > them with the new file and the interested events.
> > 
> > Signed-off-by: aloktiagi <aloktiagi@...il.com>
> > ---
> > Changes in v5:
> >   - address review comments and move the call to replace old file in each
> >     subsystem (epoll, io_uring, etc.) outside the fdtable helpers like
> >     replace_fd().
> > 
> > Changes in v4:
> >   - address review comment to remove the redundant eventpoll_replace() function.
> >   - removed an extra empty line introduced in include/linux/file.h
> > 
> > Changes in v3:
> >   - address review comment and iterate over the file table while holding the
> >     spin_lock(&files->file_lock).
> >   - address review comment and call filp_close() outside the
> >     spin_lock(&files->file_lock).
> > ---
> >  fs/eventpoll.c            | 65 +++++++++++++++++++++++++++++++++++++++
> >  include/linux/eventpoll.h |  8 +++++
> >  2 files changed, 73 insertions(+)
> > 
> > diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> > index 64659b110973..be9d192b223d 100644
> > --- a/fs/eventpoll.c
> > +++ b/fs/eventpoll.c
> > @@ -935,6 +935,71 @@ void eventpoll_release_file(struct file *file)
> >  	mutex_unlock(&epmutex);
> >  }
> >  
> > +static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,
> > +			struct file *tfile, int fd, int full_check);
> > +
> > +/*
> > + * This is called from eventpoll_replace() to replace a linked file in the epoll
> > + * interface with a new file received from another process. This is useful in
> > + * cases where a process is trying to install a new file for an existing one
> > + * that is linked in the epoll interface
> > + */
> > +int eventpoll_replace_file(struct file *toreplace, struct file *file, int tfd)
> > +{
> > +	int fd;
> > +	int error = 0;
> > +	struct eventpoll *ep;
> > +	struct epitem *epi;
> > +	struct hlist_node *next;
> > +	struct epoll_event event;
> > +	struct hlist_head *to_remove = toreplace->f_ep;
> > +
> > +	if (!file_can_poll(file))
> > +		return 0;
> > +
> > +	mutex_lock(&epmutex);
> 
> Sorry, I missed that you send a new version somehow.
> 
> So, I think I mentioned this last time: The locking has changed to
> reduce contention on the global mutex. Both epmutex and ep_remove() are
> gone. So this doesn't even compile anymore...
> 
>   CC      fs/eventpoll.o
> ../fs/eventpoll.c: In function ‘eventpoll_replace_file’:
> ../fs/eventpoll.c:998:21: error: ‘epmutex’ undeclared (first use in this function); did you mean ‘mutex’?
>   998 |         mutex_lock(&epmutex);
>       |                     ^~~~~~~
>       |                     mutex
> ../fs/eventpoll.c:998:21: note: each undeclared identifier is reported only once for each function it appears in
> ../fs/eventpoll.c:1034:17: error: implicit declaration of function ‘ep_remove’; did you mean ‘idr_remove’? [-Werror=implicit-function-declaration]
>  1034 |                 ep_remove(ep, epi);
>       |                 ^~~~~~~~~
>       |                 idr_remove
> 
> on current mainline. So please send a new version for this.

Apologies, I didn't realize the change had been merged. Will send out a new version.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ