Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3703285ybv; Mon, 10 Feb 2020 05:01:30 -0800 (PST) X-Google-Smtp-Source: APXvYqww+e54RKJpPW/1qb/SmOSaSkib3mz1IuId3VAWQwuSmYsEFn6QNRfTZg6wL2elgLCorwDe X-Received: by 2002:aca:54cc:: with SMTP id i195mr729027oib.126.1581339690648; Mon, 10 Feb 2020 05:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339690; cv=none; d=google.com; s=arc-20160816; b=OMWs5ZsZzJ7l3BeNPe3T6/OoQiXzr9DaF00oazbh3PZ+JBxZmx4n1UyYSGjB70OnWQ MDKGMr0U8i84aS6C/V7asHkBYjENqC6XL2+MG8f70JEtVtlkiLWByjTeGbFJOnExMEpn AtZWK2eIwSctMMgWy9ERaRIQ9kB+84FATh6ilQ4fytz2TwOwMMZ9J+emqUivqgViCiG5 5atgl64WvQWmxkDKCswVXGhZl7JQmAxe+yXZti2pvyojYnsZSEtMEpqcJMZHvHDYAu3D vOTe/gdmYQPeFqu/KC8pqOJY6vAH9iPHEP5x23vZWV4hBfM1larX4/YcAn1uh8OLcoBr 9QrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e0/dfN0KytR90bYUi9bo2X/VbqmBz/AROxcOBPTcBLw=; b=hyHQgkSYwaYKFyqj9+LjLRMRAbdzY0sI7ElgsAXlNNbQh6uaLrvWFQNi3EG4uBm2Mq rZNkd3J7BRRNKsJ8gsOZ2hFzYpb+hOj8Apcb/hHkiGjr4EddatRzWZ+XKts5/cb/ojEs 0aVuUPanmbGPZV4d4Gu9F2M9e14SuqI1ZhYrhIOmEUe2mAePUj26WElswH+odnE1ejYc swX6GJOCqzasA9vzNdQbtKd3ZTE7Tb+x5u+rK81aTlQVqVl/Pup7aRzAZwXNacTeiAof x1SidsDqe3LFeU3jWgvjLfP6aSITkG519fw//qmgZDw5EivO5CqEISbslpgZOxSBIcIt ZjnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="C6y7gla/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7si145902oth.181.2020.02.10.05.01.17; Mon, 10 Feb 2020 05:01:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="C6y7gla/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730230AbgBJM7w (ORCPT + 99 others); Mon, 10 Feb 2020 07:59:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:42486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729563AbgBJMlE (ORCPT ); Mon, 10 Feb 2020 07:41:04 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EB342467C; Mon, 10 Feb 2020 12:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338464; bh=1mBv9FsT65fiq4XZwUJQkTx18vF+a9/p+GVNey9Umcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C6y7gla/l62X0XQ1lD8QmQa2iSM1DDpp/SfhVfaXufwiaH1LU7gXUAXTZJIE8sOCb E/kXk0CzQ81+LfSnPSLgOt2f9fYFX4fO5xH867wPQXFYSlkHE14/9hQhrP9rnkGiwk jllEXNQ0ExRIr4PUVI+4rtNimuR9irpEon32OVIM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Melnic , Jens Axboe Subject: [PATCH 5.5 223/367] io_uring: dont map read/write iovec potentially twice Date: Mon, 10 Feb 2020 04:32:16 -0800 Message-Id: <20200210122444.634072021@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Axboe commit 5d204bcfa09330972ad3428a8f81c23f371d3e6d upstream. If we have a read/write that is deferred, we already setup the async IO context for that request, and mapped it. When we later try and execute the request and we get -EAGAIN, we don't want to attempt to re-map it. If we do, we end up with garbage in the iovec, which typically leads to an -EFAULT or -EINVAL completion. Cc: stable@vger.kernel.org # 5.5 Reported-by: Dan Melnic Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1789,10 +1789,12 @@ static int io_setup_async_rw(struct io_k if (req->opcode == IORING_OP_READ_FIXED || req->opcode == IORING_OP_WRITE_FIXED) return 0; - if (!req->io && io_alloc_async_ctx(req)) - return -ENOMEM; + if (!req->io) { + if (io_alloc_async_ctx(req)) + return -ENOMEM; - io_req_map_rw(req, io_size, iovec, fast_iov, iter); + io_req_map_rw(req, io_size, iovec, fast_iov, iter); + } req->work.func = io_rw_async; return 0; }