Re: [PATCH] signal: remove the wrong signal_pending() check in restore_user_sigmask()

From: Oleg Nesterov
Date: Wed Jun 05 2019 - 05:09:04 EST


On 06/04, Eric W. Biederman wrote:
>
> >> - restore_user_sigmask(ksig.sigmask, &sigsaved);
> >> - if (signal_pending(current) && !ret)
> >> +
> >> + interrupted = signal_pending(current);
> >> + restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted);
> >> + if (interrupted && !ret)
> >> ret = -ERESTARTNOHAND;
> >
> > are wrong to begin with, and we really should aim for an interface
> > which says "tell me whether you completed the system call, and I'll
> > give you an error return if not".
>
> The pattern you are pointing out is specific to io_pgetevents and it's
> variations. It does look buggy to me but not for the reason you point
> out, but instead because it does not appear to let a pending signal
> cause io_pgetevents to return early.
>
> I suspect we should fix that and have do_io_getevents return
> -EINTR or -ERESTARTNOHAND like everyone else.

Exactly. It should not even check signal_pending(). It can rely on
wait_event_interruptible_hrtimeout().

> So can we please get this fix in and then look at cleaning up and
> simplifying this code.

Yes ;)

Oleg.