Re: [PATCH] signals: Generate warning when flush_signals() is called from non-kthread context

From: Ingo Molnar
Date: Wed May 06 2015 - 06:19:37 EST



* Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -427,6 +427,10 @@ void flush_signals(struct task_struct *t)
> > {
> > unsigned long flags;
> >
> > + /* Only kthreads are allowed to destroy signals: */
> > + if (WARN_ON_ONCE(!(current->flags & PF_KTHREAD)))
> > + return;
> > +
>
> But I am not sure this can't make some buggy driver even more buggy.
> Just suppose it does something
>
> do {
> if (signal_pending())
> flush_signals();
> } while (wait_event_interruptible(...));
>
> and this change will turn this into busy-wait loop.
>
> So perhaps another change which just adds WARN_ON_RATELIMIT()
> without "return" will be safer?

Yeah, absolutely.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/