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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87cacc12-03d5-4d9d-a1b1-5a1da231be2d@gmail.com>
Date: Thu, 17 Apr 2025 10:12:18 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: Jens Axboe <axboe@...nel.dk>, Nitesh Shetty <nitheshshetty@...il.com>
Cc: Nitesh Shetty <nj.shetty@...sung.com>, gost.dev@...sung.com,
 io-uring@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] io_uring/rsrc: send exact nr_segs for fixed buffer

On 4/16/25 23:23, Jens Axboe wrote:
...
> Theoretically it is, but it always makes me a bit nervous as there are
> some _really_ odd iov_iter use cases out there. And passing down known
> wrong segment counts is pretty wonky.
> 
>> Btw, where exactly does it stumble in there? I'd assume we don't
> 
> Because segments != 1, and then that hits the slower path.

Right, but walking over entire bvec is not fast either. Sounds
like you're saying it's even more expensive and that's slightly
concerning.

>> need to do the segment correction for kbuf as the bio splitting
>> can do it (and probably does) in exactly the same way?
> 
> It doesn't strictly need to, but we should handle that case too. That'd
> basically just be the loop addition I already did, something ala the
> below on top for both of them:
> 
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index d8fa7158e598..767ac89c8426 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -1032,6 +1032,25 @@ static int validate_fixed_range(u64 buf_addr, size_t len,
>   	return 0;
>   }
>   
> +static int io_import_kbuf(int ddir, struct iov_iter *iter,
> +			  struct io_mapped_ubuf *imu, size_t len, size_t offset)
> +{
> +	iov_iter_bvec(iter, ddir, iter->bvec, imu->nr_bvecs, len + offset);
> +	iov_iter_advance(iter, offset);
> +
> +	if (len + offset < imu->len) {

It should always be less or equal, are you trying to handle
the latter?

> +		const struct bio_vec *bvec = iter->bvec;
> +
> +		while (len > bvec->bv_len) {
> +			len -= bvec->bv_len;
> +			bvec++;
> +		}
> +		iter->nr_segs = bvec - iter->bvec;
> +	}
> +
> +	return 0;
> +}
> +

-- 
Pavel Begunkov


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ