From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12006 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH v1] mman: fix mmap pass wrong offset to kernel Date: Mon, 16 Oct 2017 13:03:18 +0200 Message-ID: <20171016110318.GQ15263@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1508151876 23460 195.159.176.226 (16 Oct 2017 11:04:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Oct 2017 11:04:36 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) Cc: musl@lists.openwall.com To: Minqiang Chen Original-X-From: musl-return-12019-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 16 13:04:32 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1e43C5-0004tI-RJ for gllmg-musl@m.gmane.org; Mon, 16 Oct 2017 13:04:25 +0200 Original-Received: (qmail 14094 invoked by uid 550); 16 Oct 2017 11:04:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13630 invoked from network); 16 Oct 2017 11:03:30 -0000 Mail-Followup-To: Minqiang Chen , musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:12006 Archived-At: * Minqiang Chen [2017-10-16 09:09:32 +0800]: > > musl: fix mmap pass wrong offset to kernel > > > > for example off_t x=0x8d9eb000, the x/4096 result is 0xfff8d9eb, > not 0x8d9eb as expecting > off_t is 64bit, not 32bit, so x/4096 should not signextend. you need to investigate this problem more. > this happens on arm_cortex-a15 with gcc 6.3.x > > > > Signed-off-by: Chen Minqiang > > > *diff --git a/src/mman/mmap.c b/src/mman/mmap.c* > > *index 1592403..a09c901 100644* > > *--- a/src/mman/mmap.c* > > *+++ b/src/mman/mmap.c* > > *@@ -27,7 +27,7 @@* void *__mmap(void *start, size_t len, int prot, int > flags, int fd, off_t off) > > __vm_wait(); > > } > > #ifdef SYS_mmap2 > > *- ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);* > > *+* *ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, > (unsigned long)off/UNIT);* this is wrong, off is 64bit signed int, it can have values outside of the range of unsigned long. (and your email client ruined the patch with random '*' and '\n')