[PATCH] Consolidate Linux mmap implementation

Florian Weimer fweimer@redhat.com
Wed Apr 12 14:03:00 GMT 2017


On 03/24/2017 04:39 PM, Adhemerval Zanella wrote:
> +  /* For architectures with sizeof (off_t) < sizeof (off64_t) mmap is
> +     implemented with __SYS_mmap2 syscall and the offset is represented in
> +     multiples of page size.  For offset larger than
> +     '1 << (page_shift + 8 * sizeof (off_t))' (that is, 1<<44 on system with
> +     page size of 4096 bytes) the system call silently truncates the offset.
> +     For this case glibc mmap implementation returns EINVAL.  */
> +  const int prot = PROT_READ | PROT_WRITE;
> +  const int flags = MAP_SHARED;
> +  const int64_t offset = 1ULL << (page_shift + 8 * sizeof (uint32_t));

Is there a test already which checks that an offset which is not a 
multiple of the page size is not silently rounded down?

Thanks,
Florian



More information about the Libc-alpha mailing list