From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: nirbhayykumarr@proton.me
Cc: "alexander.usyskin@intel.com" <alexander.usyskin@intel.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"w@1wt.eu" <w@1wt.eu>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] misc: mei: fix race condition between client teardown and read completion
Date: Sun, 23 Aug 2026 19:09:34 +0200 [thread overview]
Message-ID: <2026082330-saint-relearn-1244@gregkh> (raw)
In-Reply-To: <mFnbLgz6MmxRv7Vo5F8dRB1xDjHWEORPoX9BEIpeevk-ptyMfVaw-WDBSZq-4i4g8eR2HpVF9QNvtbxRcAxJE621Ji2caOLa-9xmEMmpIiw=@proton.me>
On Sun, Aug 23, 2026 at 01:26:09PM +0000, nirbhayykumarr@proton.me wrote:
> In mei_release(), a host client is torn down upon close(). During this
> teardown sequence, mei_cl_disconnect() is invoked, which releases
> dev->device_lock while waiting for the firmware response.
>
> If an in-flight read request was previously submitted, an incoming
> completion interrupt processed concurrently by the MEI interrupt
> handler can add a completed callback into cl->rd_completed via
> mei_cl_add_rd_completed().
>
> Because mei_cl_flush_queues(cl, NULL) was invoked before mei_cl_unlink(cl),
> an incoming completion callback can slip into cl->rd_completed after the
> flush has completed but before the client is unlinked from dev->file_list.
> When mei_cl_unlink() is subsequently called, the invariant check at
> drivers/misc/mei/client.c:698 triggers:
>
> WARN_ON(!list_empty(&cl->rd_completed) ||
> !list_empty(&cl->rd_pending) ||
> !list_empty(&cl->link));
>
> Call trace:
> WARNING: CPU: 2 PID: 5056 at drivers/misc/mei/client.c:698 mei_cl_unlink+0xaa/0x140 [mei]
> RIP: 0010:mei_cl_unlink+0xaa/0x140 [mei]
> Call Trace:
> <TASK>
> mei_release+0x202/0x270 [mei]
> __fput+0x105/0x2e0
> __x64_sys_close+0x90/0x140
> do_syscall_64+0xaa/0x660
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> </TASK>
>
> Immediately following mei_cl_unlink(), mei_release() calls kfree(cl).
> If any remaining or deferred callback references the freed client, a
> use-after-free occurs.
>
> Fix this by flushing queues after unlinking the client from dev->file_list
> inside mei_cl_unlink(), preventing concurrent IRQ completions from
> populating the client's completed queue during teardown.
>
> Reported-by: Nirbhay Kumar <nirbhayykumarr@proton.me>
> Signed-off-by: Nirbhay Kumar <nirbhayykumarr@proton.me>
No need for Reported-by as you authored and signed off on this.
And did you forget an Assisted-by: tag?
and what commit id does this fix?
Also, no need to attach this at all, just send it using git send-email
as-is.
thanks,
greg k-h
prev parent reply other threads:[~2026-08-23 17:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 13:26 nirbhayykumarr
2026-08-23 17:09 ` gregkh [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=2026082330-saint-relearn-1244@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=alexander.usyskin@intel.com \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nirbhayykumarr@proton.me \
--cc=stable@vger.kernel.org \
--cc=w@1wt.eu \
/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
all inboxes | Powered by JetHome®