Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2021 17:44:19 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: fb580451456a - main - linux: Fix SMAP-enabled futex routines
Message-ID:  <202105161744.14GHiJrd054600@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

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

commit fb580451456aa769daa2f4b2f077e39692f80c62
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-16 17:41:41 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-16 17:42:08 +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@gmail.com
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D30276
---
 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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105161744.14GHiJrd054600>