| @@ -2,8 +2,6 @@ · 1 unmodified line |
| 2 | #ifndef __TRACE_PROBE_KERNEL_H_ | 2 | #ifndef __TRACE_PROBE_KERNEL_H_ |
| 3 | #define __TRACE_PROBE_KERNEL_H_ | 3 | #define __TRACE_PROBE_KERNEL_H_ |
| 4 | | 4 | |
| 5 | #define FAULT_STRING "(fault)" | | |
| 6 | | | |
| 7 | /* | 5 | /* |
| 8 | * This depends on trace_probe.h, but can not include it due to | 6 | * This depends on trace_probe.h, but can not include it due to |
| 9 | * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. | 7 | * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. |
| @@ -15,16 +13,8 @@ static nokprobe_inline int · 5 unmodified lines |
| 15 | fetch_store_strlen_user(unsigned long addr) | 13 | fetch_store_strlen_user(unsigned long addr) |
| 16 | { | 14 | { |
| 17 | const void __user *uaddr = (__force const void __user *)addr; | 15 | const void __user *uaddr = (__force const void __user *)addr; |
| 18 | int ret; | | |
| 19 | | 16 | |
| 20 | ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE); | 17 | return strnlen_user_nofault(uaddr, MAX_STRING_SIZE); |
| 21 | /* | | |
| 22 | * strnlen_user_nofault returns zero on fault, insert the | | |
| 23 | * FAULT_STRING when that occurs. | | |
| 24 | */ | | |
| 25 | if (ret <= 0) | | |
| 26 | return strlen(FAULT_STRING) + 1; | | |
| 27 | return ret; | | |
| 28 | } | 18 | } |
| 29 | | 19 | |
| 30 | /* Return the length of string -- including null terminal byte */ | 20 | /* Return the length of string -- including null terminal byte */ |
| @@ -44,18 +34,7 @@ fetch_store_strlen(unsigned long addr) · 13 unmodified lines |
| 44 | len++; | 34 | len++; |
| 45 | } while (c && ret == 0 && len < MAX_STRING_SIZE); | 35 | } while (c && ret == 0 && len < MAX_STRING_SIZE); |
| 46 | | 36 | |
| 47 | /* For faults, return enough to hold the FAULT_STRING */ | 37 | return (ret < 0) ? ret : len; |
| 48 | return (ret < 0) ? strlen(FAULT_STRING) + 1 : len; | | |
| 49 | } | | |
| 50 | | | |
| 51 | static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base, int len) | | |
| 52 | { | | |
| 53 | if (ret >= 0) { | | |
| 54 | *(u32 *)dest = make_data_loc(ret, __dest - base); | | |
| 55 | } else { | | |
| 56 | strscpy(__dest, FAULT_STRING, len); | | |
| 57 | ret = strlen(__dest) + 1; | | |
| 58 | } | | |
| 59 | } | 38 | } |
| 60 | | 39 | |
| 61 | /* | 40 | /* |
| @@ -76,7 +55,8 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base) · 14 unmodified lines |
| 76 | __dest = get_loc_data(dest, base); | 55 | __dest = get_loc_data(dest, base); |
| 77 | | 56 | |
| 78 | ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); | 57 | ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); |
| 79 | set_data_loc(ret, dest, __dest, base, maxlen); | 58 | if (ret >= 0) |
| | 59 | *(u32 *)dest = make_data_loc(ret, __dest - base); |
| 80 | | 60 | |
| 81 | return ret; | 61 | return ret; |
| 82 | } | 62 | } |
| @@ -107,7 +87,8 @@ fetch_store_string(unsigned long addr, void *dest, void *base) · 24 unmodified lines |
| 107 | * probing. | 87 | * probing. |
| 108 | */ | 88 | */ |
| 109 | ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); | 89 | ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); |
| 110 | set_data_loc(ret, dest, __dest, base, maxlen); | 90 | if (ret >= 0) |
| | 91 | *(u32 *)dest = make_data_loc(ret, __dest - base); |
| 111 | | 92 | |
| 112 | return ret; | 93 | return ret; |
| 113 | } | 94 | } |