From: Yaohan Li <shunsheng1218@gmail.com>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] firewire: keep the request alive while the event is queued
Date: Mon, 23 Nov 2026 10:21:46 +0800 [thread overview]
Message-ID: <179540050657.417371.5230551399496711422@gmail.com> (raw)
In-Reply-To: <20261122123358.GA500423@sakamocchi.jp>
Hi Takashi,
Yes. Both scenarios you describe are what this RFC is intended to cover.
The queued event has the handle in v[0] and a pointer into the fw_request
payload in v[1]. dequeue_event() removes the event from the list under
client->mutex, then drops the mutex and copies these two parts separately.
FW_CDEV_IOC_SEND_RESPONSE can release the client resource once it is given a
valid handle, without waiting for that copy to finish.
In the first scenario, another thread could observe the handle in the read
buffer and issue the ioctl before the payload copy. In the second, if a
speculative ioctl happens to hit the correct live handle, the resource may be
released even while the event is still queued. Depending on the request
state, that can release the fw_request holding the payload. An application
that waits for read(2) to return before responding would not encounter this;
both scenarios also require a registered address handler and an inbound
request on the bus.
The event currently has no request reference of its own. The RFC gives it one
with fw_request_get(), then drops it through free_event() after the event is
consumed or discarded, independently of the client resource.
For testing I compiled core-cdev.c into a controlled KASAN test with a
modeled request lifetime. Releasing the resource before dequeue_event()
produced a use-after-free in _copy_to_user with the original code, but not
with the patch. This tests the lifetime problem, not the exact two-thread
read/ioctl interleaving on hardware. I do not have a FireWire controller to
verify that timing.
Thanks,
Yaohan
prev parent reply other threads:[~2026-11-23 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:32 Yaohan Li
2026-11-22 12:33 ` Takashi Sakamoto
2026-11-23 2:21 ` Yaohan Li [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=179540050657.417371.5230551399496711422@gmail.com \
--to=shunsheng1218@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=o-takashi@sakamocchi.jp \
/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®