Re: [PATCH] signal: remove the wrong signal_pending() check in restore_user_sigmask()
From: Oleg Nesterov
Date: Wed Jun 05 2019 - 05:00:20 EST
On 06/04, Linus Torvalds wrote:
>
> On Tue, Jun 4, 2019 at 6:41 AM Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> >
> > This is the minimal fix for stable, I'll send cleanups later.
>
> Ugh. I htink this is correct, but I wish we had a better and more
> intuitive interface.
Yes,
> In particular, since restore_user_sigmask() basically wants to check
> for "signal_pending()" anyway
No, the caller should check signal_pending() anyway and this is enough.
> > - 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,
This is fs/aio.c and I have already mentioned that this code doesn't look
right anyway.
> IOW, I think the above could become
>
> ret = restore_user_sigmask(ksig.sigmask, &sigsaved, ret, -ERESTARTHAND);
>
> instead if we just made the right interface decision.
I think this particular code should simply do
ret = do_io_getevents(...);
if (ret == -ERESTARTSYS)
ret = -EINTR;
restore_user_sigmask(ret == -EINTR);
However I agree that another helper(s) which takes/returns the error code makes
sense and I was going to do this. Lets do this step by step, I think we should
kill sigmask/sigsaved first.
Oleg.