[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <00362659-A275-4415-B2B0-78E6183C8272@kolumbus.fi>
Date: Thu, 11 Mar 2021 20:10:18 +0200
From: "Kai Mäkisara (Kolumbus)"
<kai.makisara@...umbus.fi>
To: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Cc: "James E . J . Bottomley" <jejb@...ux.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi: Fix a use after free in st_open
> On 11. Mar 2021, at 8.46, Lv Yunlong <lyl2019@...l.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@...l.ustc.edu.cn>
Acked-by: Kai Mäkisara <kai.makisara@...umbus.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
Powered by blists - more mailing lists