mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 01:34:00 +08:00
Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull kernel thread signal handling fix from Eric Biederman: "I overlooked the fact that kernel threads are created with all signals set to SIG_IGN, and accidentally caused a regression in cifs and drbd when replacing force_sig with send_sig. This is my fix for that regression. I add a new function allow_kernel_signal which allows kernel threads to receive signals sent from the kernel, but continues to ignore all signals sent from userspace. This ensures the user space interface for cifs and drbd remain the same. These kernel threads depend on blocking networking calls which block until something is received or a signal is pending. Making receiving of signals somewhat necessary for these kernel threads. Perhaps someday we can cleanup those interfaces and remove allow_kernel_signal. If not allow_kernel_signal is pretty trivial and clearly documents what is going on so I don't think we will mind carrying it" * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: signal: Allow cifs and drbd to receive their terminating signals
This commit is contained in:
commit
287c55ed7d
@ -322,6 +322,8 @@ static int drbd_thread_setup(void *arg)
|
||||
thi->name[0],
|
||||
resource->name);
|
||||
|
||||
allow_kernel_signal(DRBD_SIGKILL);
|
||||
allow_kernel_signal(SIGXCPU);
|
||||
restart:
|
||||
retval = thi->function(thi);
|
||||
|
||||
|
@ -1113,7 +1113,7 @@ cifs_demultiplex_thread(void *p)
|
||||
mempool_resize(cifs_req_poolp, length + cifs_min_rcv);
|
||||
|
||||
set_freezable();
|
||||
allow_signal(SIGKILL);
|
||||
allow_kernel_signal(SIGKILL);
|
||||
while (server->tcpStatus != CifsExiting) {
|
||||
if (try_to_freeze())
|
||||
continue;
|
||||
|
@ -282,6 +282,9 @@ extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping);
|
||||
extern void exit_signals(struct task_struct *tsk);
|
||||
extern void kernel_sigaction(int, __sighandler_t);
|
||||
|
||||
#define SIG_KTHREAD ((__force __sighandler_t)2)
|
||||
#define SIG_KTHREAD_KERNEL ((__force __sighandler_t)3)
|
||||
|
||||
static inline void allow_signal(int sig)
|
||||
{
|
||||
/*
|
||||
@ -289,7 +292,17 @@ static inline void allow_signal(int sig)
|
||||
* know it'll be handled, so that they don't get converted to
|
||||
* SIGKILL or just silently dropped.
|
||||
*/
|
||||
kernel_sigaction(sig, (__force __sighandler_t)2);
|
||||
kernel_sigaction(sig, SIG_KTHREAD);
|
||||
}
|
||||
|
||||
static inline void allow_kernel_signal(int sig)
|
||||
{
|
||||
/*
|
||||
* Kernel threads handle their own signals. Let the signal code
|
||||
* know signals sent by the kernel will be handled, so that they
|
||||
* don't get silently dropped.
|
||||
*/
|
||||
kernel_sigaction(sig, SIG_KTHREAD_KERNEL);
|
||||
}
|
||||
|
||||
static inline void disallow_signal(int sig)
|
||||
|
@ -90,6 +90,11 @@ static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
|
||||
handler == SIG_DFL && !(force && sig_kernel_only(sig)))
|
||||
return true;
|
||||
|
||||
/* Only allow kernel generated signals to this kthread */
|
||||
if (unlikely((t->flags & PF_KTHREAD) &&
|
||||
(handler == SIG_KTHREAD_KERNEL) && !force))
|
||||
return true;
|
||||
|
||||
return sig_handler_ignored(handler, sig);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user