|
|
Message-ID: <35e0f138535048ae636e4a35f2b218b6.mforney@mforney.org>
Date: Wed, 29 Apr 2026 23:26:25 -0700
From: Michael Forney <mforney@...rney.org>
To: musl@...ts.openwall.com
Cc: Markus Wichmann <nullplan@....net>
Subject: [PATCH] riscv32, riscv64: make alignment padding in ucontext_t
explicit
As discussed in [0], add explicit padding between struct fields
with alignment attributes. This ensures that the struct layout is
the same with and without the attribute.
Noticed by Markus Wichmann.
riscv32:
(gdb) ptype /o ucontext_t
type = struct __ucontext {
/* 0 | 4 */ unsigned long uc_flags;
/* 4 | 4 */ struct __ucontext *uc_link;
/* 8 | 12 */ stack_t uc_stack;
/* 20 | 128 */ sigset_t uc_sigmask;
/* XXX 12-byte hole */
/* 160 | 656 */ mcontext_t uc_mcontext;
/* total size (bytes): 816 */
}
riscv64:
(gdb) ptype /o ucontext_t
type = struct __ucontext {
/* 0 | 8 */ unsigned long uc_flags;
/* 8 | 8 */ struct __ucontext *uc_link;
/* 16 | 24 */ stack_t uc_stack;
/* 40 | 128 */ sigset_t uc_sigmask;
/* XXX 8-byte hole */
/* 176 | 784 */ mcontext_t uc_mcontext;
/* total size (bytes): 960 */
}
[0] https://www.openwall.com/lists/musl/2024/04/21/15
---
arch/riscv32/bits/signal.h | 1 +
arch/riscv64/bits/signal.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/riscv32/bits/signal.h b/arch/riscv32/bits/signal.h
index 50b66ec9..8d0ee610 100644
--- a/arch/riscv32/bits/signal.h
+++ b/arch/riscv32/bits/signal.h
@@ -68,6 +68,7 @@ typedef struct __ucontext
struct __ucontext *uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
+ char __pad[12];
mcontext_t uc_mcontext;
} ucontext_t;
diff --git a/arch/riscv64/bits/signal.h b/arch/riscv64/bits/signal.h
index 56f8fe17..d859be1e 100644
--- a/arch/riscv64/bits/signal.h
+++ b/arch/riscv64/bits/signal.h
@@ -68,6 +68,7 @@ typedef struct __ucontext
struct __ucontext *uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
+ char __pad[8];
mcontext_t uc_mcontext;
} ucontext_t;
--
2.49.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.