Re: [PATCH for-8.0] aio-posix: fix race between epoll upgrade and aio_set_fd_handler()

2023-03-23 Thread Stefan Hajnoczi
On Thu, Mar 23, 2023 at 06:02:36AM +0100, Paolo Bonzini wrote: > Il mer 22 mar 2023, 15:55 Stefan Hajnoczi ha scritto: > > > +/* The list must not change while we add fds to epoll */ > > +if (!qemu_lockcnt_dec_if_lock(>list_lock)) { > > +return false; > > +} > > + > > +ok

Re: [PATCH for-8.0] aio-posix: fix race between epoll upgrade and aio_set_fd_handler()

2023-03-22 Thread Paolo Bonzini
Il mer 22 mar 2023, 15:55 Stefan Hajnoczi ha scritto: > +/* The list must not change while we add fds to epoll */ > +if (!qemu_lockcnt_dec_if_lock(>list_lock)) { > +return false; > +} > + > +ok = fdmon_epoll_try_enable(ctx); > + > +qemu_lockcnt_unlock(>list_lock); >

[PATCH for-8.0] aio-posix: fix race between epoll upgrade and aio_set_fd_handler()

2023-03-22 Thread Stefan Hajnoczi
If another thread calls aio_set_fd_handler() while the IOThread event loop is upgrading from ppoll(2) to epoll(7) then we might miss new AioHandlers. The epollfd will not monitor the new AioHandler's fd, resulting in hangs. Take the AioHandler list lock while upgrading to epoll. This prevents