]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: lpfc: Fix buffer free/clear order in deferred receive path
authorJohn Evans <evans1210144@gmail.com>
Thu, 28 Aug 2025 04:40:08 +0000 (12:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:58:18 +0000 (18:58 +0200)
commit367cb5ffd8a8a4c85dc89f55e7fa7cc191425b11
treec7d0ec31301318cd355a9c2779932eb605b59c39
parentcc5911dc2f989166860d513976cd1f821d5c0b7e
scsi: lpfc: Fix buffer free/clear order in deferred receive path

commit 9dba9a45c348e8460da97c450cddf70b2056deb3 upstream.

Fix a use-after-free window by correcting the buffer release sequence in
the deferred receive path. The code freed the RQ buffer first and only
then cleared the context pointer under the lock. Concurrent paths (e.g.,
ABTS and the repost path) also inspect and release the same pointer under
the lock, so the old order could lead to double-free/UAF.

Note that the repost path already uses the correct pattern: detach the
pointer under the lock, then free it after dropping the lock. The
deferred path should do the same.

Fixes: 472e146d1cf3 ("scsi: lpfc: Correct upcalling nvmet_fc transport during io done downcall")
Cc: stable@vger.kernel.org
Signed-off-by: John Evans <evans1210144@gmail.com>
Link: https://lore.kernel.org/r/20250828044008.743-1-evans1210144@gmail.com
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/lpfc/lpfc_nvmet.c