From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH] signals: Generate warning when flush_signals() is called from non-kthread context Date: Wed, 6 May 2015 12:19:27 +0200 Message-ID: <20150506101927.GA17291@gmail.com> References: <1430502057.4472.255.camel@redhat.com> <20150501193813.GA2812@gmail.com> <20150503173401.GA22052@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Linus Torvalds , Neil Brown , Evgeniy Polyakov , Stephen Smalley , Alex Williamson , linux-kernel , kvm To: Oleg Nesterov Return-path: Content-Disposition: inline In-Reply-To: <20150503173401.GA22052@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org * Oleg Nesterov 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