From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9553 Path: news.gmane.org!not-for-mail From: John Found Newsgroups: gmane.linux.lib.musl.general Subject: Re: Memory management, how to protect some address space. Date: Thu, 10 Mar 2016 21:02:04 +0200 Message-ID: <20160310210204.4c388872b04be2c4fe6a04f3@asm32.info> References: <20160310102252.f0401b98c0c333dd9dff9587@asm32.info> <20160310164515.GN9349@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1457636552 15795 80.91.229.3 (10 Mar 2016 19:02:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2016 19:02:32 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9566-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 10 20:02:23 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ae5qk-0001UD-6T for gllmg-musl@m.gmane.org; Thu, 10 Mar 2016 20:02:18 +0100 Original-Received: (qmail 26114 invoked by uid 550); 10 Mar 2016 19:02:16 -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 26096 invoked from network); 10 Mar 2016 19:02:15 -0000 In-Reply-To: <20160310164515.GN9349@brightrain.aerifal.cx> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.29; x86_64-unknown-linux-gnu) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hemus.superhosting.bg X-AntiAbuse: Original Domain - lists.openwall.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - asm32.info X-Get-Message-Sender-Via: hemus.superhosting.bg: authenticated_id: johnfound@asm32.info X-Authenticated-Sender: hemus.superhosting.bg: johnfound@asm32.info X-Source: X-Source-Args: X-Source-Dir: Xref: news.gmane.org gmane.linux.lib.musl.general:9553 Archived-At: On Thu, 10 Mar 2016 11:45:15 -0500 Rich Felker wrote: > This is not musl-specific; Linux always does that for 32-bit x86 > binaries running on a 64-bit kernel. You can either run on a 32-bit > kernel or set the ADDR_LIMIT_3GB personality() flag when running your > program. Assuming part of the address space is not used is not a > portable assumption to make, though. > > Rich Thanks! The sys_personality is exactly what I needed. I simply was not aware of this function. Unfortunately the documentation is very poor and when testing it, I have some issues, both with MUSL and Linux. 1. It seems to be MUSL problem - after setting the personality, the first several memory allocations from MUSL's malloc function still return addresses outside the 3GB range. After that it starts to allocate proper addresses. The count of the "bad" allocations depends on the size of the allocated blocks. Is it a bug, or I must call some MUSL re-initialization function? BTW, this behaviour is not observed with glibc. 2. The stack of the application remains allocated above 3GB space. It seems to be Linux issue, but I still will appreciate some help. Best Regards -- http://fresh.flatassembler.net http://asm32.info John Found