* [PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store
@ 2020-11-20 7:48 Qinglang Miao
2020-11-25 17:04 ` Benjamin Block
0 siblings, 1 reply; 2+ messages in thread
From: Qinglang Miao @ 2020-11-20 7:48 UTC (permalink / raw)
To: Steffen Maier, Benjamin Block, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger
Cc: linux-s390, linux-kernel, Qinglang Miao
kfree(port) is called in put_device(&port->dev) so that following
use would cause use-after-free bug.
the former put_device is redundant for device_unregister contains
put_device already. So just remove it to fix this.
Fixes: 83d4e1c33d93 ("[SCSI] zfcp: cleanup port sysfs attribute usage")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
drivers/s390/scsi/zfcp_sysfs.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 8d9662e8b..06285e452 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -327,8 +327,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
list_del(&port->list);
write_unlock_irq(&adapter->port_list_lock);
- put_device(&port->dev);
-
zfcp_erp_port_shutdown(port, 0, "syprs_1");
device_unregister(&port->dev);
out:
--
2.23.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store
2020-11-20 7:48 [PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store Qinglang Miao
@ 2020-11-25 17:04 ` Benjamin Block
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Block @ 2020-11-25 17:04 UTC (permalink / raw)
To: Qinglang Miao
Cc: Steffen Maier, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, linux-s390, linux-kernel, linux-scsi
On Fri, Nov 20, 2020 at 03:48:53PM +0800, Qinglang Miao wrote:
> kfree(port) is called in put_device(&port->dev) so that following
> use would cause use-after-free bug.
>
> the former put_device is redundant for device_unregister contains
> put_device already. So just remove it to fix this.
>
> Fixes: 83d4e1c33d93 ("[SCSI] zfcp: cleanup port sysfs attribute usage")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
> drivers/s390/scsi/zfcp_sysfs.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
> index 8d9662e8b..06285e452 100644
> --- a/drivers/s390/scsi/zfcp_sysfs.c
> +++ b/drivers/s390/scsi/zfcp_sysfs.c
> @@ -327,8 +327,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
> list_del(&port->list);
> write_unlock_irq(&adapter->port_list_lock);
>
> - put_device(&port->dev);
> -
> zfcp_erp_port_shutdown(port, 0, "syprs_1");
> device_unregister(&port->dev);
> out:
Hmm, the placement of the put_device() is indeed strange, now that I
think about it. But just removing it and then having a dangling
reference also seems wrong - we do get one explicitly in
`zfcp_get_port_by_wwpn()`.
My first thought would be to move it after the `device_unregister()`
call, and before the `out:` label.
--
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen / Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-25 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 7:48 [PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store Qinglang Miao
2020-11-25 17:04 ` Benjamin Block
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).