lkml.org 
[lkml]   [2022]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] RDMA/srp: Fix use-after-free in srp_exit_cmd_priv
On Fri, Jun 24, 2022 at 04:26:06PM -0700, Bart Van Assche wrote:
> On 6/24/22 15:59, Jason Gunthorpe wrote:
> > I don't even understand how get_device() prevents this call chain??
> >
> > It looks to me like the problem is srp_remove_one() is not waiting for
> > or canceling some outstanding work.
>
> Hi Jason,
>
> My conclusions from the call traces in Li's email are as follows:
> * scsi_host_dev_release() can get called after srp_remove_one().
> * srp_exit_cmd_priv() uses the ib_device pointer. If srp_remove_one() is
> called before srp_exit_cmd_priv() then a use-after-free is triggered.

Shouldn't srp_remove_one() wait for the scsi_host_dev to complete
destruction? Clearly it cannot continue to exist once the IB device
has been removed

> Is calling get_device() and put_device() on the struct ib_device an
> acceptable way to fix this?

As I said, I don't understand at all how this works. get_device() does
not prevent srp_remove_one() from being called.

Jason

\
 
 \ /
  Last update: 2022-06-25 01:49    [W:0.060 / U:7.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site