Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1523926ybl; Thu, 22 Aug 2019 16:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzu/C9p7Qq15aWzKXJwHpjRJbnZ/5QjrqCWvbi8U909b77lr0n/9ddTwq4tt3xXBvgHR9c8 X-Received: by 2002:a62:1703:: with SMTP id 3mr1867680pfx.118.1566516240678; Thu, 22 Aug 2019 16:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566516240; cv=none; d=google.com; s=arc-20160816; b=nAEsdWWB1jBDa4w5rQB/2VdgBEf+Goo/ilmL0oJ3cp7WJv9YX7c52jyUWwT9K/ndWq 3bn2k3nLmUYHQ9q/Zu/flzNCroppfXb7JseyhB0fabmCBkrnh9+fAvYa2ptgKV9NeV67 hhwVAbU+Agu6BVLPlxdGBlnULKSBiHtAOUnA2g7OBA+TfSuoom9ueprKIoKaTb4HK3M1 aPApJXPYrBLR7HnUlMFeb+s4P90G5qPju2RgxrVN4jsvNwzqhsPkM4Z88fhU102sb8cg ta3AdW1H82JSR8qdB4H6V1CBco7BKejFwyRhn4l01vYMvS7bMHAln6P+vCP4c1tTyj1y VkpQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=avDrxZrjxcpOabuTVUx7tWpLT/21e09lZ6xoX0a+3b0=; b=dXF9Vj+6cLiUjKtAAfYGA1Hs3LnsGowX+qPfku8mDERYDAwGnNCqwWzqEr82YAMmPJ tbEfGugPBnIGX1LVSuqiX4tAFPXsYikruT+Xs2YsXsFqwe086NbTjMEdJayGBvgkO1CC Gug/HbdO44KPG4YlwoJx/Omt1nD8TOfcI+udkmUomO6bT+AMZ0vBUfZMpQsdiDF62rmf 5kyAPZJTuBEcTB2J9DnSfJ8o2MkYhbmWByUtOeA3H5NEiveXkUKdJ+mRmmhE76W/oiYI yJNaIGRtTOz1RQI8cKcONY5AyTQhu5bfbtq3GQqq/57oTKccFjkeU0NID6Dq5FCnqQ0u DR5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LrqCH28M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d24si778722plr.187.2019.08.22.16.23.45; Thu, 22 Aug 2019 16:24:00 -0700 (PDT) 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=LrqCH28M; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391226AbfHVRQ3 (ORCPT + 99 others); Thu, 22 Aug 2019 13:16:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390387AbfHVRIe (ORCPT ); Thu, 22 Aug 2019 13:08:34 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6233623428; Thu, 22 Aug 2019 17:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493713; bh=LYS3PhcNvoh+tL1N6o+HYoRwuN6L08WbmA+xaB04Dyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LrqCH28MvSBoLmnYKYV+vdbpaxbs+W9BeFOH1fD9IfQTjc60ZXCFmzldHlLqx2ZzM yl1kJFxJl5mNTc8scdVUNIV+2zVDaHYfXADrOkUrcxPtX2QbzvA6oCUOSAPJG+WkDK IbtyNo88bxSzB4BfYfQigcg/DxJfroneS48hHLlE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aleix Roca Nonell , Jens Axboe , Greg Kroah-Hartman Subject: [PATCH 5.2 036/135] io_uring: fix manual setup of iov_iter for fixed buffers Date: Thu, 22 Aug 2019 13:06:32 -0400 Message-Id: <20190822170811.13303-37-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aleix Roca Nonell commit 99c79f6692ccdc42e04deea8a36e22bb48168a62 upstream. Commit bd11b3a391e3 ("io_uring: don't use iov_iter_advance() for fixed buffers") introduced an optimization to avoid using the slow iov_iter_advance by manually populating the iov_iter iterator in some cases. However, the computation of the iterator count field was erroneous: The first bvec was always accounted for an extent of page size even if the bvec length was smaller. In consequence, some I/O operations on fixed buffers were unable to operate on the full extent of the buffer, consistently skipping some bytes at the end of it. Fixes: bd11b3a391e3 ("io_uring: don't use iov_iter_advance() for fixed buffers") Cc: stable@vger.kernel.org Signed-off-by: Aleix Roca Nonell Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 3e887a09533b3..61018559e8fe6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1032,10 +1032,8 @@ static int io_import_fixed(struct io_ring_ctx *ctx, int rw, iter->bvec = bvec + seg_skip; iter->nr_segs -= seg_skip; - iter->count -= (seg_skip << PAGE_SHIFT); + iter->count -= bvec->bv_len + offset; iter->iov_offset = offset & ~PAGE_MASK; - if (iter->iov_offset) - iter->count -= iter->iov_offset; } } -- 2.20.1