All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH 1/2] io_uring: fail cancellation for EXITING tasks
Date: Fri, 26 Nov 2021 15:32:33 +0000	[thread overview]
Message-ID: <4f35110d-d1a4-f6b0-6d74-0b523c7b981a@gmail.com> (raw)
In-Reply-To: <4c41c5f379c6941ad5a07cd48cb66ed62199cf7e.1637937097.git.asml.silence@gmail.com>

On 11/26/21 14:38, Pavel Begunkov wrote:
> We need original task's context to do cancellations, so if it's dying
> and the callback is executed in a fallback mode, fail the cancellation
> attempt.

Fixes: 89b263f6d56e6 ("io_uring: run linked timeouts from task_work")
Cc: stable@kernel.org # 5.15+

> 
> Reported-by: syzbot+ab0cfe96c2b3cd1c1153@syzkaller.appspotmail.com
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>   fs/io_uring.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index a4c508a1e0cf..7dd112d44adf 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -6882,10 +6882,11 @@ static inline struct file *io_file_get(struct io_ring_ctx *ctx,
>   static void io_req_task_link_timeout(struct io_kiocb *req, bool *locked)
>   {
>   	struct io_kiocb *prev = req->timeout.prev;
> -	int ret;
> +	int ret = -ENOENT;
>   
>   	if (prev) {
> -		ret = io_try_cancel_userdata(req, prev->user_data);
> +		if (!(req->task->flags & PF_EXITING))
> +			ret = io_try_cancel_userdata(req, prev->user_data);
>   		io_req_complete_post(req, ret ?: -ETIME, 0);
>   		io_put_req(prev);
>   	} else {
> 

-- 
Pavel Begunkov

  reply	other threads:[~2021-11-26 15:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 14:38 [PATCH 0/2] 5.16 fixes for syz reports Pavel Begunkov
2021-11-26 14:38 ` [PATCH 1/2] io_uring: fail cancellation for EXITING tasks Pavel Begunkov
2021-11-26 15:32   ` Pavel Begunkov [this message]
2021-11-26 14:38 ` [PATCH 2/2] io_uring: fix link traversal locking Pavel Begunkov
2021-11-26 15:29   ` Pavel Begunkov
2021-11-26 15:36 ` [PATCH 0/2] 5.16 fixes for syz reports Jens Axboe

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=4f35110d-d1a4-f6b0-6d74-0b523c7b981a@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.