Re: [PATCH] greybus: operation: fix request timeout race
From: Greg Kroah-Hartman
Date: Sun Nov 29 2026 - 10:46:10 EST
On Sun, Nov 29, 2026 at 10:11:23PM +0800, linfordWu wrote:
> 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.
How was this found and tested?
> Reported-by: syzbot+61464b62b688791cc24c@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=61464b62b688791cc24c
> Reported-by: syzbot+a2e50fb40695811c2dab@xxxxxxxxxxxxxxxxxxxxxxxxx
> 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@xxxxxxxxx/
> Link: https://lore.kernel.org/all/20261103-gb-uart-transport-v5-3-f8e326d6561f@xxxxxxxxxxxxxxx/
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: linfordWu <linfordwu@xxxxxxx>
Real name please.
> ---
> 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);
why irq? And what about guard()? Did you use a LLM to create this
patch?
thanks,
greg k-h