* [PATCH] scsi: Fix a use after free in st_open
@ 2021-03-11 6:46 Lv Yunlong
2021-03-11 18:10 ` "Kai Mäkisara (Kolumbus)"
2021-03-16 3:13 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Lv Yunlong @ 2021-03-11 6:46 UTC (permalink / raw)
To: Kai.Makisara, jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, Lv Yunlong
In st_open, if STp->in_use is true, STp will be freed by
scsi_tape_put(). However, STp is still used by DEBC_printk()
after. It is better to DEBC_printk() before scsi_tape_put().
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
drivers/scsi/st.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 841ad2fc369a..9ca536aae784 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1269,8 +1269,8 @@ static int st_open(struct inode *inode, struct file *filp)
spin_lock(&st_use_lock);
if (STp->in_use) {
spin_unlock(&st_use_lock);
- scsi_tape_put(STp);
DEBC_printk(STp, "Device already in use.\n");
+ scsi_tape_put(STp);
return (-EBUSY);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: Fix a use after free in st_open
2021-03-11 6:46 [PATCH] scsi: Fix a use after free in st_open Lv Yunlong
@ 2021-03-11 18:10 ` "Kai Mäkisara (Kolumbus)"
2021-03-16 3:13 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: "Kai Mäkisara (Kolumbus)" @ 2021-03-11 18:10 UTC (permalink / raw)
To: Lv Yunlong
Cc: James E . J . Bottomley, Martin K . Petersen, linux-scsi, linux-kernel
> On 11. Mar 2021, at 8.46, Lv Yunlong <lyl2019@mail.ustc.edu.cn> wrote:
>
> In st_open, if STp->in_use is true, STp will be freed by
> scsi_tape_put(). However, STp is still used by DEBC_printk()
> after. It is better to DEBC_printk() before scsi_tape_put().
>
> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
> ---
> drivers/scsi/st.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 841ad2fc369a..9ca536aae784 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -1269,8 +1269,8 @@ static int st_open(struct inode *inode, struct file *filp)
> spin_lock(&st_use_lock);
> if (STp->in_use) {
> spin_unlock(&st_use_lock);
> - scsi_tape_put(STp);
> DEBC_printk(STp, "Device already in use.\n");
> + scsi_tape_put(STp);
> return (-EBUSY);
> }
Potential problem only when debugging enabled, but should be fixed.
Thanks,
Kai
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: Fix a use after free in st_open
2021-03-11 6:46 [PATCH] scsi: Fix a use after free in st_open Lv Yunlong
2021-03-11 18:10 ` "Kai Mäkisara (Kolumbus)"
@ 2021-03-16 3:13 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2021-03-16 3:13 UTC (permalink / raw)
To: Lv Yunlong, jejb, Kai.Makisara
Cc: Martin K . Petersen, linux-kernel, linux-scsi
On Wed, 10 Mar 2021 22:46:36 -0800, Lv Yunlong wrote:
> In st_open, if STp->in_use is true, STp will be freed by
> scsi_tape_put(). However, STp is still used by DEBC_printk()
> after. It is better to DEBC_printk() before scsi_tape_put().
Applied to 5.12/scsi-fixes, thanks!
[1/1] scsi: Fix a use after free in st_open
https://git.kernel.org/mkp/scsi/c/c8c165dea4c8
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-16 3:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 6:46 [PATCH] scsi: Fix a use after free in st_open Lv Yunlong
2021-03-11 18:10 ` "Kai Mäkisara (Kolumbus)"
2021-03-16 3:13 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).