Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] greybus: operation: fix request timeout race
@ 2026-11-29 14:11 linfordWu
  2026-11-29 15:45 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: linfordWu @ 2026-11-29 14:11 UTC (permalink / raw)
  To: Johan Hovold, Alex Elder, Greg Kroah-Hartman
  Cc: greybus-dev, linux-kernel, linfordWu, syzbot+61464b62b688791cc24c,
	syzbot+a2e50fb40695811c2dab, stable

A request can complete after gb_message_send() returns but before its
timeout timer is armed. The completion worker then finds no timer to
delete, and the request path can leave an active timer in an operation
that is about to be freed.

Check the result and arm the timer while holding gb_operations_lock,
which also protects result updates. If completion has already happened,
leave the timer unarmed. Otherwise the completion worker will delete
the armed timer as before.

Reported-by: syzbot+61464b62b688791cc24c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=61464b62b688791cc24c
Reported-by: syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a2e50fb40695811c2dab
Fixes: dbec27298b0d ("staging: greybus: operation: add generic timeout support")
Link: https://lore.kernel.org/all/20261022134817.1703927-1-hackerowskiy@gmail.com/
Link: https://lore.kernel.org/all/20261103-gb-uart-transport-v5-3-f8e326d6561f@beagleboard.org/
Cc: stable@vger.kernel.org
Signed-off-by: linfordWu <linfordwu@163.com>
---
 drivers/greybus/operation.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
index 7e12ffb2dd6..7d4006f4bbd 100644
--- a/drivers/greybus/operation.c
+++ b/drivers/greybus/operation.c
@@ -725,6 +725,7 @@ int gb_operation_request_send(struct gb_operation *operation,
 {
 	struct gb_connection *connection = operation->connection;
 	struct gb_operation_msg_hdr *header;
+	unsigned long flags;
 	unsigned int cycle;
 	int ret;
 
@@ -771,8 +772,12 @@ int gb_operation_request_send(struct gb_operation *operation,
 		goto err_put_active;
 
 	if (timeout) {
-		operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
-		add_timer(&operation->timer);
+		spin_lock_irqsave(&gb_operations_lock, flags);
+		if (operation->errno == -EINPROGRESS) {
+			operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
+			add_timer(&operation->timer);
+		}
+		spin_unlock_irqrestore(&gb_operations_lock, flags);
 	}
 
 	return 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 14:11 [PATCH] greybus: operation: fix request timeout race linfordWu
2026-11-29 15:45 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox