patch-2.2.13 linux/include/asm-ppc/uaccess.h

Next file: linux/include/asm-sparc/head.h
Previous file: linux/include/asm-ppc/spinlock.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/include/asm-ppc/uaccess.h linux/include/asm-ppc/uaccess.h
@@ -259,7 +259,24 @@
  * Return 0 for error
  */
 
-extern long strlen_user(const char *);
+extern int __strnlen_user(const char *str, long len, unsigned long top);
+
+/*
+ * Returns the length of the string at str (including the null byte),
+ * or 0 if we hit a page we can't access,
+ * or something > len if we didn't find a null byte.
+ *
+ * The `top' parameter to __strnlen_user is to make sure that
+ * we can never overflow from the user area into kernel space.
+ * It is 1 + the highest address the task can access.
+ */
+extern __inline__ int strnlen_user(const char *str, long len)
+{
+	unsigned long top = __kernel_ok? 0: TASK_SIZE;
+	return __strnlen_user(str, len, top);
+}
+
+#define strlen_user(str)	strnlen_user((str), 0x7ffffffe)
 
 #endif  /* __ASSEMBLY__ */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)