mbox series

[v2,0/1] RDMA/srpt: Do not register event handler until srpt device is fully setup

Message ID 20240202091549.991784-1-william.kucharski@oracle.com (mailing list archive)
Headers show
Series RDMA/srpt: Do not register event handler until srpt device is fully setup | expand

Message

William Kucharski Feb. 2, 2024, 9:15 a.m. UTC
Upon occasion, KASAN testing would report a use-after-free Write in
srpt_refresh_port().

In the course of trying to diagnose this, I noticed that the code in
srpt_add_one() registers an event handler for the srpt device and then
initializes the ports on the device. If any portion of the
device port initialization fails, it removes the registration for the
event handler in the error leg.

This felt like a race condition, where an event handler was registered
before the device ports were fully initialized.

While I can't definitively say this was the issue - this change may just
modify timing to mask the real issue - when modified to not register
the event handler until all of the device ports are intialized,
the issue no longer reproduces in KASAN.

Changelog:
v2:
  * Added Fixes tag

William Kucharski (1):
  RDMA/srpt: Do not register event handler until srpt device is fully setup

 drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Leon Romanovsky Feb. 4, 2024, 9:46 a.m. UTC | #1
On Fri, 02 Feb 2024 02:15:48 -0700, William Kucharski wrote:
> Upon occasion, KASAN testing would report a use-after-free Write in
> srpt_refresh_port().
> 
> In the course of trying to diagnose this, I noticed that the code in
> srpt_add_one() registers an event handler for the srpt device and then
> initializes the ports on the device. If any portion of the
> device port initialization fails, it removes the registration for the
> event handler in the error leg.
> 
> [...]

Applied, thanks!

[1/1] RDMA/srpt: Do not register event handler until srpt device is fully setup
      https://git.kernel.org/rdma/rdma/c/c21a8870c98611

Best regards,