public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/siddhesh/malloc-hooks] mcheck Fix malloc_usable_size [BZ #22057]
@ 2021-07-19 17:48 Siddhesh Poyarekar
  0 siblings, 0 replies; 3+ messages in thread
From: Siddhesh Poyarekar @ 2021-07-19 17:48 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bb441626aec1afedd1581d7dc4518a963593712f

commit bb441626aec1afedd1581d7dc4518a963593712f
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Tue Jul 13 07:08:42 2021 +0530

    mcheck Fix malloc_usable_size [BZ #22057]
    
    Interpose malloc_usable_size to return the correct mcheck value for
    malloc_usable_size.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    Tested-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 malloc/Makefile       | 4 +---
 malloc/malloc-debug.c | 2 ++
 malloc/mcheck-impl.c  | 6 ++++++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/malloc/Makefile b/malloc/Makefile
index a2b4383b68..48c6056fb3 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -83,7 +83,7 @@ ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes)
 # the tests expect specific internal behavior that is changed due to linking to
 # libmcheck.a.
 tests-exclude-mcheck = tst-mallocstate \
-	tst-safe-linking tst-malloc-usable \
+	tst-safe-linking \
 	tst-malloc-backtrace \
 	tst-malloc-fork-deadlock \
 	tst-malloc-stats-cancellation \
@@ -92,8 +92,6 @@ tests-exclude-mcheck = tst-mallocstate \
 	tst-malloc-thread-fail \
 	tst-malloc-usable-tunables \
 	tst-malloc_info \
-	tst-pvalloc-fortify \
-	tst-reallocarray \
 	tst-compathooks-off tst-compathooks-on
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index 34523b0cc3..9922ef5f25 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -399,6 +399,8 @@ strong_alias (__debug_calloc, calloc)
 size_t
 malloc_usable_size (void *mem)
 {
+  if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
+    return mcheck_usable_size (mem);
   if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
     return malloc_check_get_size (mem);
 
diff --git a/malloc/mcheck-impl.c b/malloc/mcheck-impl.c
index 8857e6b179..6597a290a6 100644
--- a/malloc/mcheck-impl.c
+++ b/malloc/mcheck-impl.c
@@ -404,3 +404,9 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic)
   pedantic = in_pedantic;
   return 0;
 }
+
+static int
+mcheck_usable_size (struct hdr *h)
+{
+  return (h - 1)->size;
+}


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

* [glibc/siddhesh/malloc-hooks] mcheck Fix malloc_usable_size [BZ #22057]
@ 2021-07-19 13:30 Siddhesh Poyarekar
  0 siblings, 0 replies; 3+ messages in thread
From: Siddhesh Poyarekar @ 2021-07-19 13:30 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6a425e8b2a668daf33f9b47337737bd0b2915c4a

commit 6a425e8b2a668daf33f9b47337737bd0b2915c4a
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Tue Jul 13 07:08:42 2021 +0530

    mcheck Fix malloc_usable_size [BZ #22057]
    
    Interpose malloc_usable_size to return the correct mcheck value for
    malloc_usable_size.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    Tested-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 malloc/Makefile       | 4 +---
 malloc/malloc-debug.c | 8 ++++++--
 malloc/mcheck-impl.c  | 6 ++++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/malloc/Makefile b/malloc/Makefile
index 4099d63a2a..6dc3fce3da 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -83,7 +83,7 @@ ifeq ($(have-GLIBC_2.23)$(build-shared),yesyes)
 # the tests expect specific internal behavior that is changed due to linking to
 # libmcheck.a.
 tests-exclude-mcheck = tst-mallocstate \
-	tst-safe-linking tst-malloc-usable \
+	tst-safe-linking \
 	tst-malloc-backtrace \
 	tst-malloc-fork-deadlock \
 	tst-malloc-stats-cancellation \
@@ -92,8 +92,6 @@ tests-exclude-mcheck = tst-mallocstate \
 	tst-malloc-thread-fail \
 	tst-malloc-usable-tunables \
 	tst-malloc_info \
-	tst-pvalloc-fortify \
-	tst-reallocarray \
 	tst-compathooks-off tst-compathooks-on
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index ef44546a4e..7968787ad6 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -357,8 +357,12 @@ strong_alias (__debug_calloc, calloc)
 size_t
 malloc_usable_size (void *mem)
 {
-  return (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
-	  ? malloc_check_get_size (mem) : musable (mem));
+  if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
+    return mcheck_usable_size (mem);
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return malloc_check_get_size (mem);
+
+  return musable (mem);
 }
 
 #define LIBC_SYMBOL(sym) libc_ ## sym
diff --git a/malloc/mcheck-impl.c b/malloc/mcheck-impl.c
index 8857e6b179..6597a290a6 100644
--- a/malloc/mcheck-impl.c
+++ b/malloc/mcheck-impl.c
@@ -404,3 +404,9 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic)
   pedantic = in_pedantic;
   return 0;
 }
+
+static int
+mcheck_usable_size (struct hdr *h)
+{
+  return (h - 1)->size;
+}


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

* [glibc/siddhesh/malloc-hooks] mcheck Fix malloc_usable_size [BZ #22057]
@ 2021-07-13  3:40 Siddhesh Poyarekar
  0 siblings, 0 replies; 3+ messages in thread
From: Siddhesh Poyarekar @ 2021-07-13  3:40 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cf57ab3f4cec3923afbb600e33d01b6c0de1b1ea

commit cf57ab3f4cec3923afbb600e33d01b6c0de1b1ea
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Tue Jul 13 07:08:42 2021 +0530

    mcheck Fix malloc_usable_size [BZ #22057]
    
    Interpose malloc_usable_size to return the correct mcheck value for
    malloc_usable_size.

Diff:
---
 malloc/Makefile       | 4 +---
 malloc/malloc-debug.c | 8 ++++++--
 malloc/mcheck-impl.c  | 6 ++++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/malloc/Makefile b/malloc/Makefile
index c9504d0916..04c6b09949 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -83,7 +83,7 @@ ifeq ($(have-GLIBC_2.24)$(build-shared),yesyes)
 # the tests expect specific internal behavior that is changed due to linking to
 # libmcheck.a.
 tests-exclude-mcheck = tst-mallocstate \
-	tst-safe-linking tst-malloc-usable \
+	tst-safe-linking \
 	tst-malloc-backtrace \
 	tst-malloc-fork-deadlock \
 	tst-malloc-stats-cancellation \
@@ -92,8 +92,6 @@ tests-exclude-mcheck = tst-mallocstate \
 	tst-malloc-thread-fail \
 	tst-malloc-usable-tunables \
 	tst-malloc_info \
-	tst-pvalloc-fortify \
-	tst-reallocarray \
 	tst-compathooks-off tst-compathooks-on
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c
index ef44546a4e..7968787ad6 100644
--- a/malloc/malloc-debug.c
+++ b/malloc/malloc-debug.c
@@ -357,8 +357,12 @@ strong_alias (__debug_calloc, calloc)
 size_t
 malloc_usable_size (void *mem)
 {
-  return (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)
-	  ? malloc_check_get_size (mem) : musable (mem));
+  if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK))
+    return mcheck_usable_size (mem);
+  if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK))
+    return malloc_check_get_size (mem);
+
+  return musable (mem);
 }
 
 #define LIBC_SYMBOL(sym) libc_ ## sym
diff --git a/malloc/mcheck-impl.c b/malloc/mcheck-impl.c
index 8857e6b179..6597a290a6 100644
--- a/malloc/mcheck-impl.c
+++ b/malloc/mcheck-impl.c
@@ -404,3 +404,9 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic)
   pedantic = in_pedantic;
   return 0;
 }
+
+static int
+mcheck_usable_size (struct hdr *h)
+{
+  return (h - 1)->size;
+}


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

end of thread, other threads:[~2021-07-19 17:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 17:48 [glibc/siddhesh/malloc-hooks] mcheck Fix malloc_usable_size [BZ #22057] Siddhesh Poyarekar
  -- strict thread matches above, loose matches on Subject: below --
2021-07-19 13:30 Siddhesh Poyarekar
2021-07-13  3:40 Siddhesh Poyarekar

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).