From d9c61be99f970a906f1e2a14ab2d15f0c24f0a83 Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 14 Sep 2005 18:57:01 +0000 Subject: 2005-09-14 Martin Hunt * copy.c (__stp_strncpy_from_user): Add ppc64 support. (_stp_strncpy_from_user): Call access_ok(). (_stp_string_from_user): Ditto. (_stp_copy_from_user): Ditto. --- runtime/copy.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'runtime/copy.c') diff --git a/runtime/copy.c b/runtime/copy.c index 71f69335..25f4d695 100644 --- a/runtime/copy.c +++ b/runtime/copy.c @@ -74,6 +74,9 @@ do { \ : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ : "memory"); \ } while (0) +#elif defined (__powerpc64__) +#define __stp_strncpy_from_user(dst,src,count,res) \ + do { res = __strncpy_from_user(dst, src, count); } while(0) #endif /** Copy a NULL-terminated string from userspace. @@ -89,14 +92,14 @@ do { \ * * If count is smaller than the length of the string, copies * count bytes and returns count. - * @deprecated I can't think of why you wouldn't use _stp_string_from_user() instead. */ long _stp_strncpy_from_user(char *dst, const char __user *src, long count) { - long res; - __stp_strncpy_from_user(dst, src, count, res); + long res = -EFAULT; + if (access_ok(VERIFY_READ, src, count)) + __stp_strncpy_from_user(dst, src, count, res); return res; } @@ -112,13 +115,15 @@ _stp_strncpy_from_user(char *dst, const char __user *src, long count) void _stp_string_from_user (String str, const char __user *src, long count) { - long res; + long res = -EFAULT; if (count > STP_STRING_SIZE - str->len - 1) count = STP_STRING_SIZE - str->len - 1; - __stp_strncpy_from_user(str->buf + str->len, src, count, res); - if (res > 0) { - str->len += res; - str->buf[str->len] = '\0'; + if (access_ok(VERIFY_READ, src, count)) { + __stp_strncpy_from_user(str->buf + str->len, src, count, res); + if (res > 0) { + str->len += res; + str->buf[str->len] = '\0'; + } } } @@ -138,7 +143,13 @@ void _stp_string_from_user (String str, const char __user *src, long count) unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count) { - return __copy_from_user_inatomic(dst, src, count); + if (count) { + if (access_ok(VERIFY_READ, src, count)) + count = __copy_from_user_inatomic(dst, src, count); + else + memset(dst, 0, count); + } + return count; } /** @} */ -- cgit