Skip to contentSkip to conversation

m68k: make sys_atomic_cmpxchg_32 work on classic m68k

PATCH Applied Andreas Schwab 3 participants 3 messages Jul 27, 2012 – Aug 2, 2012 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: make sys_atomic_cmpxchg_32 work on classic m68k

User space access must always go through uaccess accessors, since on classic m68k user space and kernel space are completely separate.

---
 arch/m68k/kernel/sys_m68k.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/m68k/kernel/sys_m68k.c +6 -2
index 8623f8d..9a5932e 100644
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
 			goto bad_access;
 		}
 
-		mem_value = *mem;
+		/*
+		 * No need to check for EFAULT; we know that the page is
+		 * present and writable.
+		 */
+		__get_user(mem_value, mem);
 		if (mem_value == oldval)
-			*mem = newval;
+			__put_user(newval, mem);
 
 		pte_unmap_unlock(pte, ptl);
 		up_read(&mm->mmap_sem);
Signature · 7 lines
1.7.11.3


-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Tested-by on v1 1/1
#1 lore raw

Andreas Schwab dixit:

Quoted 4 lines

User space access must always go through uaccess accessors, since on classic m68k user space and kernel space are completely separate.

This fixes my testcases, both the reduced two and the real-life one (running apt-get update no longer freezes the system, yay!).

Ben, can we please get that in the next src:linux upload to sid?

Quoted 33 lines

---
arch/m68k/kernel/sys_m68k.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)
arch/m68k/kernel/sys_m68k.c +6 -2
index 8623f8d..9a5932e 100644
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
 			goto bad_access;
 		}
 
-		mem_value = *mem;
+		/*
+		 * No need to check for EFAULT; we know that the page is
+		 * present and writable.
+		 */
+		__get_user(mem_value, mem);
 		if (mem_value == oldval)
-			*mem = newval;
+			__put_user(newval, mem);
 
 		pte_unmap_unlock(pte, ptl);
 		up_read(&mm->mmap_sem);
Signature · 7 lines
1.7.11.3


-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

//mirabilos

Signature · 4 lines
13:37⎜«Natureshadow» Deep inside, I hate mirabilos. I mean, he's a good
guy. But he's always right! In every fsckin' situation, he's right. Even
with his deeply perverted taste in software and borked ambition towards
broken OSes - in the end, he's damn right about it :(! […] works in mksh
maintainer Applied
#2 lore raw
In reply to Andreas Schwab
Quoted 4 lines · Andreas Schwab

User space access must always go through uaccess accessors, since on classic m68k user space and kernel space are completely separate.

Thanks, applied and queued for 3.6-rc1 and stable.

Quoted 25 lines
---
 arch/m68k/kernel/sys_m68k.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/m68k/kernel/sys_m68k.c +6 -3
index 8623f8d..9a5932e 100644
@@ -479,9 +479,13 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
                        goto bad_access;
                }
 
-               mem_value = *mem;
+               /*
+                * No need to check for EFAULT; we know that the page is
+                * present and writable.
+                */
+               __get_user(mem_value, mem);
                if (mem_value == oldval)
-                       *mem = newval;
+                       __put_user(newval, mem);
 
                pte_unmap_unlock(pte, ptl);
                up_read(&mm->mmap_sem);
--
Quoted 1 line

1.7.11.3

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds