android_kernel_motorola_sm6225/net/9p
Zheng Wang c078fcd3f0 9p/xen : Fix use after free bug in xen_9pfs_front_remove due to race condition
[ Upstream commit ea4f1009408efb4989a0f139b70fb338e7f687d0 ]

In xen_9pfs_front_probe, it calls xen_9pfs_front_alloc_dataring
to init priv->rings and bound &ring->work with p9_xen_response.

When it calls xen_9pfs_front_event_handler to handle IRQ requests,
it will finally call schedule_work to start the work.

When we call xen_9pfs_front_remove to remove the driver, there
may be a sequence as follows:

Fix it by finishing the work before cleanup in xen_9pfs_front_free.

Note that, this bug is found by static analysis, which might be
false positive.

CPU0                  CPU1

                     |p9_xen_response
xen_9pfs_front_remove|
  xen_9pfs_front_free|
kfree(priv)          |
//free priv          |
                     |p9_tag_lookup
                     |//use priv->client

Fixes: 71ebd71921 ("xen/9pfs: connect to the backend")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-20 12:04:40 +02:00
..
client.c net/9p: Initialize the iounit field during fid creation 2022-08-25 11:15:32 +02:00
error.c
Kconfig IB: Revert "remove redundant INFINIBAND kconfig dependencies" 2018-05-28 10:40:16 -06:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mod.c 9p: Use a slab for allocating requests 2019-07-03 13:14:41 +02:00
protocol.c 9p: p9dirent_read: check network-provided name length 2019-07-03 13:14:42 +02:00
protocol.h
trans_common.c net/9p: include trans_common.h to fix missing prototype warning. 2019-07-03 13:14:43 +02:00
trans_common.h
trans_fd.c 9p/fd: Use P9_HDRSZ for header size 2022-12-14 11:28:25 +01:00
trans_rdma.c 9p/rdma: unmap receive dma buffer in rdma_request()/post_recv() 2023-03-11 16:31:59 +01:00
trans_virtio.c 9p/trans_virtio: Remove sysfs file on probe failure 2021-09-26 13:39:47 +02:00
trans_xen.c 9p/xen : Fix use after free bug in xen_9pfs_front_remove due to race condition 2023-04-20 12:04:40 +02:00
util.c 9p: fix whitespace issues 2018-08-13 09:34:58 +09:00