This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Consolidate Linux mmap implementation


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]