Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Ryan Stone <rysto32@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: Possible bug in ipoib_reap_dead_ahs in datagram mode
Date: Tue, 24 May 2022 10:07:42 +0300	[thread overview]
Message-ID: <YoyEPnFpd7/mI1Mm@unreal> (raw)
In-Reply-To: <CAFMmRNyHUSg6_+af9W39e36aCx2a=_9WC8MB08W9XfnMKoYXAQ@mail.gmail.com>

On Wed, May 04, 2022 at 03:15:13PM -0400, Ryan Stone wrote:
> I was reading through the IPoIB code and I think that I see a bug that
> affects ipoib_reap_dead_ahs() when using datagram mode.
> 
> When sending a packet, if we aren't using the CM (which I assume means
> that we are using datagram mode), we fall into the following case:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_main.c#n1163
> 
> The AH for our neighbour has its last_send field set to the return
> value from the RDMA driver's send function
> 
> If I look at how this is used in ipoib_reap_dead_ahs(), it compares
> last_send to the current tail of the completion(?) queue.  I believe
> that this is intended to check that the last outstanding WQ entry that
> references the AH has completed.
> 
> However, if I look at the actual implementation in mlx5, the send
> function always returns NETDEV_TX_OK:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c#n635
> 
> If my understanding of all of this is correct, this could lead to a
> premature freeing of an AH and a use-after-free bug

IPoIB in mlx5 is HW offloaded version of ulp/ipoib one. AFAIK, it doesn't
change "tx_tail" and we won't enter into this if (...).

Thanks

  reply	other threads:[~2022-05-24  7:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 19:15 Possible bug in ipoib_reap_dead_ahs in datagram mode Ryan Stone
2022-05-24  7:07 ` Leon Romanovsky [this message]
2022-05-24 13:33   ` Ryan Stone
2022-05-24 19:08     ` Leon Romanovsky
2022-05-24 19:18       ` Ryan Stone
2022-05-25  6:10         ` Leon Romanovsky

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=YoyEPnFpd7/mI1Mm@unreal \
    --to=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rysto32@gmail.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