Skip to contentSkip to conversation

scsi: ufs: bsg: Set bsg_queue to NULL after removal

PATCH In review Xiangyu Chen 2 participants 2 messages Apr 16, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs: bsg: Set bsg_queue to NULL after removal

From: Guixin Liu <[email protected]>

[ Upstream commit 1e95c798d8a7f70965f0f88d4657b682ff0ec75f ]

Currently, this does not cause any issues, but I believe it is necessary to set bsg_queue to NULL after removing it to prevent potential use-after-free (UAF) access.

---
Verified the build test.

---
 drivers/scsi/ufs/ufs_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufs_bsg.c +1 -0
index 16e8ddcf22fe..b8bbfd81b8ae 100644
@@ -175,6 +175,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)
 		return;
 
 	bsg_remove_queue(hba->bsg_queue);
+	hba->bsg_queue = NULL;
 
 	device_del(bsg_dev);
 	put_device(bsg_dev);
Signature · 1 line
2.34.1
maintainer Reviewed-by Avri Altman on v1 1/1
#1 lore raw

[ Sasha's backport helper bot ]

Hi,

✅ All tests passed successfully. No issues detected. No action required from the submitter.

The upstream commit SHA1 provided is correct: 1e95c798d8a7f70965f0f88d4657b682ff0ec75f

WARNING: Author mismatch between patch and upstream commit:
Backport author: Xiangyu Chen<[email protected]> Commit author: Guixin Liu<[email protected]>

Status in newer kernel trees:

6.14.y | Present (exact SHA1)
6.13.y | Present (different SHA1: 9193bdc170cc)
6.12.y | Present (different SHA1: 88a01e9c9ad4)

6.6.y | Present (different SHA1: 5f782d4741bf)
6.1.y | Present (different SHA1: 5e7b6e44468c)
5.15.y | Not found

Note: The patch differs from the upstream commit:
---
1: 1e95c798d8a7f ! 1: be0ecc3eb507b scsi: ufs: bsg: Set bsg_queue to NULL after removal
@@ Metadata
## Commit message ##
scsi: ufs: bsg: Set bsg_queue to NULL after removal

+ [ Upstream commit 1e95c798d8a7f70965f0f88d4657b682ff0ec75f ]
+
Currently, this does not cause any issues, but I believe it is necessary to set bsg_queue to NULL after removing it to prevent potential use-after-free (UAF) access.
@@ Commit message

+ Signed-off-by: Xiangyu Chen <[email protected]>
+ Signed-off-by: He Zhe <[email protected]>

- ## drivers/ufs/core/ufs_bsg.c ##
-@@ drivers/ufs/core/ufs_bsg.c: void ufs_bsg_remove(struct ufs_hba *hba)
+ ## drivers/scsi/ufs/ufs_bsg.c ##
+@@ drivers/scsi/ufs/ufs_bsg.c: void ufs_bsg_remove(struct ufs_hba *hba)
return;

bsg_remove_queue(hba->bsg_queue);
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-5.10.y       |  Success    |  Success   |
| stable/linux-5.15.y       |  Success    |  Success   |