ntdll: Don't restore %fs selector on nested signals.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-07-09 21:08:35 +02:00
parent 4e37f2d144
commit 37705d9ff6
3 changed files with 9 additions and 8 deletions

View File

@ -1542,7 +1542,8 @@ static inline void init_handler( const ucontext_t *sigcontext )
static inline void leave_handler( const ucontext_t *sigcontext ) static inline void leave_handler( const ucontext_t *sigcontext )
{ {
#ifdef __linux__ #ifdef __linux__
if (fs32_sel) __asm__ volatile( "movw %0,%%fs" :: "r" (fs32_sel) ); if (fs32_sel && !is_inside_signal_stack( (void *)RSP_sig(sigcontext )))
__asm__ volatile( "movw %0,%%fs" :: "r" (fs32_sel) );
#endif #endif
} }
@ -1997,7 +1998,7 @@ NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size )
memcpy( &frame->xstate.YmmContext, &xs->YmmContext, sizeof(xs->YmmContext) ); memcpy( &frame->xstate.YmmContext, &xs->YmmContext, sizeof(xs->YmmContext) );
} }
else frame->xstate.Mask &= ~XSTATE_MASK_GSSE; else frame->xstate.Mask &= ~XSTATE_MASK_GSSE;
frame->restore_flags |= CONTEXT_I386_XSTATE; frame->restore_flags |= CONTEXT_XSTATE;
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View File

@ -318,6 +318,12 @@ static inline void *get_signal_stack(void)
return (void *)(((ULONG_PTR)NtCurrentTeb() & ~signal_stack_mask) + teb_size); return (void *)(((ULONG_PTR)NtCurrentTeb() & ~signal_stack_mask) + teb_size);
} }
static inline BOOL is_inside_signal_stack( void *ptr )
{
return ((char *)ptr >= (char *)get_signal_stack() &&
(char *)ptr < (char *)get_signal_stack() + signal_stack_size);
}
static inline void mutex_lock( pthread_mutex_t *mutex ) static inline void mutex_lock( pthread_mutex_t *mutex )
{ {
if (!process_exiting) pthread_mutex_lock( mutex ); if (!process_exiting) pthread_mutex_lock( mutex );

View File

@ -237,12 +237,6 @@ static struct range_entry *free_ranges;
static struct range_entry *free_ranges_end; static struct range_entry *free_ranges_end;
static inline BOOL is_inside_signal_stack( void *ptr )
{
return ((char *)ptr >= (char *)get_signal_stack() &&
(char *)ptr < (char *)get_signal_stack() + signal_stack_size);
}
static inline BOOL is_beyond_limit( const void *addr, size_t size, const void *limit ) static inline BOOL is_beyond_limit( const void *addr, size_t size, const void *limit )
{ {
return (addr >= limit || (const char *)addr + size > (const char *)limit); return (addr >= limit || (const char *)addr + size > (const char *)limit);