fix: use user ns wrapper code in new id trackers
[lttng-modules.git] / probes / lttng-tracepoint-event-impl.h
index 0fee61aea756b677ca99d12be76328316b3f7f58..321cdfa44c61afac7d79c857e4655bf47cc98737 100644 (file)
@@ -1,22 +1,9 @@
-/*
+/* 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>
@@ -32,6 +19,7 @@
 #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>
@@ -1140,7 +1128,7 @@ static void __event_probe__##_name(void *__data, _proto)                \
        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;                                                       \
@@ -1150,8 +1138,27 @@ static void __event_probe__##_name(void *__data, _proto)               \
                return;                                                       \
        if (unlikely(!READ_ONCE(__event->enabled)))                           \
                return;                                                       \
-       __lpf = lttng_rcu_dereference(__session->pid_tracker);                \
-       if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid))) \
+       __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;                                                       \
+       __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(&lttng_dynamic_len_stack)->offset; \
        __dynamic_len_idx = __orig_dynamic_len_offset;                        \
@@ -1214,7 +1221,7 @@ static void __event_probe__##_name(void *__data)                        \
        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;                                                       \
@@ -1224,8 +1231,27 @@ static void __event_probe__##_name(void *__data)                       \
                return;                                                       \
        if (unlikely(!READ_ONCE(__event->enabled)))                           \
                return;                                                       \
-       __lpf = lttng_rcu_dereference(__session->pid_tracker);                \
-       if (__lpf && likely(!lttng_pid_tracker_lookup(__lpf, current->tgid)))  \
+       __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;                                                       \
+       __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(&lttng_dynamic_len_stack)->offset; \
        __dynamic_len_idx = __orig_dynamic_len_offset;                        \
This page took 0.026447 seconds and 4 git commands to generate.