linux: Fix SMAP-enabled futex routines

Some of them were dereferencing the user pointer before disabling SMAP.

PR:		255591
Reviewed by:	kib
Tested by:	pitwuu@gmail.com
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30276
This commit is contained in:
Mark Johnston 2021-05-16 13:41:41 -04:00
parent 687e510e5c
commit fb58045145
2 changed files with 12 additions and 12 deletions

View File

@ -126,16 +126,16 @@ ENTRY(futex_orl_smap)
movq $VM_MAXUSER_ADDRESS-4,%rax
cmpq %rax,%rsi
ja futex_fault
stac
movl (%rsi),%eax
1: movl %eax,%ecx
orl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)
@ -168,16 +168,16 @@ ENTRY(futex_andl_smap)
movq $VM_MAXUSER_ADDRESS-4,%rax
cmpq %rax,%rsi
ja futex_fault
stac
movl (%rsi),%eax
1: movl %eax,%ecx
andl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)
@ -210,16 +210,16 @@ ENTRY(futex_xorl_smap)
movq $VM_MAXUSER_ADDRESS-4,%rax
cmpq %rax,%rsi
ja futex_fault
stac
movl (%rsi),%eax
1: movl %eax,%ecx
xorl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)

View File

@ -126,16 +126,16 @@ ENTRY(futex_orl_smap)
movq $VM_MAXUSER_ADDRESS-4,%rax
cmpq %rax,%rsi
ja futex_fault
stac
movl (%rsi),%eax
1: movl %eax,%ecx
orl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)
@ -169,15 +169,15 @@ ENTRY(futex_andl_smap)
cmpq %rax,%rsi
ja futex_fault
movl (%rsi),%eax
stac
1: movl %eax,%ecx
andl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)
@ -210,16 +210,16 @@ ENTRY(futex_xorl_smap)
movq $VM_MAXUSER_ADDRESS-4,%rax
cmpq %rax,%rsi
ja futex_fault
stac
movl (%rsi),%eax
1: movl %eax,%ecx
xorl %edi,%ecx
stac
#ifdef SMP
lock
#endif
cmpxchgl %ecx,(%rsi)
clac
jnz 1b
clac
movl %eax,(%rdx)
xorl %eax,%eax
movq %rax,PCB_ONFAULT(%r8)