]> git.baikalelectronics.ru Git - kernel.git/commit
bus: fsl-mc-bus: fix KASAN use-after-free in fsl_mc_bus_remove()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 1 Jun 2022 10:51:59 +0000 (19:51 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2022 13:53:12 +0000 (15:53 +0200)
commit42f86981b8fc361b8181a6e5fe2b9a9952112810
tree513a875e29ee2d55fd0a96954b3137d9f7247aec
parentc25886e9781f1857d8dcd741867cb60a6ffd4c51
bus: fsl-mc-bus: fix KASAN use-after-free in fsl_mc_bus_remove()

In fsl_mc_bus_remove(), mc->root_mc_bus_dev->mc_io is passed to
fsl_destroy_mc_io(). However, mc->root_mc_bus_dev is already freed in
fsl_mc_device_remove(). Then reference to mc->root_mc_bus_dev->mc_io
triggers KASAN use-after-free. To avoid the use-after-free, keep the
reference to mc->root_mc_bus_dev->mc_io in a local variable and pass to
fsl_destroy_mc_io().

This patch needs rework to apply to kernels older than v5.15.

Fixes: df0bd080519b ("staging: fsl-mc: fix asymmetry in destroy of mc_io")
Cc: stable@vger.kernel.org # v5.15+
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20220601105159.87752-1-shinichiro.kawasaki@wdc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bus/fsl-mc/fsl-mc-bus.c