From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 16654385E00B; Thu, 26 Mar 2020 17:36:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16654385E00B From: "maxkamper at outlook dot com" To: glibc-bugs@sourceware.org Subject: [Bug malloc/25733] New: mallopt(M_MXFAST) can set global_max_fast to 0 Date: Thu, 26 Mar 2020 17:36:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: malloc X-Bugzilla-Version: 2.31 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: maxkamper at outlook dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2020 17:36:08 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25733 Bug ID: 25733 Summary: mallopt(M_MXFAST) can set global_max_fast to 0 Product: glibc Version: 2.31 Status: UNCONFIRMED Severity: normal Priority: P2 Component: malloc Assignee: unassigned at sourceware dot org Reporter: maxkamper at outlook dot com Target Milestone: --- mallopt(M_MXFAST) can set global_max_fast to 0. This doesn't seem intentional because mallopt(M_MXFAST, 0) sets global_max_= fast to SMALLBIN_WIDTH. Passing a value between 1-7 to mallopt(M_MXFAST, value) sets global_max_fas= t to 0. Both malloc.c and the mallopt man page document the legitimate range of val= ues that may be passed to mallopt(M_MXFAST, value) as "0 to 80*sizeof(size_t)/4= ". In GLIBC versions >=3D 2.27 this has the same effect as setting global_max_= fast to SMALLBIN_WIDTH, but it is perhaps of some concern in GLIBC versions <=3D= 2.26 because of how global_max_fast is treated as an indicator of main arena initialization by malloc_consolidate(). If the following example is compiled & run under GLIBC version 2.26, a chun= k is allocated overlapping the main arena: #include #include #include int main(void) { // Populate last_remainder, which is treated as the top chunk size field // after main arena re-initialization. void* remainder_me =3D malloc(0x418); malloc(0x18); // Avoid top chunk consolidation. free(remainder_me); malloc(0x18); // Remainder remainder_me chunk. // Set global_max_fast to 0. mallopt(M_MXFAST, 7); // Trigger malloc_consolidate(), which could happen during large // allocations/frees, but for the sake of simplicity here just call // mallopt() again. mallopt(M_MXFAST, 0x78); // malloc_consolidate() uses global_max_fast to determine if malloc has // been initialized. If global_max_fast is 0, malloc_consolidate() will // re-initialize the main arena, setting its top chunk pointer to an address // within the main arena. Now last_remainder acts as the top chunk size // field. printf("%p\n", malloc(0x418); return 0; } --=20 You are receiving this mail because: You are on the CC list for the bug.=