Skip to contentSkip to conversation

linux-user: Move TARGET_SA_RESTORER out of generic/signal.h

PATCH Applied Andreas Schwab 3 participants 4 messages Feb 10, 2025 – Feb 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Move TARGET_SA_RESTORER out of generic/signal.h

SA_RESTORER and the associated sa_restorer field of struct sigaction are an obsolete feature, not expected to be used by future architectures. They are also absent on RISC-V, LoongArch, Hexagon and OpenRISC, but defined due to their use of generic/signal.h. This leads to corrupted data and out-of-bounds accesses.

Move the definition of TARGET_SA_RESTORER out of generic/signal.h into the target_signal.h files that need it. Note that m68k has the sa_restorer field, but does not use it and does not define SA_RESTORER.

---
 linux-user/aarch64/target_signal.h    | 2 ++
 linux-user/arm/target_signal.h        | 2 ++
 linux-user/generic/signal.h           | 1 -
 linux-user/i386/target_signal.h       | 2 ++
 linux-user/m68k/target_signal.h       | 1 +
 linux-user/microblaze/target_signal.h | 2 ++
 linux-user/ppc/target_signal.h        | 2 ++
 linux-user/s390x/target_signal.h      | 2 ++
 linux-user/sh4/target_signal.h        | 2 ++
 linux-user/x86_64/target_signal.h     | 2 ++
 linux-user/xtensa/target_signal.h     | 2 ++
 11 files changed, 19 insertions(+), 1 deletion(-)
linux-user/aarch64/target_signal.h +2 -0
index 40e399d990..6f66a50bfd 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_SEGV_MTEAERR  8  /* Asynchronous ARM MTE error */
 #define TARGET_SEGV_MTESERR  9  /* Synchronous ARM MTE exception */
 
linux-user/arm/target_signal.h +2 -0
index 0e6351d9f7..ff1810b1fe 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
linux-user/generic/signal.h +0 -1
index 6fd05b77bb..b34740258e 100644
@@ -15,7 +15,6 @@
 #define TARGET_SA_RESTART       0x10000000
 #define TARGET_SA_NODEFER       0x40000000
 #define TARGET_SA_RESETHAND     0x80000000
-#define TARGET_SA_RESTORER      0x04000000
 
 #define TARGET_SIGHUP            1
 #define TARGET_SIGINT            2
linux-user/i386/target_signal.h +2 -0
index 9315cba241..eee792ef63 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
linux-user/m68k/target_signal.h +1 -0
index 6e0f4b74e3..b05b9303b0 100644
@@ -3,6 +3,7 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_ARCH_HAS_SA_RESTORER 1
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
linux-user/microblaze/target_signal.h +2 -0
index 7dc5c45f00..ffe4442213 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
 #endif /* MICROBLAZE_TARGET_SIGNAL_H */
linux-user/ppc/target_signal.h +2 -0
index 5be24e152b..53fae473f3 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #if !defined(TARGET_PPC64)
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #endif
linux-user/s390x/target_signal.h +2 -0
index 41e0e34a55..738e0673f4 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
linux-user/sh4/target_signal.h +2 -0
index eee6a1a7cd..0bde417fd1 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SETUP_FRAME
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
linux-user/x86_64/target_signal.h +2 -0
index 9d9717406f..0af100c661 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 /* For x86_64, use of SA_RESTORER is mandatory. */
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0
 
linux-user/xtensa/target_signal.h +2 -0
index e4b1bea5cb..8a198bf8ac 100644
@@ -3,6 +3,8 @@
 
 #include "../generic/signal.h"
 
+#define TARGET_SA_RESTORER      0x04000000
+
 #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1
 
 #endif
Signature · 7 lines
2.48.1


-- 
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Andreas Schwab

SA_RESTORER and the associated sa_restorer field of struct sigaction are an obsolete feature, not expected to be used by future architectures. They are also absent on RISC-V, LoongArch, Hexagon and OpenRISC, but defined due to their use of generic/signal.h. This leads to corrupted data and out-of-bounds accesses.

Move the definition of TARGET_SA_RESTORER out of generic/signal.h into the target_signal.h files that need it. Note that m68k has the sa_restorer field, but does not use it and does not define SA_RESTORER.

Quoted 13 lines
---
  linux-user/aarch64/target_signal.h    | 2 ++
  linux-user/arm/target_signal.h        | 2 ++
  linux-user/generic/signal.h           | 1 -
  linux-user/i386/target_signal.h       | 2 ++
  linux-user/m68k/target_signal.h       | 1 +
  linux-user/microblaze/target_signal.h | 2 ++
  linux-user/ppc/target_signal.h        | 2 ++
  linux-user/s390x/target_signal.h      | 2 ++
  linux-user/sh4/target_signal.h        | 2 ++
  linux-user/x86_64/target_signal.h     | 2 ++
  linux-user/xtensa/target_signal.h     | 2 ++
  11 files changed, 19 insertions(+), 1 deletion(-)

r~

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andreas Schwab

Hi Andreas,

Quoted 6 lines · Andreas Schwab

SA_RESTORER and the associated sa_restorer field of struct sigaction are an obsolete feature, not expected to be used by future architectures. They are also absent on RISC-V, LoongArch, Hexagon and OpenRISC, but defined due to their use of generic/signal.h. This leads to corrupted data and out-of-bounds accesses.

Quoted 6 lines

Move the definition of TARGET_SA_RESTORER out of generic/signal.h into the target_signal.h files that need it. Note that m68k has the sa_restorer field, but does not use it and does not define SA_RESTORER.

Thanks for fixing this properly.

Quoted 13 lines
---
 linux-user/aarch64/target_signal.h    | 2 ++
 linux-user/arm/target_signal.h        | 2 ++
 linux-user/generic/signal.h           | 1 -
 linux-user/i386/target_signal.h       | 2 ++
 linux-user/m68k/target_signal.h       | 1 +
 linux-user/microblaze/target_signal.h | 2 ++
 linux-user/ppc/target_signal.h        | 2 ++
 linux-user/s390x/target_signal.h      | 2 ++
 linux-user/sh4/target_signal.h        | 2 ++
 linux-user/x86_64/target_signal.h     | 2 ++
 linux-user/xtensa/target_signal.h     | 2 ++
 11 files changed, 19 insertions(+), 1 deletion(-)

...

#3 lore raw
In reply to Andreas Schwab
Quoted 12 lines · Andreas Schwab

SA_RESTORER and the associated sa_restorer field of struct sigaction are an obsolete feature, not expected to be used by future architectures. They are also absent on RISC-V, LoongArch, Hexagon and OpenRISC, but defined due to their use of generic/signal.h. This leads to corrupted data and out-of-bounds accesses.

Move the definition of TARGET_SA_RESTORER out of generic/signal.h into the target_signal.h files that need it. Note that m68k has the sa_restorer field, but does not use it and does not define SA_RESTORER.

Quoted 13 lines
---
  linux-user/aarch64/target_signal.h    | 2 ++
  linux-user/arm/target_signal.h        | 2 ++
  linux-user/generic/signal.h           | 1 -
  linux-user/i386/target_signal.h       | 2 ++
  linux-user/m68k/target_signal.h       | 1 +
  linux-user/microblaze/target_signal.h | 2 ++
  linux-user/ppc/target_signal.h        | 2 ++
  linux-user/s390x/target_signal.h      | 2 ++
  linux-user/sh4/target_signal.h        | 2 ++
  linux-user/x86_64/target_signal.h     | 2 ++
  linux-user/xtensa/target_signal.h     | 2 ++
  11 files changed, 19 insertions(+), 1 deletion(-)

Queued, thanks.

r~