You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by tm...@apache.org on 2025/08/01 11:54:45 UTC

(nuttx) branch master updated: arch/xtensa: Fix a race condition in xtensa_sig_deliver for SMP

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 50d94863f2 arch/xtensa: Fix a race condition in xtensa_sig_deliver for SMP
50d94863f2 is described below

commit 50d94863f27bff62a45777942d5d18e9d256784f
Author: Jukka Laitinen <ju...@tii.ae>
AuthorDate: Thu Jul 31 18:15:29 2025 +0300

    arch/xtensa: Fix a race condition in xtensa_sig_deliver for SMP
    
    After the signals have been delivered, the local irqs need to be
    disabled until the context switch. But just calling
    leave_critical_section(regs[REG_PS]) will enable them if they were
    enabled in the context.
    
    Any interrupt on this cpu before xtensa_context_restore() would set
    the rtcb->xcp.regs to NULL, causing a crash in context restore.
    
    Fix this by calling leave_critical_section(up_irq_save()) instead.
    
    Signed-off-by: Jukka Laitinen <ju...@tii.ae>
---
 arch/xtensa/src/common/xtensa_sigdeliver.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_sigdeliver.c b/arch/xtensa/src/common/xtensa_sigdeliver.c
index c0914df689..77c42c646d 100644
--- a/arch/xtensa/src/common/xtensa_sigdeliver.c
+++ b/arch/xtensa/src/common/xtensa_sigdeliver.c
@@ -154,12 +154,11 @@ retry:
    */
 
   board_autoled_off(LED_SIGNAL);
+
 #ifdef CONFIG_SMP
   /* We need to keep the IRQ lock until task switching */
 
-  rtcb->irqcount++;
-  leave_critical_section((regs[REG_PS]));
-  rtcb->irqcount--;
+  leave_critical_section(up_irq_save());
 #endif
 
   rtcb->xcp.regs = rtcb->xcp.saved_regs;