From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9545 Path: news.gmane.org!not-for-mail From: Jaydeep Patil Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] malloc-brk-fail test Date: Thu, 10 Mar 2016 10:36:54 +0000 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_BD7773622145634B952E5B54ACA8E349AA2466D7PUMAIL01puimgte_" X-Trace: ger.gmane.org 1457606247 25381 80.91.229.3 (10 Mar 2016 10:37:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2016 10:37:27 +0000 (UTC) Cc: "musl@lists.openwall.com" , "dalias@libc.org" To: "nsz@port70.net" Original-X-From: musl-return-9558-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 10 11:37:26 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 1adxy9-0007qw-5b for gllmg-musl@m.gmane.org; Thu, 10 Mar 2016 11:37:25 +0100 Original-Received: (qmail 21894 invoked by uid 550); 10 Mar 2016 10:37: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 21845 invoked from network); 10 Mar 2016 10:37:10 -0000 Thread-Topic: [PATCH] malloc-brk-fail test Thread-Index: AdF6uMIqp2XIrEVxTSuyS8sK3x/A8w== Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.93.60] Xref: news.gmane.org gmane.linux.lib.musl.general:9545 Archived-At: --_000_BD7773622145634B952E5B54ACA8E349AA2466D7PUMAIL01puimgte_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Szabolcs, Page size on the MIPS64 Linux (v4.4) system we are using to test MUSL is 64= kb. The t_vmfill leaves up to 64kb memory, thus malloc of size 10000 (less = than page size) after t_vmfill in this case succeeds. Could you please consider this patch? diff --git a/src/regression/malloc-brk-fail.c b/src/regression/malloc-brk-f= ail.c index d0ccd35..a1c2f32 100644 --- a/src/regression/malloc-brk-fail.c +++ b/src/regression/malloc-brk-fail.c @@ -9,6 +9,10 @@ #define T(f) ((f)=3D=3D0 || (t_error(#f " failed: %s\n", strerror(errno)), = 0)) +#ifndef PAGE_SIZE + #define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#endif + int main(void) { void *p; @@ -26,9 +30,9 @@ int main(void) // malloc should fail here errno =3D 0; - q =3D malloc(10000); + q =3D malloc(PAGE_SIZE); if (q) - t_error("malloc(10000) succeeded after memory is filled\n")= ; + t_error("malloc(PAGE_SIZE) succeeded after memory is filled= \n"); else if (errno !=3D ENOMEM) t_error("malloc did not fail with ENOMEM, got %s\n", strerr= or(errno)); @@ -36,9 +40,9 @@ int main(void) T(munmap((char*)p+65536, 65536)); // malloc should succeed now - q =3D malloc(10000); + q =3D malloc(PAGE_SIZE); if (!q) - t_error("malloc(10000) failed (eventhough 64k is available = to mmap): %s\n", strerror(errno)); + t_error("malloc(PAGE_SIZE) failed (eventhough 64k is availa= ble to mmap): %s\n", strerror(errno)); return t_status; } Thanks, Jaydeep --_000_BD7773622145634B952E5B54ACA8E349AA2466D7PUMAIL01puimgte_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Szabolcs,

 

Page size on the MIPS64 Linux (v4.4) system we are u= sing to test MUSL is 64kb. The t_vmfill leaves up to 64kb memory, thus mall= oc of size 10000 (less than page size) after t_vmfill in this case succeeds= .

 

Could you please consider this patch?

 

diff --git a/src/regression/malloc-brk-fail.c b/src/= regression/malloc-brk-fail.c

index d0ccd35..a1c2f32 100644

--- a/src/regression/malloc-brk-fail.c

+++ b/src/regression/malloc-brk-fail.c

@@ -9,6 +9,10 @@

 

#define T(f) ((f)=3D=3D0 || (t_error(#f " faile= d: %s\n", strerror(errno)), 0))

 

+#ifndef PAGE_SIZE

+       #define PA= GE_SIZE sysconf(_SC_PAGE_SIZE)

+#endif

+

int main(void)

{

        void *p;<= o:p>

@@ -26,9 +30,9 @@ int main(void)

 

        // malloc= should fail here

        errno =3D= 0;

-       q =3D malloc(1= 0000);

+       q =3D mall= oc(PAGE_SIZE);

        if (q)

-        &nb= sp;      t_error("malloc(10000) succeeded aft= er memory is filled\n");

+        = ;       t_error("malloc(PAGE_SIZE) succe= eded after memory is filled\n");

        else if (= errno !=3D ENOMEM)

        &nbs= p;       t_error("malloc did not fail wi= th ENOMEM, got %s\n", strerror(errno));

 

@@ -36,9 +40,9 @@ int main(void)

        T(munmap(= (char*)p+65536, 65536));

 

        // malloc= should succeed now

-       q =3D malloc(1= 0000);

+       q =3D mall= oc(PAGE_SIZE);

        if (!q)

-        &nb= sp;      t_error("malloc(10000) failed (event= hough 64k is available to mmap): %s\n", strerror(errno));

+        = ;       t_error("malloc(PAGE_SIZE) faile= d (eventhough 64k is available to mmap): %s\n", strerror(errno));=

 

        return t_= status;

}

 

Thanks,

Jaydeep

 

--_000_BD7773622145634B952E5B54ACA8E349AA2466D7PUMAIL01puimgte_--