linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Hefty,
	Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] IB/ucma: Fix theoretical user triggered use-after-free
Date: Fri, 14 Aug 2015 21:22:25 -0400	[thread overview]
Message-ID: <55CE9451.3040803@redhat.com> (raw)
In-Reply-To: <1828884A29C6694DAF28B7E6B8A82373A9023323-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

On 08/06/2015 01:33 PM, Hefty, Sean wrote:
>> Something like this:
>>
>> CPU A                         CPU B
>> ========================      ================================
>> ucma_destroy_id()
>>  wait_for_completion()
>>                               .. anything
>>                                 ucma_put_ctx()
>>                                   complete()
>>  .. continues ...
>>                               ucma_leave_multicast()
>>                                mutex_lock(mut)
>>                                  atomic_inc(ctx->ref)
>>                                mutex_unlock(mut)
>>  ucma_free_ctx()
>>   ucma_cleanup_multicast()
>>    mutex_lock(mut)
>>      kfree(mc)
>>                                rdma_leave_multicast(mc->ctx->cm_id,..
>>
>> Fix it by latching the ref at 0. Once it goes to 0 mc and ctx cannot
>> leave the mutex(mut) protection.
>>
>> The other atomic_inc in ucma_get_ctx is OK because mutex(mut) protects
>> it from racing with ucma_destroy_id.
>>
>> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> 
> Acked-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

This has been picked up.  Thanks.


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

      parent reply	other threads:[~2015-08-15  1:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-04 23:13 [PATCH] IB/ucma: Fix theoretical user triggered use-after-free Jason Gunthorpe
     [not found] ` <20150804231332.GA22959-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-08-06 17:33   ` Hefty, Sean
     [not found]     ` <1828884A29C6694DAF28B7E6B8A82373A9023323-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-08-15  1:22       ` Doug Ledford [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=55CE9451.3040803@redhat.com \
    --to=dledford-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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).