io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: Re: [PATCH 1/2] io_uring: fix ->work corruption with poll_add
Date: Fri, 24 Jul 2020 20:15:59 +0300	[thread overview]
Message-ID: <0fe2c36d-1988-8ce6-df21-531410837073@gmail.com> (raw)
In-Reply-To: <3aad8261c564462b78b96d79ff23b7ac2e253b41.1595610422.git.asml.silence@gmail.com>

On 24/07/2020 20:07, Pavel Begunkov wrote:
> req->work might be already initialised by the time it gets into
> __io_arm_poll_handler(), which will corrupt it be using fields that are
s/be using/by using/

Jens, could you please fold it in, if the patch would do? Or let me know
and I'll resend.

> in an union with req->work. Luckily, the only side effect is missing
> put_creds(). Clean req->work before going there.
> 
> Suggested-by: Jens Axboe <axboe@kernel.dk>
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  fs/io_uring.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 32b0064f806e..98e8079e67e7 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -4658,6 +4658,10 @@ static int io_poll_add(struct io_kiocb *req)
>  	struct io_poll_table ipt;
>  	__poll_t mask;
>  
> +	/* ->work is in union with hash_node and others */
> +	io_req_work_drop_env(req);
> +	req->flags &= ~REQ_F_WORK_INITIALIZED;
> +
>  	INIT_HLIST_NODE(&req->hash_node);
>  	INIT_LIST_HEAD(&req->list);
>  	ipt.pt._qproc = io_poll_queue_proc;
> 

-- 
Pavel Begunkov

  reply	other threads:[~2020-07-24 17:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 17:07 [PATCH 0/2] two 5.8 fixes Pavel Begunkov
2020-07-24 17:07 ` [PATCH 1/2] io_uring: fix ->work corruption with poll_add Pavel Begunkov
2020-07-24 17:15   ` Pavel Begunkov [this message]
2020-07-24 17:07 ` [PATCH 2/2] io_uring: fix lockup in io_fail_links() Pavel Begunkov
2020-07-24 19:23 ` [PATCH 0/2] two 5.8 fixes 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=0fe2c36d-1988-8ce6-df21-531410837073@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).