]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068]
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 12 Jul 2021 21:36:39 +0000 (14:36 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 13 Jul 2021 01:13:32 +0000 (18:13 -0700)
1. Align struct hdr to MALLOC_ALIGNMENT bytes so that malloc hooks in
libmcheck align memory to MALLOC_ALIGNMENT bytes.
2. Remove tst-mallocalign1 from tests-exclude-mcheck for i386 and x32.
3. Add tst-pvalloc-fortify and tst-reallocarray to tests-exclude-mcheck
since they use malloc_usable_size (see BZ #22057).

This fixed BZ #28068.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
malloc/Makefile
malloc/mcheck.c
sysdeps/i386/Makefile
sysdeps/x86_64/x32/Makefile

index b685ed6d611015f01a85a9c6ea38d8ba6dfc3d9b..47369b6084f576c54ed696337ef44b5cd6d7b895 100644 (file)
@@ -95,7 +95,9 @@ tests-exclude-mcheck = tst-mallocstate \
        tst-malloc_info \
        tst-memalign \
        tst-posix_memalign \
-       tst-realloc
+       tst-realloc \
+       tst-pvalloc-fortify \
+       tst-reallocarray
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
 
index 2a1fc645d44b24727c85b25b7ffb3bcadbdf255c..d2efcfb7427c240649b71d7bef10eaece355d6a2 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef _MALLOC_INTERNAL
 # define _MALLOC_INTERNAL
 # include <malloc.h>
+# include <malloc-size.h>
 # include <mcheck.h>
 # include <stdint.h>
 # include <stdio.h>
@@ -53,7 +54,7 @@ struct hdr
   struct hdr *next;
   void *block;                  /* Real block allocated, for memalign.  */
   unsigned long int magic2;     /* Extra, keeps us doubleword aligned.  */
-};
+} __attribute__ ((aligned (MALLOC_ALIGNMENT)));
 
 /* This is the beginning of the list of all memory blocks allocated.
    It is only constructed if the pedantic testing is requested.  */
index 8fb65c0f178eadbf500a0e697c89408455d84493..a2e8c0b12822be0bad293570a72b3bdddf23972c 100644 (file)
@@ -5,10 +5,6 @@ asm-CPPFLAGS += -DGAS_SYNTAX
 # The i386 `long double' is a distinct type we support.
 long-double-fcts = yes
 
-ifeq ($(subdir),malloc)
-tests-exclude-mcheck += tst-mallocalign1
-endif
-
 ifeq ($(subdir),math)
 # These functions change the rounding mode internally and need to
 # update both the SSE2 rounding mode and the 387 rounding mode.  See
index 62919c79f173e6efd5df6afac23332fcfafc20c7..8748956563babf8f0ad816d361a26f79486d9a7b 100644 (file)
@@ -1,7 +1,3 @@
-ifeq ($(subdir),malloc)
-tests-exclude-mcheck += tst-mallocalign1
-endif
-
 ifeq ($(subdir),math)
 # Since x32 returns 32-bit long int and 64-bit long long int in the
 # same 64-bit register, we make the 32b-bit lround an alias of the