-/*
+/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
+ *
* lttng-tracepoint-event-impl.h
*
* Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
* Copyright (C) 2009-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <linux/uaccess.h>
#include <probes/lttng.h>
#include <probes/lttng-types.h>
#include <probes/lttng-probe-user.h>
-#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_all() */
+#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <wrapper/ringbuffer/frontend_types.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/rcu.h>
+#include <wrapper/user_namespace.h>
#include <lttng-events.h>
#include <lttng-tracer-core.h>
#include <lttng-tp-mempool.h>
},
#undef _ctf_array_encoded
-#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
+#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
{ \
.name = #_item, \
.type = \
{ \
.array = \
{ \
- .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \
+ .elem_type = __type_integer(_type, 0, 0, 0, _byte_order, _base, _encoding), \
.length = _length, \
} \
} \
.name = #_item, \
.type = \
{ \
- .atype = atype_array, \
+ .atype = atype_array_bitfield, \
.u = \
{ \
.array = \
.name = #_item, \
.type = \
{ \
- .atype = atype_sequence, \
+ .atype = atype_sequence_bitfield, \
.u = \
{ \
.sequence = \
__event_len += sizeof(_type);
#undef _ctf_array_encoded
-#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
+#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
__event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
__event_len += sizeof(_type) * (_length);
#undef _ctf_array_bitfield
#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
- _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+ _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
#undef _ctf_array_encoded
-#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
+#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
{ \
unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \
const void *__ctf_tmp_ptr = (_src); \
#undef _ctf_array_bitfield
#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
- _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+ _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
__event_align = max_t(size_t, __event_align, lttng_alignof(_type));
#undef _ctf_array_encoded
-#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
+#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
__event_align = max_t(size_t, __event_align, lttng_alignof(_type));
#undef _ctf_array_bitfield
#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
- _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+ _ctf_array_encoded(_type, _item, _src, _length, none, __LITTLE_ENDIAN, 0, _user, _nowrite)
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_ctf_integer_ext_isuser##_user(_type, _item, _user_src, _byte_order, _base, _nowrite)
#undef _ctf_array_encoded
-#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
+#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
if (_user) { \
__chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
struct probe_local_vars __tp_locvar; \
struct probe_local_vars *tp_locvar __attribute__((unused)) = \
&__tp_locvar; \
- struct lttng_pid_tracker *__lpf; \
+ struct lttng_id_tracker_rcu *__lf; \
\
if (!_TP_SESSION_CHECK(session, __session)) \
return; \
- if (unlikely(!READ_ONCE(__session->active))) \
+ if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
+ return; \
+ if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
+ return; \
+ if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
return; \
- if (unlikely(!READ_ONCE(__chan->enabled))) \
+ __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
return; \
- if (unlikely(!READ_ONCE(__event->enabled))) \
+ __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
return; \
- __lpf = lttng_rcu_dereference(__session->pid_tracker); \
- if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid))) \
+ __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_uid()))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_vuid()))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_gid()))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_vgid()))) \
return; \
__orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
__dynamic_len_idx = __orig_dynamic_len_offset; \
struct probe_local_vars __tp_locvar; \
struct probe_local_vars *tp_locvar __attribute__((unused)) = \
&__tp_locvar; \
- struct lttng_pid_tracker *__lpf; \
+ struct lttng_id_tracker_rcu *__lf; \
\
if (!_TP_SESSION_CHECK(session, __session)) \
return; \
- if (unlikely(!READ_ONCE(__session->active))) \
+ if (unlikely(!LTTNG_READ_ONCE(__session->active))) \
+ return; \
+ if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \
+ return; \
+ if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->pid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->vpid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, task_tgid_vnr(current)))) \
+ return; \
+ __lf = lttng_rcu_dereference(__session->uid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_uid()))) \
return; \
- if (unlikely(!READ_ONCE(__chan->enabled))) \
+ __lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_vuid()))) \
return; \
- if (unlikely(!READ_ONCE(__event->enabled))) \
+ __lf = lttng_rcu_dereference(__session->gid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_gid()))) \
return; \
- __lpf = lttng_rcu_dereference(__session->pid_tracker); \
- if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->pid))) \
+ __lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
+ if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
+ lttng_current_vgid()))) \
return; \
__orig_dynamic_len_offset = this_cpu_ptr(<tng_dynamic_len_stack)->offset; \
__dynamic_len_idx = __orig_dynamic_len_offset; \
#ifndef TP_MODULE_NOINIT
static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
{
- wrapper_vmalloc_sync_all();
+ wrapper_vmalloc_sync_mappings();
return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
}