]> git.itanic.dy.fi Git - linux-stable/commit
scsi: sg: Avoid sg device teardown race
authorAlexander Wetzel <Alexander@wetzel-home.de>
Wed, 20 Mar 2024 21:30:32 +0000 (22:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Apr 2024 09:23:36 +0000 (11:23 +0200)
commitb0d1ebcc1a9560e494ea9b3ee808540db26c5086
tree0e1ca10a87a13e2335b2bdab58b9143d3014bda8
parent786afd51e21481ee4430fe35f61c6b49bfb2cd50
scsi: sg: Avoid sg device teardown race

commit 27f58c04a8f438078583041468ec60597841284d upstream.

sg_remove_sfp_usercontext() must not use sg_device_destroy() after calling
scsi_device_put().

sg_device_destroy() is accessing the parent scsi_device request_queue which
will already be set to NULL when the preceding call to scsi_device_put()
removed the last reference to the parent scsi_device.

The resulting NULL pointer exception will then crash the kernel.

Link: https://lore.kernel.org/r/20240305150509.23896-1-Alexander@wetzel-home.de
Fixes: db59133e9279 ("scsi: sg: fix blktrace debugfs entries leakage")
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Wetzel <Alexander@wetzel-home.de>
Link: https://lore.kernel.org/r/20240320213032.18221-1-Alexander@wetzel-home.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/sg.c