diff options
author | Ammar Faizi <ammar.faizi@students.amikom.ac.id> | 2021-10-11 13:49:27 +0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-11 06:43:33 -0600 |
commit | 106f2d9f25b6687d1b980353af0c03e9faae5517 (patch) | |
tree | 0e4710f491b9ccca0d63168432992db0365a48ec | |
parent | 471af33417242e51fff9517dc02b12269ad54613 (diff) | |
download | liburing-106f2d9f25b6687d1b980353af0c03e9faae5517.tar.gz liburing-106f2d9f25b6687d1b980353af0c03e9faae5517.tar.bz2 |
src/nolibc: Fix `malloc()` alignment
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 <louvianlyndal@gmail.com>
Signed-off-by: Ammar Faizi <ammar.faizi@students.amikom.ac.id>
Link: https://lore.kernel.org/r/20211011064927.444704-1-ammar.faizi@students.amikom.ac.id
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | src/nolibc.c | 2 |
1 files changed, 1 insertions, 1 deletions
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) |