Re: [PATCH] iov_iter: Avoid wrap-around instrumentation in copy_compat_iovec_from_user()

From: Christian Brauner
Date: Tue Jan 30 2024 - 04:46:55 EST


On Mon, 29 Jan 2024 10:37:29 -0800, Kees Cook wrote:
> The loop counter "i" in copy_compat_iovec_from_user() is an int, but
> because the nr_segs argument is unsigned long, the signed overflow
> sanitizer got worried "i" could wrap around. Instead of making "i" an
> unsigned long (which may enlarge the type size), switch both nr_segs
> and i to u32. There is no truncation with nr_segs since it is never
> larger than UIO_MAXIOV anyway. This keeps sanitizer instrumentation[1]
> out of a UACCESS path:
>
> [...]

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[1/1] iov_iter: Avoid wrap-around instrumentation in copy_compat_iovec_from_user()
https://git.kernel.org/vfs/vfs/c/2d5099585c5b