linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zheng Hacker <hackerzheng666@gmail.com>
To: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Zheng Wang <zyytlz.wz@163.com>,
	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, 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: Wed, 26 Apr 2023 01:18:12 +0800	[thread overview]
Message-ID: <CAJedcCzptvdgk8vMO5F==NS79gTZdWaL1id8GcbUn2UsbQr8Xg@mail.gmail.com> (raw)
In-Reply-To: <2bd0143cf0e638c88f57409f854c0529a1b12b6b.camel@linux.intel.com>

srinivas pandruvada <srinivas.pandruvada@linux.intel.com> 于2023年4月25日周二 23:55写道:
>
> 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.

Got it, thanks!

Best regards,
Zheng

>
> > ---
> >  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);
>

      reply	other threads:[~2023-04-25 17:18 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
2023-04-25 17:18   ` Zheng Hacker [this message]

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='CAJedcCzptvdgk8vMO5F==NS79gTZdWaL1id8GcbUn2UsbQr8Xg@mail.gmail.com' \
    --to=hackerzheng666@gmail.com \
    --cc=1395428693sheep@gmail.com \
    --cc=alex000young@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --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=srinivas.pandruvada@linux.intel.com \
    --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 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).