diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/signal.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index e8308e3238c1..8aa3a2e226af 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2299,6 +2299,29 @@ long do_no_restart_syscall(struct restart_block *param) | |||
2299 | return -EINTR; | 2299 | return -EINTR; |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | /** | ||
2303 | * set_current_blocked - change current->blocked mask | ||
2304 | * @newset: new mask | ||
2305 | * | ||
2306 | * It is wrong to change ->blocked directly, this helper should be used | ||
2307 | * to ensure the process can't miss a shared signal we are going to block. | ||
2308 | */ | ||
2309 | void set_current_blocked(const sigset_t *newset) | ||
2310 | { | ||
2311 | struct task_struct *tsk = current; | ||
2312 | |||
2313 | spin_lock_irq(&tsk->sighand->siglock); | ||
2314 | if (signal_pending(tsk) && !thread_group_empty(tsk)) { | ||
2315 | sigset_t newblocked; | ||
2316 | /* A set of now blocked but previously unblocked signals. */ | ||
2317 | signandsets(&newblocked, newset, ¤t->blocked); | ||
2318 | retarget_shared_pending(tsk, &newblocked); | ||
2319 | } | ||
2320 | tsk->blocked = *newset; | ||
2321 | recalc_sigpending(); | ||
2322 | spin_unlock_irq(&tsk->sighand->siglock); | ||
2323 | } | ||
2324 | |||
2302 | /* | 2325 | /* |
2303 | * This is also useful for kernel threads that want to temporarily | 2326 | * This is also useful for kernel threads that want to temporarily |
2304 | * (or permanently) block certain signals. | 2327 | * (or permanently) block certain signals. |
@@ -2330,11 +2353,7 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset) | |||
2330 | return -EINVAL; | 2353 | return -EINVAL; |
2331 | } | 2354 | } |
2332 | 2355 | ||
2333 | spin_lock_irq(&tsk->sighand->siglock); | 2356 | set_current_blocked(&newset); |
2334 | tsk->blocked = newset; | ||
2335 | recalc_sigpending(); | ||
2336 | spin_unlock_irq(&tsk->sighand->siglock); | ||
2337 | |||
2338 | return 0; | 2357 | return 0; |
2339 | } | 2358 | } |
2340 | 2359 | ||