]> git.baikalelectronics.ru Git - kernel.git/commit
libata: add refcounting to ata_host
authorTaras Kondratiuk <takondra@cisco.com>
Fri, 9 Mar 2018 08:34:41 +0000 (08:34 +0000)
committerTejun Heo <tj@kernel.org>
Tue, 13 Mar 2018 20:29:10 +0000 (13:29 -0700)
commite0b5b9dfb61c0feb7f9edefd8f8052ccbc96ff40
tree7ff753d1e024524a77fef933c149f1d96627ebff
parentecc4014d09b1a4d90f8cc8da8c32ba27457e6a8c
libata: add refcounting to ata_host

After commit 592c94567ae1 ("ata: make ata port as parent device of scsi
host") manual driver unbind/remove causes use-after-free.

Unbind unconditionally invokes devres_release_all() which calls
ata_host_release() and frees ata_host/ata_port memory while it is still
being referenced as a parent of SCSI host. When SCSI host is finally
released scsi_host_dev_release() calls put_device(parent) and accesses
freed ata_port memory.

Add reference counting to make sure that ata_host lives long enough.

Bug report: https://lkml.org/lkml/2017/11/1/945
Fixes: 592c94567ae1 ("ata: make ata port as parent device of scsi host")
Cc: Tejun Heo <tj@kernel.org>
Cc: Lin Ming <minggr@gmail.com>
Cc: linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Taras Kondratiuk <takondra@cisco.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/libata-core.c
drivers/ata/libata-transport.c
drivers/ata/libata.h
include/linux/libata.h