mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-05 16:10:55 +00:00
Fix a race condition introduced when redzones were added. Use an
atomic operation to return and adjust the stack. Submitted by: luoqi
This commit is contained in:
parent
33499e2ae5
commit
c0addafac3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155990
|
@ -162,11 +162,11 @@ ENTRY(_amd64_restore_context)
|
||||||
cmpq $0, %rdi /* check for null pointer */
|
cmpq $0, %rdi /* check for null pointer */
|
||||||
jne 1f
|
jne 1f
|
||||||
movq $-1, %rax
|
movq $-1, %rax
|
||||||
jmp 7f
|
jmp 2f
|
||||||
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
|
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
|
||||||
je 2f
|
je 2f
|
||||||
movq $-1, %rax /* bzzzt, invalid context */
|
movq $-1, %rax /* bzzzt, invalid context */
|
||||||
jmp 7f
|
ret
|
||||||
2: movq MC_RCX(%rdi), %rcx
|
2: movq MC_RCX(%rdi), %rcx
|
||||||
movq MC_R8(%rdi), %r8
|
movq MC_R8(%rdi), %r8
|
||||||
movq MC_R9(%rdi), %r9
|
movq MC_R9(%rdi), %r9
|
||||||
|
@ -213,6 +213,5 @@ ENTRY(_amd64_restore_context)
|
||||||
popq %rsi /* restore rsi, rdx, and rdi */
|
popq %rsi /* restore rsi, rdx, and rdi */
|
||||||
popq %rdx
|
popq %rdx
|
||||||
popq %rdi
|
popq %rdi
|
||||||
leaq (8 + REDZONE)(%rsp), %rsp
|
ret $REDZONE
|
||||||
jmp *-(8 + REDZONE)(%rsp) /* jump to return address */
|
|
||||||
7: ret
|
|
||||||
|
|
|
@ -162,11 +162,11 @@ ENTRY(_amd64_restore_context)
|
||||||
cmpq $0, %rdi /* check for null pointer */
|
cmpq $0, %rdi /* check for null pointer */
|
||||||
jne 1f
|
jne 1f
|
||||||
movq $-1, %rax
|
movq $-1, %rax
|
||||||
jmp 7f
|
jmp 2f
|
||||||
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
|
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
|
||||||
je 2f
|
je 2f
|
||||||
movq $-1, %rax /* bzzzt, invalid context */
|
movq $-1, %rax /* bzzzt, invalid context */
|
||||||
jmp 7f
|
ret
|
||||||
2: movq MC_RCX(%rdi), %rcx
|
2: movq MC_RCX(%rdi), %rcx
|
||||||
movq MC_R8(%rdi), %r8
|
movq MC_R8(%rdi), %r8
|
||||||
movq MC_R9(%rdi), %r9
|
movq MC_R9(%rdi), %r9
|
||||||
|
@ -213,6 +213,5 @@ ENTRY(_amd64_restore_context)
|
||||||
popq %rsi /* restore rsi, rdx, and rdi */
|
popq %rsi /* restore rsi, rdx, and rdi */
|
||||||
popq %rdx
|
popq %rdx
|
||||||
popq %rdi
|
popq %rdi
|
||||||
leaq (8 + REDZONE)(%rsp), %rsp
|
ret $REDZONE
|
||||||
jmp *-(8 + REDZONE)(%rsp) /* jump to return address */
|
|
||||||
7: ret
|
|
||||||
|
|
Loading…
Reference in a new issue