Hi, thanks, I committed this patch because indeed the mprotect manual
pages, in both Linux and posix, both talk about (possible) errors if addr
is not aligned, but keep suspiciously silent about len. But I'm curious,
how did you find this issue? Did it break actual code that tried to use
unaligned length?

On Sat, Jun 29, 2019 at 7:07 AM Waldemar Kozaczuk <jwkozac...@gmail.com>
wrote:

> Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
> ---
>  libc/mman.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libc/mman.cc b/libc/mman.cc
> index 73a3f416..bb573a80 100644
> --- a/libc/mman.cc
> +++ b/libc/mman.cc
> @@ -88,11 +88,12 @@ int mprotect(void *addr, size_t len, int prot)
>          abort("mprotect() on linear map not supported\n");
>      }
>
> -    if (!mmu::is_page_aligned(addr) || !mmu::is_page_aligned(len)) {
> +    if (!mmu::is_page_aligned(addr)) {
>          // address not page aligned
>          return libc_error(EINVAL);
>      }
>
> +    len = align_up(len, mmu::page_size);
>      return mmu::mprotect(addr, len, libc_prot_to_perm(prot)).to_libc();
>  }
>
> --
> 2.20.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20190629040727.9569-1-jwkozaczuk%40gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjtk2pmhUd3sx5XPpaVjapyqHBjcSa7Dax3G61S-jjiVKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to