#ifndef _LTTNG_PROBE_USER_H
#define _LTTNG_PROBE_USER_H
+#include <wrapper/uaccess.h>
+
/*
* 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 */
#include <linux/fs.h>
#include <linux/mm.h>
#include <wrapper/uaccess.h>
+#include <lttng/probe-user.h>
/* Internal helpers */
#include <ringbuffer/backend_internal.h>
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;
+ return lttng_copy_from_user_check_nofault(dest, src, len);
}
#endif /* _LIB_RING_BUFFER_BACKEND_H */