git: 14cc1326579b - stable/13 - linux: Fix SMAP-enabled futex routines

Mark Johnston markj at FreeBSD.org
Sun May 23 16:50:45 UTC 2021


The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=14cc1326579b24c5eb743a62874fc768d0ca0ab5

commit 14cc1326579b24c5eb743a62874fc768d0ca0ab5
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-05-16 17:41:41 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-05-23 16:43:43 +0000

    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 at gmail.com
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit fb580451456aa769daa2f4b2f077e39692f80c62)
---
 sys/amd64/linux/linux_support.s     | 12 ++++++------
 sys/amd64/linux32/linux32_support.s | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sys/amd64/linux/linux_support.s b/sys/amd64/linux/linux_support.s
index 391f76414f22..45eb565f667d 100644
--- a/sys/amd64/linux/linux_support.s
+++ b/sys/amd64/linux/linux_support.s
@@ -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)
diff --git a/sys/amd64/linux32/linux32_support.s b/sys/amd64/linux32/linux32_support.s
index 981bba9f5821..f3ec3bd8c776 100644
--- a/sys/amd64/linux32/linux32_support.s
+++ b/sys/amd64/linux32/linux32_support.s
@@ -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)


More information about the dev-commits-src-all mailing list