From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA3B14F9E7; Wed, 5 Feb 2025 13:54:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738763688; cv=none; b=lF1s9IwSvTIBEDQCXYhhNUd+qFVJqzl8Zosr4po0AjQKKaCw5pWcuM5jIukyMDQ6JvFDdsWmepoYT20S+2ri845WBZGXLu4tMjxbzsFYd+8W2GshnnYBFrC18adT9TKfHbtod37Jy4GkSYvCUjjJgGpTPOwISxhlRbHneQJKaZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738763688; c=relaxed/simple; bh=ErUzmZZbPBwJKjFr0YomQmzS8czQfl8dsoi7OrKNfn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l7/OrY9sxfTTXMDwrpFhaIqZZvYg4Xm3jo8Qp7cda+hOydC2RQa6D68G3zWM0I58LMIhBlQ88okcC5QbsYONofL/ZJOyE0Mh/pC1aaCJ01+0yLTHP8PSkNkDhrBBWvgV2CQXZgzWkFxcr5swWnnHkyI/AXPnAE4GWWTjDltpTAA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K9+r7KmE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="K9+r7KmE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D661C4CED6; Wed, 5 Feb 2025 13:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738763687; bh=ErUzmZZbPBwJKjFr0YomQmzS8czQfl8dsoi7OrKNfn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9+r7KmEdDA6jF3AMGq3scChjW+HuuZIFzilhvSGvsglqCfNzm/v8o7H/JgT5C8Vj V2+g0V9EupAiaOWzwQmrbhgOVvEEnwGrc2xPlLM6/tTSGFyiSEXKa/oFMRKp+oKjdI HumdlMkTN9z/iV61h7VVcYsHWwMRRA6vSyhIvWyI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Anuj Gupta , Keith Busch , Jens Axboe , Sasha Levin Subject: [PATCH 6.13 009/623] block: copy back bounce buffer to user-space correctly in case of split Date: Wed, 5 Feb 2025 14:35:51 +0100 Message-ID: <20250205134456.587063924@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134456.221272033@linuxfoundation.org> References: <20250205134456.221272033@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Hellwig [ Upstream commit 031141976be0bd5f385775727a4ed3cc845eb7ba ] Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d455969f ("block: bio-integrity: directly map user buffers") Signed-off-by: Christoph Hellwig Signed-off-by: Anuj Gupta Reviewed-by: Keith Busch Link: https://lore.kernel.org/r/20241128112240.8867-3-anuj20.g@samsung.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio-integrity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 2a4bd66116920..e73d8ed34235e 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs, static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip) { - unsigned short nr_vecs = bip->bip_max_vcnt - 1; - struct bio_vec *copy = &bip->bip_vec[1]; - size_t bytes = bip->bip_iter.bi_size; - struct iov_iter iter; + unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1; + struct bio_vec *orig_bvecs = &bip->bip_vec[1]; + struct bio_vec *bounce_bvec = &bip->bip_vec[0]; + size_t bytes = bounce_bvec->bv_len; + struct iov_iter orig_iter; int ret; - iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes); - ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter); + iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes); + ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter); WARN_ON_ONCE(ret != bytes); - bio_integrity_unpin_bvec(copy, nr_vecs, true); + bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true); } /** -- 2.39.5