Skip to contentSkip to conversation

s390: speedup strn{cpy,len}_from_user.

PATCH [email protected] 1 participant 1 message Jun 11, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 6 lines
Quoted 6 lines

static inline long
strncpy_from_user(char *dst, const char *src, long count)

 {
         long res = -EFAULT;
         might_sleep();

- if (access_ok(VERIFY_READ, src, 1))

Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +3 -1
-                res = __strncpy_from_user_asm(dst, src, count);
+        if (access_ok(VERIFY_READ, src, 1)) {
+                res = __strncpy_from_user_asm(count, dst, src);
+	}
         return res;
 }

Shouldn't the access_ok() check be passed count', rather than 1'?

This deserves a comment, but no.

"count" is the maximum length of the string, not the actual length. If you passed it to access_ok(), you'd falsely EFAULT a short string near the end of the address space.

Assuming that there's a guard page at the end of the user address space, __strncpy_from_user_asm is guaranteed to hit it as part of normal operations, and will get the fault.