mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] sandbox: route malloc_usable_size() through the PBL glue again
Date: Tue, 22 Sep 2026 12:53:02 +0200	[thread overview]
Message-ID: <20260922105308.386749-1-a.fatoum@pengutronix.de> (raw)

Everything in SANDBOX_PBL2PROPER_GLUE_SYMS is #defined to a barebox_
prefixed name in barebox proper, so calls end up at our wrappers
instead of directly in the host libc directly.

malloc_usable_size lost its prefix when sandbox was migrated to PBL,
which becomes quickly apparent if it's called with a ZERO_SIZE_PTR:
The barebox wrapper rejects it, while the host allocator will choke on
it under ASAN:

  AddressSanitizer: attempting to call malloc_usable_size() for pointer
  which is not owned: 0x000000000010

Fixes: 2aba0017c95a ("sandbox: switch to using PBL")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index c8f5ae8c8986..9490a1ae4b35 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -33,7 +33,8 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
 SANDBOX_PBL2PROPER_GLUE_SYMS := \
 	putchar errno setjmp longjmp \
-	malloc_stats memalign malloc free realloc calloc memleak_check brk sbrk
+	malloc_stats memalign malloc free realloc calloc malloc_usable_size \
+	memleak_check brk sbrk
 
 KBUILD_CFLAGS += $(foreach s,$(SANDBOX_PBL2PROPER_GLUE_SYMS),-D$(s)=barebox_$(s))
 
-- 
2.47.3




             reply	other threads:[~2026-09-22 10:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 10:53 Ahmad Fatoum [this message]
2026-09-22 10:53 ` [PATCH 2/2] test: self: free a zero-sized buffer with free_sensitive() Ahmad Fatoum
2026-09-23  6:09 ` [PATCH 1/2] sandbox: route malloc_usable_size() through the PBL glue again Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260922105308.386749-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox