unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068]
@ 2021-07-12 21:41 H.J. Lu via Libc-alpha
  2021-07-13  1:05 ` Siddhesh Poyarekar via Libc-alpha
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-07-12 21:41 UTC (permalink / raw)
  To: libc-alpha; +Cc: Siddhesh Poyarekar

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.
---
 malloc/Makefile             | 4 +++-
 malloc/mcheck.c             | 3 ++-
 sysdeps/i386/Makefile       | 4 ----
 sysdeps/x86_64/x32/Makefile | 4 ----
 4 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/malloc/Makefile b/malloc/Makefile
index b685ed6d61..47369b6084 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -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))
 
diff --git a/malloc/mcheck.c b/malloc/mcheck.c
index 2a1fc645d4..d2efcfb742 100644
--- a/malloc/mcheck.c
+++ b/malloc/mcheck.c
@@ -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.  */
diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile
index 8fb65c0f17..a2e8c0b128 100644
--- a/sysdeps/i386/Makefile
+++ b/sysdeps/i386/Makefile
@@ -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
diff --git a/sysdeps/x86_64/x32/Makefile b/sysdeps/x86_64/x32/Makefile
index 62919c79f1..8748956563 100644
--- a/sysdeps/x86_64/x32/Makefile
+++ b/sysdeps/x86_64/x32/Makefile
@@ -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
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068]
  2021-07-12 21:41 [PATCH] mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068] H.J. Lu via Libc-alpha
@ 2021-07-13  1:05 ` Siddhesh Poyarekar via Libc-alpha
  0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar via Libc-alpha @ 2021-07-13  1:05 UTC (permalink / raw)
  To: H.J. Lu, libc-alpha

On 7/13/21 3:11 AM, H.J. Lu via Libc-alpha wrote:
> 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.

This is fine.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-13  1:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 21:41 [PATCH] mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068] H.J. Lu via Libc-alpha
2021-07-13  1:05 ` Siddhesh Poyarekar via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).