Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0702d6b8
Commit
0702d6b8
authored
Jun 16, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Don't allow single-stepping through syscalls.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=51273
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5c009c17
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
5 deletions
+68
-5
signal_i386.c
dlls/ntdll/unix/signal_i386.c
+30
-0
signal_x86_64.c
dlls/ntdll/unix/signal_x86_64.c
+31
-0
import.c
tools/winebuild/import.c
+7
-5
No files found.
dlls/ntdll/unix/signal_i386.c
View file @
0702d6b8
...
...
@@ -1753,6 +1753,34 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, void *stack_ptr,
}
/***********************************************************************
* handle_syscall_trap
*
* Handle a trap exception during a system call.
*/
static
BOOL
handle_syscall_trap
(
ucontext_t
*
sigcontext
)
{
extern
void
__wine_syscall_dispatcher_prolog_end
(
void
);
struct
syscall_frame
*
frame
=
x86_thread_data
()
->
syscall_frame
;
/* disallow single-stepping through a syscall */
if
((
void
*
)
EIP_sig
(
sigcontext
)
!=
__wine_syscall_dispatcher
)
return
FALSE
;
TRACE
(
"ignoring trap in syscall eip=%08x eflags=%08x
\n
"
,
EIP_sig
(
sigcontext
),
EFL_sig
(
sigcontext
)
);
frame
->
eip
=
*
(
ULONG
*
)
ESP_sig
(
sigcontext
);
frame
->
eflags
=
EFL_sig
(
sigcontext
);
frame
->
restore_flags
=
CONTEXT_CONTROL
;
EIP_sig
(
sigcontext
)
=
(
ULONG
)
__wine_syscall_dispatcher_prolog_end
;
ECX_sig
(
sigcontext
)
=
(
ULONG
)
frame
;
ESP_sig
(
sigcontext
)
+=
sizeof
(
ULONG
);
EFL_sig
(
sigcontext
)
&=
~
0x100
;
/* clear single-step flag */
return
TRUE
;
}
/**********************************************************************
* segv_handler
*
...
...
@@ -1855,6 +1883,8 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
ucontext_t
*
ucontext
=
sigcontext
;
void
*
stack
=
setup_exception_record
(
sigcontext
,
&
rec
,
&
xcontext
);
if
(
handle_syscall_trap
(
ucontext
))
return
;
switch
(
TRAP_sig
(
ucontext
))
{
case
TRAP_x86_TRCTRAP
:
/* Single-step exception */
...
...
dlls/ntdll/unix/signal_x86_64.c
View file @
0702d6b8
...
...
@@ -2202,6 +2202,35 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec,
}
/***********************************************************************
* handle_syscall_trap
*
* Handle a trap exception during a system call.
*/
static
BOOL
handle_syscall_trap
(
ucontext_t
*
sigcontext
)
{
extern
void
__wine_syscall_dispatcher_prolog_end
(
void
);
struct
syscall_frame
*
frame
=
amd64_thread_data
()
->
syscall_frame
;
/* disallow single-stepping through a syscall */
if
((
void
*
)
RIP_sig
(
sigcontext
)
!=
__wine_syscall_dispatcher
)
return
FALSE
;
TRACE
(
"ignoring trap in syscall rip=%p eflags=%08x
\n
"
,
(
void
*
)
RIP_sig
(
sigcontext
),
(
ULONG
)
EFL_sig
(
sigcontext
)
);
frame
->
rip
=
*
(
ULONG64
*
)
RSP_sig
(
sigcontext
);
frame
->
eflags
=
EFL_sig
(
sigcontext
);
frame
->
restore_flags
=
CONTEXT_CONTROL
;
RIP_sig
(
sigcontext
)
=
(
ULONG64
)
__wine_syscall_dispatcher_prolog_end
;
RCX_sig
(
sigcontext
)
=
(
ULONG64
)
frame
;
RSP_sig
(
sigcontext
)
+=
sizeof
(
ULONG64
);
EFL_sig
(
sigcontext
)
&=
~
0x100
;
/* clear single-step flag */
return
TRUE
;
}
/**********************************************************************
* segv_handler
*
...
...
@@ -2281,6 +2310,8 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext )
struct
xcontext
context
;
ucontext_t
*
ucontext
=
sigcontext
;
if
(
handle_syscall_trap
(
sigcontext
))
return
;
rec
.
ExceptionAddress
=
(
void
*
)
RIP_sig
(
ucontext
);
save_context
(
&
context
,
sigcontext
);
...
...
tools/winebuild/import.c
View file @
0702d6b8
...
...
@@ -1436,9 +1436,10 @@ static void output_syscall_dispatcher(void)
output
(
"
\t
movl %%fs:0x1f8,%%ecx
\n
"
);
/* x86_thread_data()->syscall_frame */
output
(
"
\t
movl $0,0x00(%%ecx)
\n
"
);
/* frame->restore_flags */
output
(
"
\t
popl 0x08(%%ecx)
\n
"
);
/* frame->eip */
output
(
"
\t
movl %%esp,0x0c(%%ecx)
\n
"
);
/* frame->esp */
output
(
"
\t
pushfl
\n
"
);
output
(
"
\t
popl 0x04(%%ecx)
\n
"
);
/* frame->eflags */
output
(
"%s
\n
"
,
asm_globl
(
"__wine_syscall_dispatcher_prolog_end"
)
);
output
(
"
\t
movl %%esp,0x0c(%%ecx)
\n
"
);
/* frame->esp */
output
(
"
\t
movw %%cs,0x10(%%ecx)
\n
"
);
output
(
"
\t
movw %%ss,0x12(%%ecx)
\n
"
);
output
(
"
\t
movw %%ds,0x14(%%ecx)
\n
"
);
...
...
@@ -1553,6 +1554,11 @@ static void output_syscall_dispatcher(void)
case
CPU_x86_64
:
output
(
"
\t
movq %%gs:0x30,%%rcx
\n
"
);
output
(
"
\t
movq 0x328(%%rcx),%%rcx
\n
"
);
/* amd64_thread_data()->syscall_frame */
output
(
"
\t
popq 0x70(%%rcx)
\n
"
);
/* frame->rip */
output
(
"
\t
pushfq
\n
"
);
output
(
"
\t
popq 0x80(%%rcx)
\n
"
);
output
(
"
\t
movl $0,0x94(%%rcx)
\n
"
);
/* frame->restore_flags */
output
(
"%s
\n
"
,
asm_globl
(
"__wine_syscall_dispatcher_prolog_end"
)
);
output
(
"
\t
movq %%rax,0x00(%%rcx)
\n
"
);
output
(
"
\t
movq %%rbx,0x08(%%rcx)
\n
"
);
output
(
"
\t
movq %%rdx,0x18(%%rcx)
\n
"
);
...
...
@@ -1562,7 +1568,6 @@ static void output_syscall_dispatcher(void)
output
(
"
\t
movq %%r13,0x58(%%rcx)
\n
"
);
output
(
"
\t
movq %%r14,0x60(%%rcx)
\n
"
);
output
(
"
\t
movq %%r15,0x68(%%rcx)
\n
"
);
output
(
"
\t
popq 0x70(%%rcx)
\n
"
);
/* frame->rip */
output
(
"
\t
movw %%cs,0x78(%%rcx)
\n
"
);
output
(
"
\t
movw %%ds,0x7a(%%rcx)
\n
"
);
output
(
"
\t
movw %%es,0x7c(%%rcx)
\n
"
);
...
...
@@ -1570,10 +1575,7 @@ static void output_syscall_dispatcher(void)
output
(
"
\t
movq %%rsp,0x88(%%rcx)
\n
"
);
output
(
"
\t
movw %%ss,0x90(%%rcx)
\n
"
);
output
(
"
\t
movw %%gs,0x92(%%rcx)
\n
"
);
output
(
"
\t
movl $0,0x94(%%rcx)
\n
"
);
/* frame->restore_flags */
output
(
"
\t
movq %%rbp,0x98(%%rcx)
\n
"
);
output
(
"
\t
pushfq
\n
"
);
output
(
"
\t
popq 0x80(%%rcx)
\n
"
);
/* Legends of Runeterra hooks the first system call return instruction, and
* depends on us returning to it. Adjust the return address accordingly. */
output
(
"
\t
subq $0xb,0x70(%%rcx)
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment