[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range
|
From: |
Warner Losh |
|
Subject: |
[PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range |
|
Date: |
Fri, 2 Aug 2024 17:56:12 -0600 |
This is the generic validation function, so remove some hand-rolled
ones.
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/mmap.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index fc69cb43ebd..ed8d31a9048 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -74,9 +74,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)
if ((start & ~TARGET_PAGE_MASK) != 0)
return -EINVAL;
len = TARGET_PAGE_ALIGN(len);
+ if (!guest_range_valid_untagged(start, len)) {
+ return -ENOMEM;
+ }
end = start + len;
- if (end < start)
- return -EINVAL;
prot &= PROT_READ | PROT_WRITE | PROT_EXEC;
if (len == 0)
return 0;
@@ -689,11 +690,13 @@ int target_munmap(abi_ulong start, abi_ulong len)
TARGET_ABI_FMT_lx "\n",
start, len);
#endif
- if (start & ~TARGET_PAGE_MASK)
+ if (start & ~TARGET_PAGE_MASK) {
return -EINVAL;
+ }
len = TARGET_PAGE_ALIGN(len);
- if (len == 0)
+ if (len == 0 || !guest_range_valid_untagged(start, len)) {
return -EINVAL;
+ }
mmap_lock();
end = start + len;
real_start = start & qemu_host_page_mask;
--
2.45.1
- [PATCH 00/17] For 9.2: A bunch of cleanups and work towards variable pagesize support, Warner Losh, 2024/08/02
- [PATCH 01/17] bsd-user: Delete TaskState next member, Warner Losh, 2024/08/02
- [PATCH 02/17] bsd-user: Make init_task_state global, Warner Losh, 2024/08/02
- [PATCH 04/17] bsd-user: Implement cpu_copy(), Warner Losh, 2024/08/02
- [PATCH 05/17] bsd-user: Eliminate unused regs arg in load_elf_binary, Warner Losh, 2024/08/02
- [PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range,
Warner Losh <=
- [PATCH 03/17] bsd-user: Make cpu_model and cpu_type file scope, Warner Losh, 2024/08/02
- [PATCH 07/17] bsd-user: Remove deprecated -p argument, Warner Losh, 2024/08/02
- [PATCH 08/17] bsd-user: Eliminate unused qemu_uname_release, Warner Losh, 2024/08/02
- [PATCH 06/17] bsd-user: Remove load_flt_binary prototype, Warner Losh, 2024/08/02
- [PATCH 11/17] bsd-user: Replace set_brk and padzero with zerobss from linux-user, Warner Losh, 2024/08/02