Re: [PATCH] signal/x86: Delay calling signals in atomic

From: Sebastian Andrzej Siewior
Date: Mon Mar 28 2022 - 12:17:45 EST


On 2022-03-28 09:25:06 [-0500], Eric W. Biederman wrote:
> Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> writes:
>
> Folks I really would have appreciated being copied on a signal handling
> patch like this.

Sorry for that. For the whole ptrace/signal part is no maintainer listed
and I got the feeling that Oleg knows these bits.

> It is too late to nack, but I think this buggy patch deserved one. Can
> we please fix PREEMPT_RT instead?

Sure.

> As far as I can tell this violates all of rules from
> implementing/maintaining the RT kernel. Instead of coming up with new
> abstractions that makes sense and can use by everyone this introduces
> a hack only for PREEMPT_RT and a pretty horrible one at that.
>
> This talks about int3, but the code looks for in_atomic(). Which means
> that essentially every call of force_sig will take this path as they
> almost all come from exception handlers. It is the nature of signals
> that report on faults. An exception is raised and the kernel reports it
> to userspace with a fault signal (aka force_sig_xxx).

The int3 is invoked with disabled interrupts. There are also a few
others path which are explicit with disabled interrupts or with a
raw_spinlock_t which lead to an atomic section on PREEMPT_RT. Call
chains with spinlock_t or a rwlock_t don't lead to a atomic section on
PREEMPT_RT. Therefore I don't think this is "essentially every call of
force_sig" that is going to use that.

> Further this code is buggy. TIF_NOTIFY_RESUME is not the correct
> flag to set to enter into exit_to_usermode_loop. TIF_NOTIFY_RESUME is
> about that happens after signal handling. This very much needs to be
> TIF_SIGPENDING with recalc_sigpending and friends updated to know about
> "task->force_info".
>
> Does someone own this problem? Can that person please fix this
> properly?

Sure. Instead setting TIF_NOTIFY_RESUME you want the code updated to use
recalc_sigpending() only. Or do you have other suggestions regarding
fixing this properly?

> I really don't think it is going to be maintainable for PREEMPT_RT to
> maintain a separate signal delivery path for faults from the rest of
> linux.

Okay.

> Eric

Sebastian