lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV0Kv4s8Iqp-E8Ge@fedora>
Date: Tue, 6 Jan 2026 21:14:39 +0800
From: Ming Lei <ming.lei@...hat.com>
To: Caleb Sander Mateos <csander@...estorage.com>
Cc: Jens Axboe <axboe@...nel.dk>, Shuah Khan <shuah@...nel.org>,
	linux-block@...r.kernel.org, linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Stanley Zhang <stazhang@...estorage.com>,
	Uday Shankar <ushankar@...estorage.com>,
	"Martin K . Petersen" <martin.petersen@...cle.com>
Subject: Re: [PATCH v3 05/19] ublk: add ublk_copy_user_bvec() helper

On Mon, Jan 05, 2026 at 05:57:37PM -0700, Caleb Sander Mateos wrote:
> Factor a helper function ublk_copy_user_bvec() out of
> ublk_copy_user_pages(). It will be used for copying integrity data too.
> 
> Signed-off-by: Caleb Sander Mateos <csander@...estorage.com>
> ---
>  drivers/block/ublk_drv.c | 52 +++++++++++++++++++++++-----------------
>  1 file changed, 30 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 2b0a9720921d..2ce9afdecc15 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1000,10 +1000,39 @@ static const struct block_device_operations ub_fops = {
>  	.open =		ublk_open,
>  	.free_disk =	ublk_free_disk,
>  	.report_zones =	ublk_report_zones,
>  };
>  
> +static bool ublk_copy_user_bvec(const struct bio_vec *bv, unsigned *offset,
> +				struct iov_iter *uiter, int dir, size_t *done)
> +{
> +	unsigned len;
> +	void *bv_buf;
> +	size_t copied;
> +
> +	if (*offset >= bv->bv_len) {
> +		*offset -= bv->bv_len;
> +		return true;
> +	}
> +
> +	len = bv->bv_len - *offset;
> +	bv_buf = kmap_local_page(bv->bv_page) + bv->bv_offset + *offset;
> +	if (dir == ITER_DEST)
> +		copied = copy_to_iter(bv_buf, len, uiter);
> +	else
> +		copied = copy_from_iter(bv_buf, len, uiter);
> +
> +	kunmap_local(bv_buf);
> +
> +	*done += copied;
> +	if (copied < len)
> +		return false;
> +
> +	*offset = 0;
> +	return true;
> +}
> +
>  /*
>   * Copy data between request pages and io_iter, and 'offset'
>   * is the start point of linear offset of request.
>   */
>  static size_t ublk_copy_user_pages(const struct request *req,
> @@ -1012,33 +1041,12 @@ static size_t ublk_copy_user_pages(const struct request *req,
>  	struct req_iterator iter;
>  	struct bio_vec bv;
>  	size_t done = 0;
>  
>  	rq_for_each_segment(bv, req, iter) {
> -		unsigned len;
> -		void *bv_buf;
> -		size_t copied;
> -
> -		if (offset >= bv.bv_len) {
> -			offset -= bv.bv_len;
> -			continue;
> -		}
> -
> -		len = bv.bv_len - offset;
> -		bv_buf = kmap_local_page(bv.bv_page) + bv.bv_offset + offset;
> -		if (dir == ITER_DEST)
> -			copied = copy_to_iter(bv_buf, len, uiter);
> -		else
> -			copied = copy_from_iter(bv_buf, len, uiter);
> -
> -		kunmap_local(bv_buf);
> -
> -		done += copied;
> -		if (copied < len)
> +		if (!ublk_copy_user_bvec(&bv, &offset, uiter, dir, &done))
>  			break;
> -
> -		offset = 0;
>  	}
>  	return done;
>  }

Reviewed-by: Ming Lei <ming.lei@...hat.com>


Thanks, 
Ming


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ