Revert "include/nuttx/sched.h: Add storage for a previous signal mask. arch/: In all syscall implementations, block all signals before dispatching a system call; resotre signal mask when the system call returns."

Using the sigprocmask() for this purpose has too many side-effects.

This reverts commit 344f7bc9f6.
This commit is contained in:
Gregory Nutt
2019-11-28 11:57:54 -06:00
parent 7dcd57aa4a
commit cbdd590c82
10 changed files with 11 additions and 111 deletions
+1 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv6-m/up_svcall.c * arch/arm/src/armv6-m/up_svcall.c
* *
* Copyright (C) 2013-2014, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
# include <syscall.h> # include <syscall.h>
@@ -270,11 +269,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
*/ */
regs[REG_R0] = regs[REG_R2]; regs[REG_R0] = regs[REG_R2];
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -421,7 +415,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -445,11 +438,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
regs[REG_R0] -= CONFIG_SYS_RESERVED; regs[REG_R0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]);
#endif #endif
+1 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-a/arm_syscall.c * arch/arm/src/armv7-a/arm_syscall.c
* *
* Copyright (C) 2013-2014, 2016, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,6 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <nuttx/addrenv.h> #include <nuttx/addrenv.h>
#include "arm.h" #include "arm.h"
@@ -220,11 +219,6 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Save the new SYSCALL nesting level */ /* Save the new SYSCALL nesting level */
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
@@ -430,7 +424,6 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -457,11 +450,6 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
regs[REG_R0] -= CONFIG_SYS_RESERVED; regs[REG_R0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]);
#endif #endif
@@ -477,7 +465,6 @@ uint32_t *arm_syscall(uint32_t *regs)
regs[REG_SP] = (uint32_t)rtcb->xcp.kstack + ARCH_KERNEL_STACKSIZE; regs[REG_SP] = (uint32_t)rtcb->xcp.kstack + ARCH_KERNEL_STACKSIZE;
} }
#endif #endif
/* Save the new SYSCALL nesting level */ /* Save the new SYSCALL nesting level */
rtcb->xcp.nsyscalls = index + 1; rtcb->xcp.nsyscalls = index + 1;
+1 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-m/up_svcall.c * arch/arm/src/armv7-m/up_svcall.c
* *
* Copyright (C) 2009, 2011-2015, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2009, 2011-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <nuttx/userspace.h> #include <nuttx/userspace.h>
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
@@ -270,11 +269,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
*/ */
regs[REG_R0] = regs[REG_R2]; regs[REG_R0] = regs[REG_R2];
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -421,7 +415,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -445,11 +438,6 @@ int up_svcall(int irq, FAR void *context, FAR void *arg)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
regs[REG_R0] -= CONFIG_SYS_RESERVED; regs[REG_R0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]);
#endif #endif
+2 -14
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-r/arm_syscall.c * arch/arm/src/armv7-r/arm_syscall.c
* *
* Copyright (C) 2015, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,6 @@
#include <arch/irq.h> #include <arch/irq.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include "arm.h" #include "arm.h"
#include "svcall.h" #include "svcall.h"
@@ -218,11 +217,6 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Save the new SYSCALL nesting level */ /* Save the new SYSCALL nesting level */
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
@@ -357,7 +351,7 @@ uint32_t *arm_syscall(uint32_t *regs)
regs[REG_R3] = regs[REG_R4]; /* ucontext */ regs[REG_R3] = regs[REG_R4]; /* ucontext */
#ifdef CONFIG_ARCH_KERNEL_STACK #ifdef CONFIG_ARCH_KERNEL_STACK
/* If we are signaling a user process, then we must be operating /* If we are signalling a user process, then we must be operating
* on the kernel stack now. We need to switch back to the user * on the kernel stack now. We need to switch back to the user
* stack before dispatching the signal handler to the user code. * stack before dispatching the signal handler to the user code.
* The existence of an allocated kernel stack is sufficient * The existence of an allocated kernel stack is sufficient
@@ -428,7 +422,6 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_LIB_SYSCALL #ifdef CONFIG_LIB_SYSCALL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -455,11 +448,6 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
regs[REG_R0] -= CONFIG_SYS_RESERVED; regs[REG_R0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_R0]);
#endif #endif
+1 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/mips/src/mips32/up_swint0.c * arch/mips/src/mips32/up_swint0.c
* *
* Copyright (C) 2011-2012, 2015, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@
#include <debug.h> #include <debug.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <arch/irq.h> #include <arch/irq.h>
#include <arch/mips32/cp0.h> #include <arch/mips32/cp0.h>
@@ -226,11 +225,6 @@ int up_swint0(int irq, FAR void *context, FAR void *arg)
g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn; g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn;
#error "Missing logic -- need to restore the original mode" #error "Missing logic -- need to restore the original mode"
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -245,7 +239,6 @@ int up_swint0(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -269,11 +262,6 @@ int up_swint0(int irq, FAR void *context, FAR void *arg)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
g_current_regs[REG_R0] -= CONFIG_SYS_RESERVED; g_current_regs[REG_R0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]);
#endif #endif
+1 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/misoc/src/lm32/lm32_swint.c * arch/misoc/src/lm32/lm32_swint.c
* *
* Copyright (C) 2016. 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Ramtin Amin <keytwo@gmail.com> * Ramtin Amin <keytwo@gmail.com>
* *
@@ -47,7 +47,6 @@
#include <debug.h> #include <debug.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <arch/irq.h> #include <arch/irq.h>
#include "lm32.h" #include "lm32.h"
@@ -227,11 +226,6 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg)
g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn; g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn;
#error "Missing logic -- need to restore the original mode" #error "Missing logic -- need to restore the original mode"
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -246,7 +240,6 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -270,11 +263,6 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED; g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]);
#endif #endif
-12
View File
@@ -47,7 +47,6 @@
#include <debug.h> #include <debug.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <arch/irq.h> #include <arch/irq.h>
#include "minerva.h" #include "minerva.h"
@@ -214,11 +213,6 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg)
g_current_regs[REG_CSR_MEPC] = rtcb->xcp.syscall[index].sysreturn; g_current_regs[REG_CSR_MEPC] = rtcb->xcp.syscall[index].sysreturn;
#error "Missing logic -- need to restore the original mode" #error "Missing logic -- need to restore the original mode"
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -233,7 +227,6 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -258,11 +251,6 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg)
/* Offset R0 to account for the reserved values */ /* Offset R0 to account for the reserved values */
g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED; g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED;
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]);
#endif #endif
+1 -13
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/riscv/src/rv32im/up_swint.c * arch/riscv/src/rv32im/up_swint.c
* *
* Copyright (C) 2011-2012, 2015, 2019 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@
#include <debug.h> #include <debug.h>
#include <nuttx/sched.h> #include <nuttx/sched.h>
#include <nuttx/signal.h>
#include <arch/irq.h> #include <arch/irq.h>
@@ -224,11 +223,6 @@ int up_swint(int irq, FAR void *context, FAR void *arg)
g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn; g_current_regs[REG_EPC] = rtcb->xcp.syscall[index].sysreturn;
#error "Missing logic -- need to restore the original mode" #error "Missing logic -- need to restore the original mode"
rtcb->xcp.nsyscalls = index; rtcb->xcp.nsyscalls = index;
/* Restore the signal mask when the syscall returns */
(void)nxsig_procmask(SIG_SETMASK, &rtcb->sigoldmask, NULL);
sigemptyset(rtcb->sigoldmask);
} }
break; break;
#endif #endif
@@ -243,7 +237,6 @@ int up_swint(int irq, FAR void *context, FAR void *arg)
#ifdef CONFIG_BUILD_KERNEL #ifdef CONFIG_BUILD_KERNEL
FAR struct tcb_s *rtcb = sched_self(); FAR struct tcb_s *rtcb = sched_self();
int index = rtcb->xcp.nsyscalls; int index = rtcb->xcp.nsyscalls;
sigset_t set;
/* Verify that the SYS call number is within range */ /* Verify that the SYS call number is within range */
@@ -269,11 +262,6 @@ int up_swint(int irq, FAR void *context, FAR void *arg)
g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED; g_current_regs[REG_A0] -= CONFIG_SYS_RESERVED;
#else #else
svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]); svcerr("ERROR: Bad SYS call: %d\n", regs[REG_A0]);
/* Block all signals while the system call runs */
sigfillset(&set);
(void)nxsig_procmask(SIG_BLOCK, &set, &rtcb->sigoldmask);
#endif #endif
} }
break; break;
+1 -4
View File
@@ -675,14 +675,11 @@ struct tcb_s
/* POSIX Semaphore Control Fields *********************************************/ /* POSIX Semaphore Control Fields *********************************************/
FAR sem_t *waitsem; /* Semaphore ID waiting on */ sem_t *waitsem; /* Semaphore ID waiting on */
/* POSIX Signal Control Fields ************************************************/ /* POSIX Signal Control Fields ************************************************/
sigset_t sigprocmask; /* Signals that are blocked */ sigset_t sigprocmask; /* Signals that are blocked */
#ifdef CONFIG_LIB_SYSCALL
sigset_t sigoldmask; /* Signals previously blocked */
#endif
sigset_t sigwaitmask; /* Waiting for pending signals */ sigset_t sigwaitmask; /* Waiting for pending signals */
sq_queue_t sigpendactionq; /* List of pending signal actions */ sq_queue_t sigpendactionq; /* List of pending signal actions */
sq_queue_t sigpostedq; /* List of posted signals */ sq_queue_t sigpostedq; /* List of posted signals */
+2 -2
View File
@@ -127,8 +127,8 @@ static void netlink_notify_waiters(FAR struct netlink_conn_s *conn)
int i; int i;
/* Notify every pending thread. Lock the scheduler while we do this so /* Notify every pending thread. Lock the scheduler while we do this so
* that there is no thrashing: All waiters will be restarted, but only * there there is no thrashing: All waiters will be restarted, but only
* the highest priority waiter will get to run and it will receive the * the highest priority waiter will get to run and will receive the
* response. * response.
*/ */