From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101151 invoked by alias); 12 Apr 2017 14:15:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 78365 invoked by uid 89); 12 Apr 2017 14:15:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=3mLbeGMhh54Rca6ifFe5L8kwHW/NZoTgxVhE5TBT3f0=; b=kKRYvTL0+aEBQrcYTXpa7NJG7HcxO60otUWQQ+iHccbLqoalG/psXF7J19/pAwtdEn TnsCSvdV2JhodC/068HYNsfbbJy84p38PMT9KU4a2iaszRY4JJP1V29jh/GchEbNbTKo 9jatryNqY17HRIsN4aKWE9auHz8yvHhW8pVRYMaY/mdATUrFiVbshYuoibYlGZB8dC6n jdBTCzBrd2j8hkwhvSYceNrmELkMOmt6m2eqGJzXbMnOESdHZB/cdUTZ3553ah0bs0PW gKWw5koI7MuBemZ5WLtLJZF5Wpka/EojPkF0KMIXOHLojZEzg/Al3BFgosOmuM+0Z50c wxtQ== X-Gm-Message-State: AFeK/H06VaX046yUdTyxx/wlX1Dg1bP80zCnztG8uLYnCUhGiDj0Hid4OKP6R538y1jbwTe2 X-Received: by 10.237.32.240 with SMTP id 103mr64060455qtb.93.1492006510870; Wed, 12 Apr 2017 07:15:10 -0700 (PDT) Subject: Re: [PATCH] Consolidate Linux mmap implementation To: Florian Weimer , libc-alpha@sourceware.org References: <1490369962-29989-1-git-send-email-adhemerval.zanella@linaro.org> <757b1881-bd83-ac34-c299-c3fc9c9731d7@redhat.com> From: Adhemerval Zanella Message-ID: <3ed57c86-6260-d6fe-fc90-e70b7e888f46@linaro.org> Date: Wed, 12 Apr 2017 14:15:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <757b1881-bd83-ac34-c299-c3fc9c9731d7@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00216.txt.bz2 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 }