[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock
|
From: |
Ilya Leoshkevich |
|
Subject: |
Re: [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock |
|
Date: |
Mon, 29 Jan 2024 15:52:45 +0100 |
On Tue, Jan 02, 2024 at 12:57:52PM +1100, Richard Henderson wrote:
> Basic validation of operands does not require the lock.
> Hoist them from target_mmap__locked back into target_mmap.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/mmap.c | 107 +++++++++++++++++++++++-----------------------
> 1 file changed, 53 insertions(+), 54 deletions(-)
>
> diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> index b4c3cc65aa..fbaea832c5 100644
> --- a/linux-user/mmap.c
> +++ b/linux-user/mmap.c
[...]
> @@ -778,13 +726,64 @@ abi_long target_mmap(abi_ulong start, abi_ulong len,
> int target_prot,
> int flags, int fd, off_t offset)
> {
> abi_long ret;
> + int page_flags;
>
> trace_target_mmap(start, len, target_prot, flags, fd, offset);
> +
> + if (!len) {
> + errno = EINVAL;
> + return -1;
> + }
> +
> + page_flags = validate_prot_to_pageflags(target_prot);
> + if (!page_flags) {
> + errno = EINVAL;
> + return -1;
> + }
> +
> + /* Also check for overflows... */
> + len = TARGET_PAGE_ALIGN(len);
> + if (!len || len != (size_t)len) {
> + errno = ENOMEM;
> + return -1;
> + }
The overflow fix is probably worth mentioning in the commit message (or
even deserves a separate commit, for backporting into stable).
Regardless:
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
- [PATCH v3 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN, (continued)
- [PATCH v3 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN, Richard Henderson, 2024/01/01
- [PATCH v3 15/33] linux-user: Remove qemu_host_page_size from main, Richard Henderson, 2024/01/01
- [PATCH v3 16/33] linux-user: Split out target_mmap__locked, Richard Henderson, 2024/01/01
- [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock, Richard Henderson, 2024/01/01
- Re: [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock,
Ilya Leoshkevich <=
- [PATCH v3 18/33] linux-user: Fix sub-host-page mmap, Richard Henderson, 2024/01/01
- [PATCH v3 19/33] linux-user: Split out mmap_end, Richard Henderson, 2024/01/01
- [PATCH v3 21/33] linux-user: Split out mmap_h_eq_g, Richard Henderson, 2024/01/01
- [PATCH v3 24/33] tests/tcg: Remove run-test-mmap-*, Richard Henderson, 2024/01/01