The branch main has been updated by markj:

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

commit fb580451456aa769daa2f4b2f077e39692f80c62
Author:     Mark Johnston <[email protected]>
AuthorDate: 2021-05-16 17:41:41 +0000
Commit:     Mark Johnston <[email protected]>
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:      [email protected]
    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)
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to