40b91461838f7675fbb0dacf0f1d0b147e58d10c
[lttng-modules.git] / include / lttng / probe-user.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * lttng/probe-user.h
4 *
5 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8 #ifndef _LTTNG_PROBE_USER_H
9 #define _LTTNG_PROBE_USER_H
10
11 #include <wrapper/uaccess.h>
12
13 /*
14 * Calculate string length. Include final null terminating character if there is
15 * one, or ends at first fault.
16 */
17 long lttng_strlen_user_inatomic(const char *addr);
18
19 /*
20 * We use __copy_from_user_inatomic to copy userspace data after
21 * checking with access_ok() and disabling page faults.
22 *
23 * Return 0 if OK, nonzero on error.
24 */
25 static inline
26 unsigned long lttng_copy_from_user_check_nofault(void *dest,
27 const void __user *src,
28 unsigned long len)
29 {
30 unsigned long ret;
31
32 if (!lttng_access_ok(VERIFY_READ, src, len))
33 return 1;
34 pagefault_disable();
35 ret = __copy_from_user_inatomic(dest, src, len);
36 pagefault_enable();
37 return ret;
38 }
39
40 #endif /* _LTTNG_PROBE_USER_H */
This page took 0.039699 seconds and 5 git commands to generate.