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: <438a8b44-ea5f-4e13-bd7e-e1c2e2a481c4@kernel.dk>
Date:   Mon, 4 Dec 2023 09:36:31 -0700
From:   Jens Axboe <axboe@...nel.dk>
To:     Sumit Garg <sumit.garg@...aro.org>,
        Arnaud POULIQUEN <arnaud.pouliquen@...s.st.com>,
        Al Viro <viro@...iv.linux.org.uk>
Cc:     Jens Wiklander <jens.wiklander@...aro.org>,
        Christoph Hellwig <hch@...radead.org>,
        op-tee@...ts.trustedfirmware.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] tee: Use iov_iter to better support shared buffer
 registration

On 12/4/23 5:42 AM, Sumit Garg wrote:
> IMO, access_ok() should be the first thing that import_ubuf() or
> import_single_range() should do, something as follows:
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 8ff6824a1005..4aee0371824c 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1384,10 +1384,10 @@ EXPORT_SYMBOL(import_single_range);
> 
>  int import_ubuf(int rw, void __user *buf, size_t len, struct iov_iter *i)
>  {
> -       if (len > MAX_RW_COUNT)
> -               len = MAX_RW_COUNT;
>         if (unlikely(!access_ok(buf, len)))
>                 return -EFAULT;
> +       if (len > MAX_RW_COUNT)
> +               len = MAX_RW_COUNT;
> 
>         iov_iter_ubuf(i, rw, buf, len);
>         return 0;
> 
> Jens A., Al Viro,
> 
> Was there any particular reason which I am unaware of to perform
> access_ok() check on modified input length?

This change makes sense to me, and seems consistent with what is done
elsewhere too.

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ