From: linfordWu <linfordwu@163.com>
To: Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: greybus-dev@lists.linaro.org, linux-kernel@vger.kernel.org,
linfordWu <linfordwu@163.com>,
syzbot+61464b62b688791cc24c@syzkaller.appspotmail.com,
syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: [PATCH] greybus: operation: fix request timeout race
Date: Sun, 29 Nov 2026 22:11:23 +0800 [thread overview]
Message-ID: <20261129141123.2172008-1-linfordwu@163.com> (raw)
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
next reply other threads:[~2026-11-29 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 14:11 linfordWu [this message]
2026-11-29 15:45 ` Greg Kroah-Hartman
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=20261129141123.2172008-1-linfordwu@163.com \
--to=linfordwu@163.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+61464b62b688791cc24c@syzkaller.appspotmail.com \
--cc=syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®