Re: pselect/etc semantics (Was: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask())

From: Oleg Nesterov
Date: Thu May 30 2019 - 10:44:34 EST


On 05/30, Arnd Bergmann wrote:
>
> I think this is a nice simplification, but it would help not to mix up the
> minimal regression fix with the rewrite of those functions.

Yes, yes, agreed.

Plus every file touched by this patch asks for more cleanups. Say, do_poll()
should return -ERESTARTNOHAND, not -EINTR, after that we can remove the ugly
EINTR->ERESTARTNOHAND in its callers. And more.

> For the stable
> kernels, I think we want just the addition of the 'bool interrupted' argument
> to restore_user_sigmask()

or simply revert this patch. I will check if this is possible today... At first
glance 854a6ed56839a40f6 fixed another bug by accident, do_pselect() did
"ret == -ERESTARTNOHAND" after "ret = poll_select_copy_remaining()" which can
turn ERESTARTNOHAND into EINTR, but this is simple. I'll check tomorrow.


> > - ret = set_user_sigmask(ksig.sigmask, &ksigmask, &sigsaved, ksig.sigsetsize);
> > + ret = set_xxx(ksig.sigmask, ksig.sigsetsize);
> > if (ret)
> > return ret;
> >
> > ret = do_io_getevents(ctx_id, min_nr, nr, events, timeout ? &ts : NULL);
> > - restore_user_sigmask(ksig.sigmask, &sigsaved);
> > - if (signal_pending(current) && !ret)
> > +
> > + interrupted = signal_pending(current);
> > + update_xxx(interrupted);
>
> Maybe name this
>
> restore_saved_sigmask_if(!interrupted);

Yes, I thought about restore_if(), but to me

restore_saved_sigmask_if(ret != -EINTR);

doesn't look readable... May be

restore_saved_sigmask_unless(ret == -EINTR);

? but actually I agree with any naming.

> and make restore_saved_sigmask_if() an inline function
> next to restore_saved_sigmask()?

agreed,

> With some of the recent discussions about compat syscall handling,
> I now think that we want to just fold set_compat_user_sigmask()
> into set_user_sigmask()

agreed, and I thought about this too. But again, I'd prefer to do this
and other cleanups later, on top of this patch.

Oleg.