From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>, Dan Aloni <dan@kernelim.com>,
<linux-rdma@vger.kernel.org>
Subject: Re: [PATCH rdma-next] RDMA/addr: Fix race with netevent_callback()/rdma_addr_cancel()
Date: Wed, 30 Sep 2020 15:31:36 -0300 [thread overview]
Message-ID: <20200930183136.GA1031970@nvidia.com> (raw)
In-Reply-To: <20200930072007.1009692-1-leon@kernel.org>
On Wed, Sep 30, 2020 at 10:20:07AM +0300, Leon Romanovsky wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
>
> This three thread race can result in the work being run once the callback
> becomes NULL:
>
> CPU1 CPU2 CPU3
> netevent_callback()
> process_one_req() rdma_addr_cancel()
> [..]
> spin_lock_bh()
> set_timeout()
> spin_unlock_bh()
>
> spin_lock_bh()
> list_del_init(&req->list);
> spin_unlock_bh()
>
> req->callback = NULL
> spin_lock_bh()
> if (!list_empty(&req->list))
> // Skipped!
> // cancel_delayed_work(&req->work);
> spin_unlock_bh()
>
> process_one_req() // again
> req->callback() // BOOM
> cancel_delayed_work_sync()
>
> The solution is to always cancel the work once it is completed so any
> in between set_timeout() does not result in it running again.
>
> Fixes: 44e75052bc2a ("RDMA/rdma_cm: Make rdma_addr_cancel into a fence")
> Reported-by: Dan Aloni <dan@kernelim.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> drivers/infiniband/core/addr.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
Applied to for-next
Jason
prev parent reply other threads:[~2020-09-30 18:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 7:20 [PATCH rdma-next] RDMA/addr: Fix race with netevent_callback()/rdma_addr_cancel() Leon Romanovsky
2020-09-30 18:31 ` Jason Gunthorpe [this message]
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=20200930183136.GA1031970@nvidia.com \
--to=jgg@nvidia.com \
--cc=dan@kernelim.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
/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).