From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] Consolidate Linux mmap implementation
Date: Wed, 12 Apr 2017 14:15:00 -0000 [thread overview]
Message-ID: <3ed57c86-6260-d6fe-fc90-e70b7e888f46@linaro.org> (raw)
In-Reply-To: <757b1881-bd83-ac34-c299-c3fc9c9731d7@redhat.com>
On 12/04/2017 11:03, Florian Weimer wrote:
> 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
posix/tst-mmap.c already check this up for both mmap/mmap64:
42 /* First try something which is not allowed: map at an offset which is
43 not modulo the pagesize. */
44 ptr = mmap (NULL, 1000, PROT_READ, MAP_SHARED, fd, ps - 1);
45 if (ptr != MAP_FAILED)
46 {
47 puts ("mapping at offset with mod pagesize != 0 succeeded!");
48 result = 1;
49 }
50 else if (errno != EINVAL && errno != ENOSYS)
51 {
52 puts ("wrong error value for mapping at offset with mod pagesize != 0: %m (should be EINVAL)");
53 result = 1;
54 }
prev parent reply other threads:[~2017-04-12 14:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 15:39 Adhemerval Zanella
2017-03-24 17:42 ` Andreas Schwab
2017-03-24 17:57 ` Adhemerval Zanella
2017-04-06 20:00 ` Adhemerval Zanella
2017-04-12 12:44 ` Adhemerval Zanella
2017-04-12 14:03 ` Florian Weimer
2017-04-12 14:15 ` Adhemerval Zanella [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ed57c86-6260-d6fe-fc90-e70b7e888f46@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).