lkml.org 
[lkml]   [2022]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] signal/x86: Delay calling signals in atomic
Sebastian Andrzej Siewior <bigeasy@linutronix.de> writes:

> On 2022-03-30 13:10:05 [-0500], Eric W. Biederman wrote:
>> But it looks like if we are coming from userspace then we use the same
>> stack as any other time we would come from userspace. AKA a stack
>> that allows the kernel to sleep.
>>
>> So I don't see what the problem is that is trying to be fixed.
>
> It is not only the stack. In atomic context / disabled interrupts it is
> not possible to acquire a spinlock_t (sighand_struct::siglock) which is
> done later.

Looking at do_int3_user the interrupts must be enabled.
>
>> I know that code has been changed over the years, perhaps this is
>> something that was fixed upstream and the real time tree didn't realize
>> there was no longer a need to fix anything?
>>
>> Or am I missing something subtle when reading the idtentry assembly?
>
> It certainly is true that the code changed over the years. The per-CPU
> stack is one problem, the siglock in atomic context is the other one.
> Thank you for the input. Let me digest the informations I have here and
> get back.

Certainly. I case it helps this is the relevant bit of code:

static void do_int3_user(struct pt_regs *regs)
{
if (do_int3(regs))
return;

cond_local_irq_enable(regs);
do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, 0, 0, NULL);
cond_local_irq_disable(regs);
}

The signal delivery where siglock is take happens inside of do_trap. If
we are coming from kernel mode only do_int3 is called.

Coming from user_mode we switch to the task stack and
enable interrupts.

Unless I am misreading the code the cond_local_irq_{enable/disable} can
correctly be replaced local_irq_{enable/disable} as coming from user
mode interrupts are always enabled.

Unless I am misreading cond_local_irq_enable. If for some reason
cond_local_irq_enable doesn't enable interrupts when come from user
mode fixing that appears to be the fix that is needed.


Eric

\
 
 \ /
  Last update: 2022-04-04 16:30    [W:0.042 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site