From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 424633857364; Fri, 5 Aug 2022 19:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 424633857364 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: malloc: use intptr_t to preserve capabilities X-Act-Checkin: glibc X-Git-Author: Carlos Eduardo Seo X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: d0db1e8a122459e0f37b97eeca2bf399cadb043e X-Git-Newrev: 0205012984bc65f70d6324d9bc2338b7b23f4533 Message-Id: <20220805193530.424633857364@sourceware.org> Date: Fri, 5 Aug 2022 19:35:30 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2022 19:35:30 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0205012984bc65f70d6324d9bc2338b7b23f4533 commit 0205012984bc65f70d6324d9bc2338b7b23f4533 Author: Carlos Eduardo Seo Date: Wed Jan 26 16:00:13 2022 -0300 cheri: malloc: use intptr_t to preserve capabilities Avoid integer casts and arithmetics that invalidates capabilities. Diff: --- malloc/arena.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index 0a684a720d..b1f5b4117f 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -444,7 +444,7 @@ dump_heap (heap_info *heap) fprintf (stderr, "Heap %p, size %10lx:\n", heap, (long) heap->size); ptr = (heap->ar_ptr != (mstate) (heap + 1)) ? (char *) (heap + 1) : (char *) (heap + 1) + sizeof (struct malloc_state); - p = (mchunkptr) (((unsigned long) ptr + MALLOC_ALIGN_MASK) & + p = (mchunkptr) (((uintptr_t) ptr + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK); for (;; ) { @@ -518,7 +518,7 @@ alloc_new_heap (size_t size, size_t top_pad, size_t pagesize, p1 = (char *) MMAP (0, max_size << 1, PROT_NONE, mmap_flags); if (p1 != MAP_FAILED) { - p2 = (char *) (((unsigned long) p1 + (max_size - 1)) + p2 = (char *) (((uintptr_t) p1 + (max_size - 1)) & ~(max_size - 1)); ul = p2 - p1; if (ul) @@ -760,7 +760,7 @@ _int_new_arena (size_t size) /* Set up the top chunk, with proper alignment. */ ptr = (char *) (a + 1); - misalign = (unsigned long) chunk2mem (ptr) & MALLOC_ALIGN_MASK; + misalign = (uintptr_t) chunk2mem (ptr) & MALLOC_ALIGN_MASK; if (misalign > 0) ptr += MALLOC_ALIGNMENT - misalign; top (a) = (mchunkptr) ptr;