Skip to contentSkip to conversation

: sparc64: Fix probe_kernel_{read,write}().

PATCH New David Miller 1 participant 1 message Feb 9, 2009 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 2/2 : sparc64: Fix probe_kernel_{read,write}().

This is based upon a report from Chris Torek and his initial patch. From Chris's report:

--------------------
This came up in testing kgdb, using the built-in tests -- turn on CONFIG_KGDB_TESTS, then

echo V1 > /sys/module/kgdbts/parameters/kgdbts

-- but it would affect using kgdb if you were debugging and looking at bad pointers.
--------------------

When we get a copy_{from,to}_user() request and the %asi is set to something other than ASI_AIUS (which is userspace) then we branch off to a routine called memcpy_user_stub(). It just does a straight memcpy since we are copying from kernel to kernel in this case.

The logic was that since source and destination are both kernel pointers we don't need to have exception checks.

But for what probe_kernel_{read,write}() is trying to do, we have to have the checks, otherwise things like kgdb bad kernel pointer accesses don't do the right thing.

---
 arch/sparc/lib/GENcopy_from_user.S |    2 +-
 arch/sparc/lib/GENcopy_to_user.S   |    2 +-
 arch/sparc/lib/NG2copy_from_user.S |    2 +-
 arch/sparc/lib/NG2copy_to_user.S   |    2 +-
 arch/sparc/lib/NGcopy_from_user.S  |    2 +-
 arch/sparc/lib/NGcopy_to_user.S    |    2 +-
 arch/sparc/lib/U1copy_from_user.S  |    2 +-
 arch/sparc/lib/U1copy_to_user.S    |    2 +-
 arch/sparc/lib/U3copy_to_user.S    |    2 +-
 arch/sparc/lib/copy_in_user.S      |   55 ++++++++++-------------------------
 10 files changed, 25 insertions(+), 48 deletions(-)
arch/sparc/lib/GENcopy_from_user.S +1 -1
index 9b0e58f..b7d0bd6 100644
@@ -23,7 +23,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/GENcopy_to_user.S +1 -1
index ce79b49..780550e 100644
@@ -27,7 +27,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/NG2copy_from_user.S +1 -1
index 01ac546..119ccb9 100644
@@ -28,7 +28,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/NG2copy_to_user.S +1 -1
index c477e15..7fe1cce 100644
@@ -37,7 +37,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/NGcopy_from_user.S +1 -1
index 39bb891..5d1e4d1 100644
@@ -25,7 +25,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/NGcopy_to_user.S +1 -1
index bf62fc1..ff630dc 100644
@@ -28,7 +28,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop
 #endif
 
arch/sparc/lib/U1copy_from_user.S +1 -1
index f14efdd..a6ae2ea 100644
@@ -23,7 +23,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop;						\
 
 #include "U1memcpy.S"
arch/sparc/lib/U1copy_to_user.S +1 -1
index 59d531b..f4b970e 100644
@@ -23,7 +23,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop;						\
 
 #include "U1memcpy.S"
arch/sparc/lib/U3copy_to_user.S +1 -1
index b4cbfe5..ef1e493 100644
@@ -23,7 +23,7 @@
 #define PREAMBLE					\
 	rd		%asi, %g1;			\
 	cmp		%g1, ASI_AIUS;			\
-	bne,pn		%icc, memcpy_user_stub;		\
+	bne,pn		%icc, ___copy_in_user;		\
 	 nop;						\
 
 #include "U3memcpy.S"
arch/sparc/lib/copy_in_user.S +16 -39

102 lines not on this page · raw message

Signature · 1 line
1.6.1.2.253.ga34a