This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a9066e5de2306c5fff2424fed6f0e095776552c9
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 28 10:36:44 2026 +0100

    arch/arm64: Refuse reserved user system calls without full signals.
    
    Commit 50a4f8061da ("arch/arm64: refuse reserved syscalls from user
    space") reads tcb->xcp.sigreturn, but struct xcptcontext has that field
    only with CONFIG_ENABLE_ALL_SIGNALS.  A kernel build with
    CONFIG_ENABLE_PARTIAL_SIGNALS or CONFIG_DISABLE_ALL_SIGNALS does not
    compile.
    
    Without full signals the kernel dispatches no user signal handler, so
    no SYS_signal_handler_return from user mode is valid: refuse all
    reserved system calls from user mode in that case.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm64/src/common/arm64_syscall.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/src/common/arm64_syscall.c 
b/arch/arm64/src/common/arm64_syscall.c
index 312444b018b..75f5e88739f 100644
--- a/arch/arm64/src/common/arm64_syscall.c
+++ b/arch/arm64/src/common/arm64_syscall.c
@@ -27,6 +27,7 @@
 #include <nuttx/config.h>
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <string.h>
 #include <assert.h>
@@ -44,6 +45,22 @@
 #include "sched/sched.h"
 #include "signal/signal.h"
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* From user mode, the only reserved system call that is allowed is the
+ * return from a signal handler that the kernel dispatched.  Without full
+ * signal support the kernel dispatches no handler, so none is allowed.
+ */
+
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+#  define USER_SIGRETURN(tcb, cmd) \
+     ((cmd) == SYS_signal_handler_return && (tcb)->xcp.sigreturn != 0)
+#else
+#  define USER_SIGRETURN(tcb, cmd) false
+#endif
+
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -183,7 +200,7 @@ uint64_t *arm64_syscall(uint64_t *regs)
 
 #ifdef CONFIG_BUILD_KERNEL
   if ((regs[REG_SPSR] & SPSR_MODE_MASK) == SPSR_MODE_EL0T &&
-      (cmd != SYS_signal_handler_return || tcb->xcp.sigreturn == 0))
+      !USER_SIGRETURN(tcb, cmd))
     {
       regs[REG_X0] = -ENOSYS;
       return regs;

Reply via email to