qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [PATCH] migration/rdma: Fix cm event use after free
Date: Wed, 2 Jun 2021 16:52:09 +0100	[thread overview]
Message-ID: <YLepKZ1X2wr7PwPC@work-vm> (raw)
In-Reply-To: <20210602023506.3821293-1-lizhijian@cn.fujitsu.com>

* Li Zhijian (lizhijian@cn.fujitsu.com) wrote:
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

Thanks! I don't think I understood that 'ack' actually meant 'free'!



Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/rdma.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/migration/rdma.c b/migration/rdma.c
> index 1cdb4561f32..d90b29a4b51 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -1539,16 +1539,20 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma)
>  
>                  if (pfds[1].revents) {
>                      ret = rdma_get_cm_event(rdma->channel, &cm_event);
> -                    if (!ret) {
> -                        rdma_ack_cm_event(cm_event);
> +                    if (ret) {
> +                        error_report("failed to get cm event while wait "
> +                                     "completion channel");
> +                        return -EPIPE;
>                      }
>  
>                      error_report("receive cm event while wait comp channel,"
>                                   "cm event is %d", cm_event->event);
>                      if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED ||
>                          cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
> +                        rdma_ack_cm_event(cm_event);
>                          return -EPIPE;
>                      }
> +                    rdma_ack_cm_event(cm_event);
>                  }
>                  break;
>  
> @@ -3285,7 +3289,6 @@ static void rdma_cm_poll_handler(void *opaque)
>          error_report("get_cm_event failed %d", errno);
>          return;
>      }
> -    rdma_ack_cm_event(cm_event);
>  
>      if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED ||
>          cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
> @@ -3298,12 +3301,14 @@ static void rdma_cm_poll_handler(void *opaque)
>                  rdma->return_path->error_state = -EPIPE;
>              }
>          }
> +        rdma_ack_cm_event(cm_event);
>  
>          if (mis->migration_incoming_co) {
>              qemu_coroutine_enter(mis->migration_incoming_co);
>          }
>          return;
>      }
> +    rdma_ack_cm_event(cm_event);
>  }
>  
>  static int qemu_rdma_accept(RDMAContext *rdma)
> -- 
> 2.30.2
> 
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2021-06-02 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  2:35 [PATCH] migration/rdma: Fix cm event use after free Li Zhijian
2021-06-02 15:52 ` Dr. David Alan Gilbert [this message]
2021-06-08 17:55   ` Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YLepKZ1X2wr7PwPC@work-vm \
    --to=dgilbert@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).