From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! malloc: implement malloc_usable_size()
Date: Tue, 6 Aug 2024 14:56:58 +0200 [thread overview]
Message-ID: <20240806125658.332359-1-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240806105429.2278660-1-s.hauer@pengutronix.de>
- Prevent sandbox from using libc function inadvertently
- Implement wrapper for libc malloc
- Implement for dummy_malloc
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Makefile | 1 +
arch/sandbox/os/libc_malloc.c | 5 +++++
common/dummy_malloc.c | 5 +++++
3 files changed, 11 insertions(+)
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index d5327d44e097..5c51f2de38b3 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -23,6 +23,7 @@ lds-y := $(BOARD)/barebox.lds
TEXT_BASE = $(CONFIG_TEXT_BASE)
KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dmalloc_stats=barebox_malloc_stats -Dmemalign=barebox_memalign \
+ -Dmalloc_usable_size=barebox_malloc_usable_size \
-Dfree=barebox_free -Drealloc=barebox_realloc \
-Dread=barebox_read -Dwrite=barebox_write \
-Dopen=barebox_open -Dclose=barebox_close \
diff --git a/arch/sandbox/os/libc_malloc.c b/arch/sandbox/os/libc_malloc.c
index 975c41b0ec49..e34156cd49e7 100644
--- a/arch/sandbox/os/libc_malloc.c
+++ b/arch/sandbox/os/libc_malloc.c
@@ -32,6 +32,11 @@ void *barebox_malloc(size_t size)
return mem;
}
+size_t barebox_malloc_usable_size(void *mem)
+{
+ return malloc_usable_size(mem);
+}
+
void barebox_free(void *ptr)
{
free(ptr);
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
index 7a96afec76e0..140ba314272a 100644
--- a/common/dummy_malloc.c
+++ b/common/dummy_malloc.c
@@ -30,6 +30,11 @@ void free(void *ptr)
{
}
+size_t malloc_usable_size(void *mem)
+{
+ BUG();
+}
+
void *realloc(void *ptr, size_t size)
{
BUG();
--
2.39.2
next prev parent reply other threads:[~2024-08-06 12:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 10:54 [PATCH 1/2] " Sascha Hauer
2024-08-06 10:54 ` [PATCH 2/2] malloc: implement free_sensitive() Sascha Hauer
2024-08-06 12:56 ` Ahmad Fatoum [this message]
2024-08-07 6:58 ` (subset) [PATCH] fixup! malloc: implement malloc_usable_size() Sascha Hauer
2024-08-07 6:58 ` [PATCH 1/2] " 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=20240806125658.332359-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