X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Fprobe-user.h;h=40b91461838f7675fbb0dacf0f1d0b147e58d10c;hb=9f2d2694cf0655682a1f0c29a7f3b868680524a5;hp=6b7f38dc98afdea2fa006fee0f8504c25c8c5e24;hpb=3b4aafcbbef722c5d04f2fe06a47c47d4d23eda0;p=lttng-modules.git diff --git a/include/lttng/probe-user.h b/include/lttng/probe-user.h index 6b7f38dc..40b91461 100644 --- a/include/lttng/probe-user.h +++ b/include/lttng/probe-user.h @@ -8,10 +8,33 @@ #ifndef _LTTNG_PROBE_USER_H #define _LTTNG_PROBE_USER_H +#include + /* * Calculate string length. Include final null terminating character if there is * one, or ends at first fault. */ long lttng_strlen_user_inatomic(const char *addr); +/* + * We use __copy_from_user_inatomic to copy userspace data after + * checking with access_ok() and disabling page faults. + * + * Return 0 if OK, nonzero on error. + */ +static inline +unsigned long lttng_copy_from_user_check_nofault(void *dest, + const void __user *src, + unsigned long len) +{ + unsigned long ret; + + if (!lttng_access_ok(VERIFY_READ, src, len)) + return 1; + pagefault_disable(); + ret = __copy_from_user_inatomic(dest, src, len); + pagefault_enable(); + return ret; +} + #endif /* _LTTNG_PROBE_USER_H */