public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] src/nolibc: Fix `malloc()` alignment
@ 2021-10-11  6:49 Ammar Faizi
  2021-10-11 12:13 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Ammar Faizi @ 2021-10-11  6:49 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring Mailing List
  Cc: Bedirhan KURT, Louvian Lyndal, Ammar Faizi

Add `__attribute__((__aligned__))` to the `user_p` to guarantee
pointer returned by the `malloc()` is properly aligned for user.

This attribute asks the compiler to align a type to the maximum
useful alignment for the target machine we are compiling for,
which is often, but by no means always, 8 or 16 bytes [1].

Link: https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes [1]
Fixes: https://github.com/axboe/liburing/issues/454
Reported-by: Louvian Lyndal <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 src/nolibc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nolibc.c b/src/nolibc.c
index 5582ca0..251780b 100644
--- a/src/nolibc.c
+++ b/src/nolibc.c
@@ -20,7 +20,7 @@ void *memset(void *s, int c, size_t n)
 
 struct uring_heap {
 	size_t		len;
-	char		user_p[];
+	char		user_p[] __attribute__((__aligned__));
 };
 
 void *malloc(size_t len)
-- 
2.30.2


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

end of thread, other threads:[~2021-10-11 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-11  6:49 [PATCH liburing] src/nolibc: Fix `malloc()` alignment Ammar Faizi
2021-10-11 12:13 ` Jens Axboe
2021-10-11 12:56   ` Ammar Faizi
2021-10-11 13:00     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox