diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-04-11 17:48:23 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-04-19 11:15:27 +0200 |
commit | ee338a256ee8dff064fd3920a2efe642ef1d3cfa (patch) | |
tree | 3b095ced1ff29ea9a872d0e8408a1fe523bb5561 /util.h | |
parent | 5d5208b67d4e4dfb4098495620591c73ac3de50d (diff) | |
download | passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar.gz passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar.bz2 passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar.lz passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar.xz passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.tar.zst passt-ee338a256ee8dff064fd3920a2efe642ef1d3cfa.zip |
pasta, util: Align stack area for clones to maximum natural alignment
Given that we use this stack pointer as a location to store arbitrary
data types from the cloned process, we need to guarantee that its
alignment matches any of those possible data types.
runsisi reports that pasta gets a SIGBUS in pasta_open_ns() on
aarch64, where the alignment requirement for stack pointers is a
16 bytes (same as the size of a long double), and similar requirements
actually apply to most architectures we run on.
Reported-by: runsisi <runsisi@hust.edu.cn>
Link: https://bugs.passt.top/show_bug.cgi?id=85
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -9,6 +9,7 @@ #include <stdlib.h> #include <stdarg.h> #include <stdbool.h> +#include <stddef.h> #include <string.h> #include <signal.h> @@ -116,7 +117,8 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, void *arg); #define NS_CALL(fn, arg) \ do { \ - char ns_fn_stack[NS_FN_STACK_SIZE]; \ + char ns_fn_stack[NS_FN_STACK_SIZE] \ + __attribute__ ((aligned(__alignof__(max_align_t)))); \ \ do_clone((fn), ns_fn_stack, sizeof(ns_fn_stack), \ CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD,\ |