* [PATCH] firewire: core: fix race condition in split transaction handling
@ 2026-10-18 2:55 Takashi Sakamoto
2026-10-18 10:30 ` Takashi Sakamoto
0 siblings, 1 reply; 2+ messages in thread
From: Takashi Sakamoto @ 2026-10-18 2:55 UTC (permalink / raw)
To: linux1394-devel; +Cc: linux-kernel
For a split transaction, either fw_core_handle_response() or
split_transaction_timeout_callback() may manipulate the same transaction
entry in the pending transaction list. The return value of timer_delete()
is used to determine which function handles the entry. If the transaction
is a split transaction and timer_delete() returns zero, the timeout
callback may already be running. In this case, the response handler must
leave the entry in the list for the timeout callback to remove.
A previous code refactoring broke this behavior, introducing a race
condition in which both functions could process the same transaction.
This could lead to a use-after-free on the transaction initiator side.
Fix the regression by ensuring that the response handler does not process
the transaction when timer_delete() returns zero. The timeout callback is
responsible for removing the entry from the pending transaction list.
Fixes: fa2dc2710076 ("firewire: core: code refactoring to find and pop transaction entry")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
drivers/firewire/core-transaction.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 22ae387ae03c..016070560c74 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -89,8 +89,12 @@ void fw_cancel_pending_transactions(struct fw_card *card)
break; \
} \
} \
- if (t && try_cancel_split_timeout(t)) \
- remove_transaction_entry(card, t); \
+ if (t) { \
+ if (try_cancel_split_timeout(t)) \
+ remove_transaction_entry(card, t); \
+ else \
+ t = NULL; \
+ } \
t; \
})
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] firewire: core: fix race condition in split transaction handling
2026-10-18 2:55 [PATCH] firewire: core: fix race condition in split transaction handling Takashi Sakamoto
@ 2026-10-18 10:30 ` Takashi Sakamoto
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Sakamoto @ 2026-10-18 10:30 UTC (permalink / raw)
To: linux1394-devel; +Cc: linux-kernel
On Sun, Oct 18, 2026 at 11:55:04AM +0900, Takashi Sakamoto wrote:
> For a split transaction, either fw_core_handle_response() or
> split_transaction_timeout_callback() may manipulate the same transaction
> entry in the pending transaction list. The return value of timer_delete()
> is used to determine which function handles the entry. If the transaction
> is a split transaction and timer_delete() returns zero, the timeout
> callback may already be running. In this case, the response handler must
> leave the entry in the list for the timeout callback to remove.
>
> A previous code refactoring broke this behavior, introducing a race
> condition in which both functions could process the same transaction.
> This could lead to a use-after-free on the transaction initiator side.
>
> Fix the regression by ensuring that the response handler does not process
> the transaction when timer_delete() returns zero. The timeout callback is
> responsible for removing the entry from the pending transaction list.
>
> Fixes: fa2dc2710076 ("firewire: core: code refactoring to find and pop transaction entry")
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
> drivers/firewire/core-transaction.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Applied to for-linus branch.
Regards
Takashi Sakamoto
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-18 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 2:55 [PATCH] firewire: core: fix race condition in split transaction handling Takashi Sakamoto
2026-10-18 10:30 ` Takashi Sakamoto
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®