lkml.org 
[lkml]   [2022]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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

\
 
 \ /
  Last update: 2022-03-28 16:49    [W:0.107 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site