1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
5 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 #include <linux/uaccess.h>
9 #include <linux/module.h>
10 #include <probes/lttng-probe-user.h>
13 * Calculate string length. Include final null terminating character if there is
14 * one, or ends at first fault. Disabling page faults ensures that we can safely
15 * call this from pretty much any context, including those where the caller
16 * holds mmap_sem, or any lock which nests in mmap_sem.
18 long lttng_strlen_user_inatomic(const char *addr
)
33 if (unlikely(!access_ok((__force
const char __user
*) addr
,
36 ret
= __copy_from_user_inatomic(&v
,
37 (__force
const char __user
*)(addr
),
39 if (unlikely(ret
> 0))
50 EXPORT_SYMBOL_GPL(lttng_strlen_user_inatomic
);