Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
	andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com,
	kalesh-anakkur.purayil@broadcom.com
Subject: Re: [PATCH rdma-next v6 7/9] RDMA/bnxt_re: Enhance dpi lifecycle logic in doorbell uapis
Date: Tue, 19 May 2026 10:27:30 -0300	[thread overview]
Message-ID: <20260519132730.GZ7702@ziepe.ca> (raw)
In-Reply-To: <CAHHeUGWpp8n1dHAu=MfYiLhntzK=PtvNyRBHhD0W9KkthEgYUw@mail.gmail.com>

On Tue, May 19, 2026 at 06:50:38PM +0530, Sriharsha Basavapatna wrote:
> > > ufile_destroy_ucontext(reason == RDMA_REMOVE_DRIVER_REMOVE) -->
> > > uverbs_user_mmap_disassociate() --> rdma_user_mmap_entry_put() -->
> > > rdma_user_mmap_entry_free() --> ucontext->device->ops.mmap_free()
> >
> > Yes, that's right. The disassociate removes the references from all
> > the VMAs so it should always eventually call free.
> Ok, so disassociate() triggers mmap free in the driver while
> ib_ucontext is still valid, right?  The use-after-free concern raised
> above, where uctx has been freed, shouldn't occur?

As far as I can see. At least you would be in good company making this
assumption...

> > However, it would be best if we didn't have this code in the free
> > callback at all, ideally the destruction of the object will happen in
> > the uobject destructor not the mmap free. However, I think we lack the
> > ability to do that right now.
> >
> I had to move it into mmap_free() because a prior concern pointed out
> that the dpi could be reallocated to another process, while the
> original process's mmap is still active.  Although the bnxt_re library
> unmaps first and then destroys the dbr object (i.e in the right
> sequence), I still tried to address that concern by moving it into
> mmap free context.

Yes, we lack the ability to shoot down a single mmap_entry during the
uboject destruction so it has to work like this :(

Jason

  reply	other threads:[~2026-05-19 13:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 15:37 [PATCH rdma-next v6 0/9] RDMA/bnxt_re: Support QP uapi extensions Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 1/9] RDMA/bnxt_re: Refactor bnxt_re_init_user_qp() Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 2/9] RDMA/bnxt_re: Update rq depth for app allocated QPs Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 3/9] RDMA/bnxt_re: Update sq " Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 4/9] RDMA/bnxt_re: Update msn table size " Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 5/9] RDMA/bnxt_re: Update hwq depth " Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 6/9] RDMA/bnxt_re: Enhance dbr usecnt logic in doorbell uapis Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 7/9] RDMA/bnxt_re: Enhance dpi lifecycle " Sriharsha Basavapatna
2026-05-19  9:27   ` Sriharsha Basavapatna
2026-05-19 12:46     ` Jason Gunthorpe
2026-05-19 13:20       ` Sriharsha Basavapatna
2026-05-19 13:27         ` Jason Gunthorpe [this message]
2026-05-19 13:59           ` Sriharsha Basavapatna
2026-05-19 14:40             ` Jason Gunthorpe
2026-05-19 15:17               ` Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 8/9] RDMA/bnxt_re: Support doorbells for app allocated QPs Sriharsha Basavapatna
2026-05-18 15:37 ` [PATCH rdma-next v6 9/9] RDMA/bnxt_re: Enable " Sriharsha Basavapatna

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=20260519132730.GZ7702@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=selvin.xavier@broadcom.com \
    --cc=sriharsha.basavapatna@broadcom.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