Messages in this thread | | | From | "Eric W. Biederman" <> | Date | Mon, 28 Mar 2022 09:48:48 -0500 | Subject | Re: [PATCH] signal/x86: Delay calling signals in atomic |
| |
"Eric W. Biederman" <ebiederm@xmission.com> writes:
>> diff --git a/kernel/signal.c b/kernel/signal.c >> index 9b04631acde8f..cb2b28c17c0a5 100644 >> --- a/kernel/signal.c >> +++ b/kernel/signal.c >> @@ -1327,6 +1327,34 @@ force_sig_info_to_task(struct kernel_siginfo *info, struct task_struct *t, >> struct k_sigaction *action; >> int sig = info->si_signo; ^^^^^^^^^^^^^^^^^^^^^^^^^ See info->si_signo is unconditionally dereferenced. >> >> + /* >> + * On some archs, PREEMPT_RT has to delay sending a signal from a trap >> + * since it can not enable preemption, and the signal code's spin_locks >> + * turn into mutexes. Instead, it must set TIF_NOTIFY_RESUME which will >> + * send the signal on exit of the trap. >> + */ >> +#ifdef ARCH_RT_DELAYS_SIGNAL_SEND >> + if (in_atomic()) { >> + struct task_struct *t = current; >> + >> + if (WARN_ON_ONCE(t->forced_info.si_signo)) >> + return 0; >> + >> + if (is_si_special(info)) { ^^^^^^^^^^^^^^^^^^^ This tests to see if info is either 0 or 1 cased to as "kernel_siginfo *"
Which is a long way of saying this code already guarantees that is_si_special is guaranteed to be false so most of this code is completely unnecessary.
>> + WARN_ON_ONCE(info != SEND_SIG_PRIV); >> + t->forced_info.si_signo = info->si_signo; >> + t->forced_info.si_errno = 0; >> + t->forced_info.si_code = SI_KERNEL; >> + t->forced_info.si_pid = 0; >> + t->forced_info.si_uid = 0; >> + } else { >> + t->forced_info = *info; >> + } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ All of that can just be:
copy_siginfo(&t->force_info, info);
Using a structure copy here that gcc is allowed to not copy bytes in the padding is wrong in that it allows an information leak to userspace.
>> + set_tsk_thread_flag(t, TIF_NOTIFY_RESUME); >> + return 0; >> + } >> +#endif >> spin_lock_irqsave(&t->sighand->siglock, flags); >> action = &t->sighand->action[sig-1]; >> ignored = action->sa.sa_handler == SIG_IGN;
Eric
| |