|
@@ -1046,3 +1046,101 @@ static inline long __strlen_user(const char __user *s)
|
|
|
|
|
|
might_fault();
|
|
might_fault();
|
|
__asm__ __volatile__(
|
|
__asm__ __volatile__(
|
|
|
|
+ "move\t$4, %1\n\t"
|
|
|
|
+ __MODULE_JAL(__strlen_user_nocheck_asm)
|
|
|
|
+ "move\t%0, $2"
|
|
|
|
+ : "=r" (res)
|
|
|
|
+ : "r" (s)
|
|
|
|
+ : "$2", "$4", __UA_t0, "$31");
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * strlen_user: - Get the size of a string in user space.
|
|
|
|
+ * @str: The string to measure.
|
|
|
|
+ *
|
|
|
|
+ * Context: User context only. This function may sleep.
|
|
|
|
+ *
|
|
|
|
+ * Get the size of a NUL-terminated string in user space.
|
|
|
|
+ *
|
|
|
|
+ * Returns the size of the string INCLUDING the terminating NUL.
|
|
|
|
+ * On exception, returns 0.
|
|
|
|
+ *
|
|
|
|
+ * If there is a limit on the length of a valid string, you may wish to
|
|
|
|
+ * consider using strnlen_user() instead.
|
|
|
|
+ */
|
|
|
|
+static inline long strlen_user(const char __user *s)
|
|
|
|
+{
|
|
|
|
+ long res;
|
|
|
|
+
|
|
|
|
+ might_fault();
|
|
|
|
+ __asm__ __volatile__(
|
|
|
|
+ "move\t$4, %1\n\t"
|
|
|
|
+ __MODULE_JAL(__strlen_user_asm)
|
|
|
|
+ "move\t%0, $2"
|
|
|
|
+ : "=r" (res)
|
|
|
|
+ : "r" (s)
|
|
|
|
+ : "$2", "$4", __UA_t0, "$31");
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Returns: 0 if bad, string length+1 (memory size) of string if ok */
|
|
|
|
+static inline long __strnlen_user(const char __user *s, long n)
|
|
|
|
+{
|
|
|
|
+ long res;
|
|
|
|
+
|
|
|
|
+ might_fault();
|
|
|
|
+ __asm__ __volatile__(
|
|
|
|
+ "move\t$4, %1\n\t"
|
|
|
|
+ "move\t$5, %2\n\t"
|
|
|
|
+ __MODULE_JAL(__strnlen_user_nocheck_asm)
|
|
|
|
+ "move\t%0, $2"
|
|
|
|
+ : "=r" (res)
|
|
|
|
+ : "r" (s), "r" (n)
|
|
|
|
+ : "$2", "$4", "$5", __UA_t0, "$31");
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * strlen_user: - Get the size of a string in user space.
|
|
|
|
+ * @str: The string to measure.
|
|
|
|
+ *
|
|
|
|
+ * Context: User context only. This function may sleep.
|
|
|
|
+ *
|
|
|
|
+ * Get the size of a NUL-terminated string in user space.
|
|
|
|
+ *
|
|
|
|
+ * Returns the size of the string INCLUDING the terminating NUL.
|
|
|
|
+ * On exception, returns 0.
|
|
|
|
+ *
|
|
|
|
+ * If there is a limit on the length of a valid string, you may wish to
|
|
|
|
+ * consider using strnlen_user() instead.
|
|
|
|
+ */
|
|
|
|
+static inline long strnlen_user(const char __user *s, long n)
|
|
|
|
+{
|
|
|
|
+ long res;
|
|
|
|
+
|
|
|
|
+ might_fault();
|
|
|
|
+ __asm__ __volatile__(
|
|
|
|
+ "move\t$4, %1\n\t"
|
|
|
|
+ "move\t$5, %2\n\t"
|
|
|
|
+ __MODULE_JAL(__strnlen_user_asm)
|
|
|
|
+ "move\t%0, $2"
|
|
|
|
+ : "=r" (res)
|
|
|
|
+ : "r" (s), "r" (n)
|
|
|
|
+ : "$2", "$4", "$5", __UA_t0, "$31");
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+struct exception_table_entry
|
|
|
|
+{
|
|
|
|
+ unsigned long insn;
|
|
|
|
+ unsigned long nextinsn;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+extern int fixup_exception(struct pt_regs *regs);
|
|
|
|
+
|
|
|
|
+#endif /* _ASM_UACCESS_H */
|