All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
@ 2026-11-19 14:53 Peter Xu
  2026-11-19 22:29 ` Stefan Hajnoczi
  2026-11-20 17:03 ` Kevin Wolf
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Xu @ 2026-11-19 14:53 UTC (permalink / raw)
  To: qemu-devel
  Cc: peterx, Hongyan Xu, Stefan Hajnoczi, Kevin Wolf, Fabiano Rosas,
	Zhijian Li (Fujitsu)

Hongyan reported a possible use-after-free of RDMA migration code:

https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn

The issue seems real, while this patch is a proposal to fix it in a simpler
way, meanwhile it should be a problem to the yield_until_fd_readable()
helper in general, so it should make more sense to be fixed there too.

The problem is about the use of the stack allocated FDYieldUntilData where
we must make sure after yield_until_fd_readable() returns it's not used
anywhere.  If the coroutine yielded can be entered from outside of this
helper (fd_coroutine_enter()), then the aio handler might be installed even
after yield_until_fd_readable() returns, and that makes the stack variable
accessible by aio codd, even if stack gone.

Fix it by moving the aio handler removal outside the handler.

Reported-by: Hongyan Xu <getshell@seu.edu.cn>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Fabiano Rosas <farosas@suse.de>
Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
Cc: Hongyan Xu <getshell@seu.edu.cn>
Signed-off-by: Peter Xu <peterx@redhat.com>
---

NOTE: I targeted this for 12.0 because the bug was not introduced in 11.2,
however this seems to be a real bug fix to coroutine in general, I'll leave
that to maintainers to decide if to pick it for 11.2.
---
 util/qemu-coroutine-io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
index 364f4d5abf..3c0a7feafa 100644
--- a/util/qemu-coroutine-io.c
+++ b/util/qemu-coroutine-io.c
@@ -74,7 +74,6 @@ typedef struct {
 static void fd_coroutine_enter(void *opaque)
 {
     FDYieldUntilData *data = opaque;
-    aio_set_fd_handler(data->ctx, data->fd, NULL, NULL, NULL, NULL, NULL);
     qemu_coroutine_enter(data->co);
 }
 
@@ -89,4 +88,9 @@ void coroutine_fn yield_until_fd_readable(int fd)
     aio_set_fd_handler(data.ctx, fd, fd_coroutine_enter, NULL, NULL, NULL,
                        &data);
     qemu_coroutine_yield();
+    /*
+     * Always remove the fd handler, no matter the re-entering of this
+     * coroutine was caused by fd_coroutine_enter() or something else.
+     */
+    aio_set_fd_handler(data.ctx, fd, NULL, NULL, NULL, NULL, NULL);
 }
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
  2026-11-19 14:53 [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always Peter Xu
@ 2026-11-19 22:29 ` Stefan Hajnoczi
  2026-11-19 23:05   ` Peter Xu
  2026-11-20 17:11   ` Kevin Wolf
  2026-11-20 17:03 ` Kevin Wolf
  1 sibling, 2 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2026-11-19 22:29 UTC (permalink / raw)
  To: Peter Xu
  Cc: qemu-devel, Hongyan Xu, Kevin Wolf, Fabiano Rosas,
	Zhijian Li (Fujitsu)

On Thu, Nov 19, 2026 at 09:53:11AM -0500, Peter Xu wrote:
> Hongyan reported a possible use-after-free of RDMA migration code:
> 
> https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn
> 
> The issue seems real, while this patch is a proposal to fix it in a simpler
> way, meanwhile it should be a problem to the yield_until_fd_readable()
> helper in general, so it should make more sense to be fixed there too.
> 
> The problem is about the use of the stack allocated FDYieldUntilData where
> we must make sure after yield_until_fd_readable() returns it's not used
> anywhere.  If the coroutine yielded can be entered from outside of this
> helper (fd_coroutine_enter()), then the aio handler might be installed even
> after yield_until_fd_readable() returns, and that makes the stack variable
> accessible by aio codd, even if stack gone.
> 
> Fix it by moving the aio handler removal outside the handler.
> 
> Reported-by: Hongyan Xu <getshell@seu.edu.cn>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Fabiano Rosas <farosas@suse.de>
> Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
> Cc: Hongyan Xu <getshell@seu.edu.cn>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> 
> NOTE: I targeted this for 12.0 because the bug was not introduced in 11.2,
> however this seems to be a real bug fix to coroutine in general, I'll leave
> that to maintainers to decide if to pick it for 11.2.
> ---
>  util/qemu-coroutine-io.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
> index 364f4d5abf..3c0a7feafa 100644
> --- a/util/qemu-coroutine-io.c
> +++ b/util/qemu-coroutine-io.c
> @@ -74,7 +74,6 @@ typedef struct {
>  static void fd_coroutine_enter(void *opaque)
>  {
>      FDYieldUntilData *data = opaque;
> -    aio_set_fd_handler(data->ctx, data->fd, NULL, NULL, NULL, NULL, NULL);
>      qemu_coroutine_enter(data->co);
>  }
>  
> @@ -89,4 +88,9 @@ void coroutine_fn yield_until_fd_readable(int fd)
>      aio_set_fd_handler(data.ctx, fd, fd_coroutine_enter, NULL, NULL, NULL,
>                         &data);
>      qemu_coroutine_yield();
> +    /*
> +     * Always remove the fd handler, no matter the re-entering of this
> +     * coroutine was caused by fd_coroutine_enter() or something else.
> +     */
> +    aio_set_fd_handler(data.ctx, fd, NULL, NULL, NULL, NULL, NULL);
>  }

Why would the coroutine be entered? Should there be a loop around
qemu_coroutine_yield() - otherwise we fix the invalid stack memory
access but return to the caller without fulfilling the purpose of the
function (waiting for the fd to become readable), which could cause
further bugs?

Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
  2026-11-19 22:29 ` Stefan Hajnoczi
@ 2026-11-19 23:05   ` Peter Xu
  2026-11-20 17:01     ` Stefan Hajnoczi
  2026-11-20 17:11   ` Kevin Wolf
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Xu @ 2026-11-19 23:05 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: qemu-devel, Hongyan Xu, Kevin Wolf, Fabiano Rosas,
	Zhijian Li (Fujitsu)

On Thu, Nov 19, 2026 at 05:29:36PM -0500, Stefan Hajnoczi wrote:
> On Thu, Nov 19, 2026 at 09:53:11AM -0500, Peter Xu wrote:
> > Hongyan reported a possible use-after-free of RDMA migration code:
> > 
> > https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn
> > 
> > The issue seems real, while this patch is a proposal to fix it in a simpler
> > way, meanwhile it should be a problem to the yield_until_fd_readable()
> > helper in general, so it should make more sense to be fixed there too.
> > 
> > The problem is about the use of the stack allocated FDYieldUntilData where
> > we must make sure after yield_until_fd_readable() returns it's not used
> > anywhere.  If the coroutine yielded can be entered from outside of this
> > helper (fd_coroutine_enter()), then the aio handler might be installed even
> > after yield_until_fd_readable() returns, and that makes the stack variable
> > accessible by aio codd, even if stack gone.
> > 
> > Fix it by moving the aio handler removal outside the handler.
> > 
> > Reported-by: Hongyan Xu <getshell@seu.edu.cn>
> > Cc: Stefan Hajnoczi <stefanha@redhat.com>
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Cc: Fabiano Rosas <farosas@suse.de>
> > Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
> > Cc: Hongyan Xu <getshell@seu.edu.cn>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > 
> > NOTE: I targeted this for 12.0 because the bug was not introduced in 11.2,
> > however this seems to be a real bug fix to coroutine in general, I'll leave
> > that to maintainers to decide if to pick it for 11.2.
> > ---
> >  util/qemu-coroutine-io.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
> > index 364f4d5abf..3c0a7feafa 100644
> > --- a/util/qemu-coroutine-io.c
> > +++ b/util/qemu-coroutine-io.c
> > @@ -74,7 +74,6 @@ typedef struct {
> >  static void fd_coroutine_enter(void *opaque)
> >  {
> >      FDYieldUntilData *data = opaque;
> > -    aio_set_fd_handler(data->ctx, data->fd, NULL, NULL, NULL, NULL, NULL);
> >      qemu_coroutine_enter(data->co);
> >  }
> >  
> > @@ -89,4 +88,9 @@ void coroutine_fn yield_until_fd_readable(int fd)
> >      aio_set_fd_handler(data.ctx, fd, fd_coroutine_enter, NULL, NULL, NULL,
> >                         &data);
> >      qemu_coroutine_yield();
> > +    /*
> > +     * Always remove the fd handler, no matter the re-entering of this
> > +     * coroutine was caused by fd_coroutine_enter() or something else.
> > +     */
> > +    aio_set_fd_handler(data.ctx, fd, NULL, NULL, NULL, NULL, NULL);
> >  }
> 
> Why would the coroutine be entered?

In case of RDMA, rdma_cm_poll_handler() could receive a disconnect event on
another management fd, then it knows the link is down, hence it needs to
kickoff this coroutine to quit.  See 923709896b1.

> Should there be a loop around
> qemu_coroutine_yield() - otherwise we fix the invalid stack memory
> access but return to the caller without fulfilling the purpose of the
> function (waiting for the fd to become readable), which could cause
> further bugs?

I feel like these are two separate things.

IMO fixing reset of aio handler should be a pure positive fix, because not
fixing it doesn't stop user from re-entering of the coroutine and bypass
fd_coroutine_enter().

My understanding is the caller should have full control of this: when the
caller requires "fd must be readable", it should always wait until
fd_coroutine_enter() returns.  This patch should have no functional
difference.

But it seems still legal if the caller is benign and can properly handle
the case even if fd is still not readable.  In this case, this patch fixes
a real issue.

In case of RDMA migration, only the quit path can cause it to re-enter, so
either there is IO or we need to quit.  RDMA code works well with either
event, it can even loop back and wait on the fd again, but since quit is
the only path kicking this off, it's also not possible even if the caller
handles this.

Thanks,

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
  2026-11-19 23:05   ` Peter Xu
@ 2026-11-20 17:01     ` Stefan Hajnoczi
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2026-11-20 17:01 UTC (permalink / raw)
  To: Peter Xu
  Cc: qemu-devel, Hongyan Xu, Kevin Wolf, Fabiano Rosas,
	Zhijian Li (Fujitsu)

On Thu, Nov 19, 2026 at 06:05:37PM -0500, Peter Xu wrote:
> On Thu, Nov 19, 2026 at 05:29:36PM -0500, Stefan Hajnoczi wrote:
> > On Thu, Nov 19, 2026 at 09:53:11AM -0500, Peter Xu wrote:
> > > Hongyan reported a possible use-after-free of RDMA migration code:
> > > 
> > > https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn
> > > 
> > > The issue seems real, while this patch is a proposal to fix it in a simpler
> > > way, meanwhile it should be a problem to the yield_until_fd_readable()
> > > helper in general, so it should make more sense to be fixed there too.
> > > 
> > > The problem is about the use of the stack allocated FDYieldUntilData where
> > > we must make sure after yield_until_fd_readable() returns it's not used
> > > anywhere.  If the coroutine yielded can be entered from outside of this
> > > helper (fd_coroutine_enter()), then the aio handler might be installed even
> > > after yield_until_fd_readable() returns, and that makes the stack variable
> > > accessible by aio codd, even if stack gone.
> > > 
> > > Fix it by moving the aio handler removal outside the handler.
> > > 
> > > Reported-by: Hongyan Xu <getshell@seu.edu.cn>
> > > Cc: Stefan Hajnoczi <stefanha@redhat.com>
> > > Cc: Kevin Wolf <kwolf@redhat.com>
> > > Cc: Fabiano Rosas <farosas@suse.de>
> > > Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
> > > Cc: Hongyan Xu <getshell@seu.edu.cn>
> > > Signed-off-by: Peter Xu <peterx@redhat.com>
> > > ---
> > > 
> > > NOTE: I targeted this for 12.0 because the bug was not introduced in 11.2,
> > > however this seems to be a real bug fix to coroutine in general, I'll leave
> > > that to maintainers to decide if to pick it for 11.2.
> > > ---
> > >  util/qemu-coroutine-io.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
> > > index 364f4d5abf..3c0a7feafa 100644
> > > --- a/util/qemu-coroutine-io.c
> > > +++ b/util/qemu-coroutine-io.c
> > > @@ -74,7 +74,6 @@ typedef struct {
> > >  static void fd_coroutine_enter(void *opaque)
> > >  {
> > >      FDYieldUntilData *data = opaque;
> > > -    aio_set_fd_handler(data->ctx, data->fd, NULL, NULL, NULL, NULL, NULL);
> > >      qemu_coroutine_enter(data->co);
> > >  }
> > >  
> > > @@ -89,4 +88,9 @@ void coroutine_fn yield_until_fd_readable(int fd)
> > >      aio_set_fd_handler(data.ctx, fd, fd_coroutine_enter, NULL, NULL, NULL,
> > >                         &data);
> > >      qemu_coroutine_yield();
> > > +    /*
> > > +     * Always remove the fd handler, no matter the re-entering of this
> > > +     * coroutine was caused by fd_coroutine_enter() or something else.
> > > +     */
> > > +    aio_set_fd_handler(data.ctx, fd, NULL, NULL, NULL, NULL, NULL);
> > >  }
> > 
> > Why would the coroutine be entered?
> 
> In case of RDMA, rdma_cm_poll_handler() could receive a disconnect event on
> another management fd, then it knows the link is down, hence it needs to
> kickoff this coroutine to quit.  See 923709896b1.

Commit 923709896b1 is not safe in general. It would be necessary to
audit all yield points and see how they react to an unexpected coroutine
re-entry. There could be more bugs related to this.

> > Should there be a loop around
> > qemu_coroutine_yield() - otherwise we fix the invalid stack memory
> > access but return to the caller without fulfilling the purpose of the
> > function (waiting for the fd to become readable), which could cause
> > further bugs?
> 
> I feel like these are two separate things.
> 
> IMO fixing reset of aio handler should be a pure positive fix, because not
> fixing it doesn't stop user from re-entering of the coroutine and bypass
> fd_coroutine_enter().
> 
> My understanding is the caller should have full control of this: when the
> caller requires "fd must be readable", it should always wait until
> fd_coroutine_enter() returns.  This patch should have no functional
> difference.

I don't understand this paragraph because the caller has no way of
knowing whether fd_coroutine_enter() ran when yield_until_fd_readable()
returns with this patch applied. How can the caller wait until
fd_coroutine_enter() returns?

> But it seems still legal if the caller is benign and can properly handle
> the case even if fd is still not readable.  In this case, this patch fixes
> a real issue.
> 
> In case of RDMA migration, only the quit path can cause it to re-enter, so
> either there is IO or we need to quit.  RDMA code works well with either
> event, it can even loop back and wait on the fd again, but since quit is
> the only path kicking this off, it's also not possible even if the caller
> handles this.

The caller of yield_until_fd_readable() expects the function return to
mean the fd is now readable, not that the fd is readable or something
else happened. At minimum this patch would need to add a comment to
clarify this and then audit all callers to be sure they can handle those
semantics correctly.

It would be better to also add a return value differentiating between
success and failure (due to interruption) so that callers can propagate
the interruption (a caller may be several frames into a call stack where
a parent function will loop on early return, defeating the purpose of
reentering the coroutine to notify it that the connection on a separate
fd was dropped, so it must be possible to propagate the interruption up
the call stack).

Any part of QEMU could use util/qemu-coroutine-io.c, so even if this
patch happens to work for RDMA migration, the yield_until_fd_readable()
API needs a more disciplined approach so that it can be used correctly
by anyone.

Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
  2026-11-19 14:53 [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always Peter Xu
  2026-11-19 22:29 ` Stefan Hajnoczi
@ 2026-11-20 17:03 ` Kevin Wolf
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2026-11-20 17:03 UTC (permalink / raw)
  To: Peter Xu
  Cc: qemu-devel, Hongyan Xu, Stefan Hajnoczi, Fabiano Rosas,
	Zhijian Li (Fujitsu)

Am 19.11.2026 um 15:53 hat Peter Xu geschrieben:
> Hongyan reported a possible use-after-free of RDMA migration code:
> 
> https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn
> 
> The issue seems real, while this patch is a proposal to fix it in a simpler
> way, meanwhile it should be a problem to the yield_until_fd_readable()
> helper in general, so it should make more sense to be fixed there too.
> 
> The problem is about the use of the stack allocated FDYieldUntilData where
> we must make sure after yield_until_fd_readable() returns it's not used
> anywhere.  If the coroutine yielded can be entered from outside of this
> helper (fd_coroutine_enter()), then the aio handler might be installed even
> after yield_until_fd_readable() returns, and that makes the stack variable
> accessible by aio codd, even if stack gone.
> 
> Fix it by moving the aio handler removal outside the handler.
> 
> Reported-by: Hongyan Xu <getshell@seu.edu.cn>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Fabiano Rosas <farosas@suse.de>
> Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
> Cc: Hongyan Xu <getshell@seu.edu.cn>
> Signed-off-by: Peter Xu <peterx@redhat.com>

The fix looks right to me, however now FDYieldUntilData has two unused
fields. I suppose you could get rid of it entirely now and pass the
coroutine pointer as opaque.

Kevin



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always
  2026-11-19 22:29 ` Stefan Hajnoczi
  2026-11-19 23:05   ` Peter Xu
@ 2026-11-20 17:11   ` Kevin Wolf
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2026-11-20 17:11 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Peter Xu, qemu-devel, Hongyan Xu, Fabiano Rosas,
	Zhijian Li (Fujitsu)

Am 19.11.2026 um 23:29 hat Stefan Hajnoczi geschrieben:
> On Thu, Nov 19, 2026 at 09:53:11AM -0500, Peter Xu wrote:
> > Hongyan reported a possible use-after-free of RDMA migration code:
> > 
> > https://lore.kernel.org/all/20260904033130.276-1-getshell@seu.edu.cn
> > 
> > The issue seems real, while this patch is a proposal to fix it in a simpler
> > way, meanwhile it should be a problem to the yield_until_fd_readable()
> > helper in general, so it should make more sense to be fixed there too.
> > 
> > The problem is about the use of the stack allocated FDYieldUntilData where
> > we must make sure after yield_until_fd_readable() returns it's not used
> > anywhere.  If the coroutine yielded can be entered from outside of this
> > helper (fd_coroutine_enter()), then the aio handler might be installed even
> > after yield_until_fd_readable() returns, and that makes the stack variable
> > accessible by aio codd, even if stack gone.
> > 
> > Fix it by moving the aio handler removal outside the handler.
> > 
> > Reported-by: Hongyan Xu <getshell@seu.edu.cn>
> > Cc: Stefan Hajnoczi <stefanha@redhat.com>
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Cc: Fabiano Rosas <farosas@suse.de>
> > Cc: Zhijian Li (Fujitsu) <lizhijian@fujitsu.com>
> > Cc: Hongyan Xu <getshell@seu.edu.cn>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > 
> > NOTE: I targeted this for 12.0 because the bug was not introduced in 11.2,
> > however this seems to be a real bug fix to coroutine in general, I'll leave
> > that to maintainers to decide if to pick it for 11.2.
> > ---
> >  util/qemu-coroutine-io.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/util/qemu-coroutine-io.c b/util/qemu-coroutine-io.c
> > index 364f4d5abf..3c0a7feafa 100644
> > --- a/util/qemu-coroutine-io.c
> > +++ b/util/qemu-coroutine-io.c
> > @@ -74,7 +74,6 @@ typedef struct {
> >  static void fd_coroutine_enter(void *opaque)
> >  {
> >      FDYieldUntilData *data = opaque;
> > -    aio_set_fd_handler(data->ctx, data->fd, NULL, NULL, NULL, NULL, NULL);
> >      qemu_coroutine_enter(data->co);
> >  }
> >  
> > @@ -89,4 +88,9 @@ void coroutine_fn yield_until_fd_readable(int fd)
> >      aio_set_fd_handler(data.ctx, fd, fd_coroutine_enter, NULL, NULL, NULL,
> >                         &data);
> >      qemu_coroutine_yield();
> > +    /*
> > +     * Always remove the fd handler, no matter the re-entering of this
> > +     * coroutine was caused by fd_coroutine_enter() or something else.
> > +     */
> > +    aio_set_fd_handler(data.ctx, fd, NULL, NULL, NULL, NULL, NULL);
> >  }
> 
> Why would the coroutine be entered? Should there be a loop around
> qemu_coroutine_yield() - otherwise we fix the invalid stack memory
> access but return to the caller without fulfilling the purpose of the
> function (waiting for the fd to become readable), which could cause
> further bugs?

A loop around qemu_coroutine_yield() is almost never what you want. It
may happen in cases where you spawn multiple operations and wait for all
of them to complete, but if you're just waiting for a condition to
become true, then entering the coroutine before the condition is true
means that the caller is doing something wrong.

In this case, I think the additional caller intentionally wants to
cancel the waiting.

Having multiple places that can reenter a coroutine tends to be tricky
because aio_co_wake() introduces a window where both places could
trigger, which leads to an abort(). But here, qemu_coroutine_enter() is
directly used (which also implies that the coroutine and all the places
that reenter it are in the same thread), so it should be okay.

Kevin



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-20 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 14:53 [PATCH for-12.0] coroutine: Make yield_until_fd_readable() detach fd handler always Peter Xu
2026-11-19 22:29 ` Stefan Hajnoczi
2026-11-19 23:05   ` Peter Xu
2026-11-20 17:01     ` Stefan Hajnoczi
2026-11-20 17:11   ` Kevin Wolf
2026-11-20 17:03 ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.