mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Cc: Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
	greybus-dev@lists.linaro.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com
Subject: Re: [PATCH] greybus: operation: arm the timeout timer before sending the request
Date: Sun, 18 Oct 2026 08:47:14 +0200	[thread overview]
Message-ID: <2026101814-static-agreeing-29ad@gregkh> (raw)
In-Reply-To: <20261017171743.24612-1-ngocthang2710.1999@gmail.com>

On Sun, Oct 18, 2026 at 12:17:43AM +0700, Nguyen Ngoc Thang wrote:
> gb_operation_request_send() sends the request message and only then arms
> the operation timer. The host driver can complete the operation before
> add_timer() runs, e.g. when the transfer fails right away. The completion
> work then calls timer_delete_sync() on a timer that is not armed yet,
> the synchronous caller wakes up and drops the last reference, and
> the operation is freed while the timer is still pending:
> 
>   ODEBUG: free active (active state 0) object type: timer_list
>           hint: gb_operation_timeout+0x0/0xc0
>   WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0
>    kmem_cache_free+0xfd/0x6d0
>    gb_operation_sync_timeout+0x1c7/0x270
>    gb_svc_process_deferred_request+0x5f3/0x1150

How was this generated and tested?

> Arm the timer before the message is sent. If sending fails, delete the
> timer again. If it has already fired, its work is queued and drops the
> active and operation references itself, so the error path must not drop
> them a second time.
> 
> Fixes: dbec27298b0d ("staging: greybus: operation: add generic timeout support")
> Cc: stable@vger.kernel.org
> Reported-by: syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a2e50fb40695811c2dab
> Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
> ---
>  drivers/greybus/operation.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
> index 7e12ffb2dd60..19b0cdeca498 100644
> --- a/drivers/greybus/operation.c
> +++ b/drivers/greybus/operation.c
> @@ -766,17 +766,22 @@ int gb_operation_request_send(struct gb_operation *operation,
>  	if (ret)
>  		goto err_put;
>  
> -	ret = gb_message_send(operation->request, gfp);
> -	if (ret)
> -		goto err_put_active;
> -
> +	/* Arm before sending, as the response may complete the operation at once. */

"Arm" what?

>  	if (timeout) {
>  		operation->timer.expires = jiffies + msecs_to_jiffies(timeout);
>  		add_timer(&operation->timer);
>  	}
>  
> +	ret = gb_message_send(operation->request, gfp);
> +	if (ret)
> +		goto err_del_timer;
> +
>  	return 0;
>  
> +err_del_timer:
> +	/* A timer that already fired has queued work which drops our references. */

Why is this comment needed?

> +	if (timeout && !timer_delete_sync(&operation->timer))
> +		return ret;

Did you just leak this:

>  err_put_active:
>  	gb_operation_put_active(operation);

And again, how was this tested?

thanks,

greg k-h

  reply	other threads:[~2026-10-18  6:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 17:17 Nguyen Ngoc Thang
2026-10-18  6:47 ` Greg Kroah-Hartman [this message]
2026-10-18  6:52 ` kernel test robot
2026-10-18  9:27 ` kernel test robot

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=2026101814-static-agreeing-29ad@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=elder@kernel.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ngocthang2710.1999@gmail.com \
    --cc=stable@vger.kernel.org \
    --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®