From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Zheng Wang <zyytlz.wz@163.com>
Cc: jikos@kernel.org, benjamin.tissoires@redhat.com,
rafael@kernel.org, hdegoede@redhat.com,
gregkh@linuxfoundation.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, hackerzheng666@gmail.com,
1395428693sheep@gmail.com, alex000young@gmail.com
Subject: Re: [PATCH] HID: intel-ish-hid: pci-ish: Fix use after free bug in ish_remove due to race condition
Date: Tue, 25 Apr 2023 08:55:12 -0700 [thread overview]
Message-ID: <2bd0143cf0e638c88f57409f854c0529a1b12b6b.camel@linux.intel.com> (raw)
In-Reply-To: <20230412171441.18958-1-zyytlz.wz@163.com>
On Thu, 2023-04-13 at 01:14 +0800, Zheng Wang wrote:
> In ish_probe, it calls ish_dev_init to init the device. In this
> function,
> ishtp_device_init is called and &dev->bh_hbm_work is bound with
> bh_hbm_work_fn. recv_hbm may be called to start the timer work.
>
> If we remove the module which will call ish_remove to make cleanup,
> there may be an unfinished work. The possible sequence is as follows:
>
> Fix it by canceling the work before cleanup in
> ishtp_bus_remove_all_clients
>
> CPU0 CPUc1
>
> |bh_hbm_work_fn
> ish_remove |
> ishtp_bus_remove_all_clients |
> kfree(ishtp_dev->fw_clients); |
> |
> |&dev->fw_clients[...]
> | //use
>
> Fixes: 3703f53b99e4 ("HID: intel_ish-hid: ISH Transport layer")
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
It is a extremely rare case, so it is OK to not mark for stable.
> ---
> drivers/hid/intel-ish-hid/ishtp/bus.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c
> b/drivers/hid/intel-ish-hid/ishtp/bus.c
> index 81385ab37fa9..ada7cd08dbeb 100644
> --- a/drivers/hid/intel-ish-hid/ishtp/bus.c
> +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
> @@ -744,6 +744,7 @@ void ishtp_bus_remove_all_clients(struct
> ishtp_device *ishtp_dev,
> */
> }
> spin_unlock_irqrestore(&ishtp_dev->cl_list_lock, flags);
> + cancel_work_sync(&ishtp_dev->bh_hbm_work);
>
> /* Release DMA buffers for client messages */
> ishtp_cl_free_dma_buf(ishtp_dev);
next prev parent reply other threads:[~2023-04-25 15:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 17:14 [PATCH] HID: intel-ish-hid: pci-ish: Fix use after free bug in ish_remove due to race condition Zheng Wang
2023-04-12 17:18 ` Zheng Hacker
2023-04-25 15:55 ` srinivas pandruvada [this message]
2023-04-25 17:18 ` Zheng Hacker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bd0143cf0e638c88f57409f854c0529a1b12b6b.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=1395428693sheep@gmail.com \
--cc=alex000young@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hackerzheng666@gmail.com \
--cc=hdegoede@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=zyytlz.wz@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.