|
From: | Richard Henderson |
Subject: | Re: [PATCH 16/17] bsd-user: Define validate_prot_to_pageflags and use in mprotect |
Date: | Mon, 5 Aug 2024 07:44:41 +1000 |
User-agent: | Mozilla Thunderbird |
On 8/3/24 09:56, Warner Losh wrote:
Define validate_prot_to_pageflags. Use it in target_mprotect to validate the flags. Our taraget_mmap needs more work before it can be used there, do don't copy linux-user's use of it there. This should hvae no net functional change, but does make target_mprotect more similar to linux-user's. Signed-off-by: Warner Losh <[email protected]> --- bsd-user/mmap.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
+/* + * Validate target prot bitmask. + * Return the prot bitmask for the host in *HOST_PROT. + * Return 0 if the target prot bitmask is invalid, otherwise + * the internal qemu page_flags (which will include PAGE_VALID). + */ +static int validate_prot_to_pageflags(int prot) +{ + int valid = PROT_READ | PROT_WRITE | PROT_EXEC; + int page_flags = (prot & PAGE_RWX) | PAGE_VALID; + + return prot & ~valid ? 0 : page_flags; +}
Comment still refers to @host_prot, which you removed. Otherwise, Reviewed-by: Richard Henderson <[email protected]> r~
[Prev in Thread] | Current Thread | [Next in Thread] |