All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH lttng-modules v2 1/3] RFC: Add namespace contexts
       [not found] <1520369592-10619-1-git-send-email-mjeanson@efficios.com>
@ 2018-03-06 20:53 ` Michael Jeanson
  2018-03-06 20:53 ` [PATCH lttng-modules v2 2/3] RFC: Add uid/gid contexts Michael Jeanson
  2018-03-06 20:53 ` [PATCH lttng-modules v2 3/3] RFC: Add namespaces statedump Michael Jeanson
  2 siblings, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2018-03-06 20:53 UTC (permalink / raw)
  To: lttng-dev

Add a context for each available kernel namespace which currently are :
cgroup, ipc, mnt, net, pid, user and uts. The id chosen to identify the
namespaces is the inode number of the fd representing each of them in
the proc filesystem. This was instroduced in v3.8.0 in this commit :

  commit 98f842e675f96ffac96e6c50315790912b2812be
  Author: Eric W. Biederman <ebiederm@xmission.com>
  Date:   Wed Jun 15 10:21:48 2011 -0700

    proc: Usable inode numbers for the namespace file descriptors.

    Assign a unique proc inode to each namespace, and use that
    inode number to ensure we only allocate at most one proc
    inode for every namespace in proc.

    A single proc inode per namespace allows userspace to test
    to see if two processes are in the same namespace.

    ...

Prior to this there is no unique identifier for a namespace that is
available to both the kernel and userspace.

Per namespace particularities :

  - Cgroup
    - Introduced in 4.6.0
    - CONFIG_CGROUPS

  - IPC
    - Introduced in 2.6.25
    - CONFIG_IPC_NS

  - MNT
    - Introduced in 2.6.20
    - The mnt_namespace struct is defined in a private header

  - NET
    - Introduced in 2.6.24
    - CONFIG_NET_NS

  - PID
    - Introduced in 2.6.20
    - CONFIG_PID_NS

  - User
    - Introduced in 2.6.23
    - CONFIG_USER_NS

  - UTS
    - Introduced in 2.6.19
    - CONFIG_UTS_NS

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
---
 Kbuild.common                               |   5 ++
 Makefile                                    |  26 +++++++
 instrumentation/events/lttng-module/sched.h |  11 +--
 lttng-abi.c                                 |  14 ++++
 lttng-abi.h                                 |   7 ++
 lttng-context-cgroup-ns.c                   | 113 ++++++++++++++++++++++++++++
 lttng-context-ipc-ns.c                      | 110 +++++++++++++++++++++++++++
 lttng-context-mnt-ns.c                      | 111 +++++++++++++++++++++++++++
 lttng-context-net-ns.c                      | 110 +++++++++++++++++++++++++++
 lttng-context-pid-ns.c                      | 106 ++++++++++++++++++++++++++
 lttng-context-user-ns.c                     |  98 ++++++++++++++++++++++++
 lttng-context-uts-ns.c                      | 110 +++++++++++++++++++++++++++
 lttng-context.c                             |  28 +++++++
 lttng-events.h                              |  79 +++++++++++++++++++
 wrapper/namespace.h                         |  33 ++++++++
 15 files changed, 953 insertions(+), 8 deletions(-)
 create mode 100644 lttng-context-cgroup-ns.c
 create mode 100644 lttng-context-ipc-ns.c
 create mode 100644 lttng-context-mnt-ns.c
 create mode 100644 lttng-context-net-ns.c
 create mode 100644 lttng-context-pid-ns.c
 create mode 100644 lttng-context-user-ns.c
 create mode 100644 lttng-context-uts-ns.c
 create mode 100644 wrapper/namespace.h

diff --git a/Kbuild.common b/Kbuild.common
index c0d5409..4bb21ad 100644
--- a/Kbuild.common
+++ b/Kbuild.common
@@ -55,4 +55,9 @@ ifneq ($(CONFIG_DYNAMIC_FTRACE),)
   endif
 endif
 
+mnt_ns_dep = $(srctree)/fs/mount.h
+ifeq ($(wildcard $(mnt_ns_dep)),)
+    ccflags-y += -DLTTNG_MNT_NS_MISSING_HEADER
+endif
+
 # vim:syntax=make
diff --git a/Makefile b/Makefile
index b08f0bf..15f18c4 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,32 @@ ifneq ($(KERNELRELEASE),)
       -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 15 \) ] ; then \
       echo "lttng-tracepoint.o" ; fi;)
 
+  lttng-tracer-objs += lttng-context-cgroup-ns.o
+
+  ifneq ($(CONFIG_IPC_NS),)
+    lttng-tracer-objs += lttng-context-ipc-ns.o
+  endif
+
+  ifneq ($(wildcard $(mnt_ns_dep)),)
+     lttng-tracer-objs += lttng-context-mnt-ns.o
+  endif
+
+  ifneq ($(CONFIG_NET_NS),)
+    lttng-tracer-objs += lttng-context-net-ns.o
+  endif
+
+  ifneq ($(CONFIG_PID_NS),)
+    lttng-tracer-objs += lttng-context-pid-ns.o
+  endif
+
+  ifneq ($(CONFIG_USER_NS),)
+    lttng-tracer-objs += lttng-context-user-ns.o
+  endif
+
+  ifneq ($(CONFIG_UTS_NS),)
+    lttng-tracer-objs += lttng-context-uts-ns.o
+  endif
+
   obj-$(CONFIG_LTTNG) += lttng-statedump.o
   lttng-statedump-objs := lttng-statedump-impl.o wrapper/irqdesc.o \
                           wrapper/fdtable.o
diff --git a/instrumentation/events/lttng-module/sched.h b/instrumentation/events/lttng-module/sched.h
index f5c3669..19c0fe0 100644
--- a/instrumentation/events/lttng-module/sched.h
+++ b/instrumentation/events/lttng-module/sched.h
@@ -12,12 +12,7 @@
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
 #include <linux/sched/rt.h>
 #endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
-#define lttng_proc_inum ns.inum
-#else
-#define lttng_proc_inum proc_inum
-#endif
+#include <wrapper/namespace.h>
 
 #define LTTNG_MAX_PID_NS_LEVEL 32
 
@@ -414,7 +409,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
 					pid_ns = task_active_pid_ns(parent);
 					if (pid_ns)
 						parent_ns_inum =
-							pid_ns->lttng_proc_inum;
+							pid_ns->lttng_ns_inum;
 				}
 				parent_ns_inum;
 			}))
@@ -434,7 +429,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
 					pid_ns = task_active_pid_ns(child);
 					if (pid_ns)
 						child_ns_inum =
-							pid_ns->lttng_proc_inum;
+							pid_ns->lttng_ns_inum;
 				}
 				child_ns_inum;
 			}))
diff --git a/lttng-abi.c b/lttng-abi.c
index ea746c2..1345e93 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -247,6 +247,20 @@ long lttng_abi_add_context(struct file *file,
 		return lttng_add_preemptible_to_ctx(ctx);
 	case LTTNG_KERNEL_CONTEXT_MIGRATABLE:
 		return lttng_add_migratable_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_CGROUP_NS:
+		return lttng_add_cgroup_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_IPC_NS:
+		return lttng_add_ipc_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_MNT_NS:
+		return lttng_add_mnt_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_NET_NS:
+		return lttng_add_net_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_PID_NS:
+		return lttng_add_pid_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_USER_NS:
+		return lttng_add_user_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_UTS_NS:
+		return lttng_add_uts_ns_to_ctx(ctx);
 	default:
 		return -EINVAL;
 	}
diff --git a/lttng-abi.h b/lttng-abi.h
index dac8658..47cacec 100644
--- a/lttng-abi.h
+++ b/lttng-abi.h
@@ -146,6 +146,13 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_PREEMPTIBLE	= 13,
 	LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE	= 14,
 	LTTNG_KERNEL_CONTEXT_MIGRATABLE		= 15,
+	LTTNG_KERNEL_CONTEXT_CGROUP_NS		= 16,
+	LTTNG_KERNEL_CONTEXT_IPC_NS		= 17,
+	LTTNG_KERNEL_CONTEXT_MNT_NS		= 18,
+	LTTNG_KERNEL_CONTEXT_NET_NS		= 19,
+	LTTNG_KERNEL_CONTEXT_PID_NS		= 20,
+	LTTNG_KERNEL_CONTEXT_USER_NS		= 21,
+	LTTNG_KERNEL_CONTEXT_UTS_NS		= 22,
 };
 
 struct lttng_kernel_perf_counter_ctx {
diff --git a/lttng-context-cgroup-ns.c b/lttng-context-cgroup-ns.c
new file mode 100644
index 0000000..124677b
--- /dev/null
+++ b/lttng-context-cgroup-ns.c
@@ -0,0 +1,113 @@
+/*
+ * lttng-context-cgroup-ns.c
+ *
+ * LTTng cgroup namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/cgroup.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_CGROUPS) && \
+	((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \
+	 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
+
+static
+size_t cgroup_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void cgroup_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int cgroup_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		cgroup_ns_inum = 0;
+	else
+		cgroup_ns_inum = current->nsproxy->cgroup_ns->lttng_ns_inum;
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(cgroup_ns_inum));
+	chan->ops->event_write(ctx, &cgroup_ns_inum, sizeof(cgroup_ns_inum));
+}
+
+static
+void cgroup_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int cgroup_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		cgroup_ns_inum = 0;
+	else
+		cgroup_ns_inum = current->nsproxy->cgroup_ns->lttng_ns_inum;
+
+	value->s64 = cgroup_ns_inum;
+}
+
+int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "cgroup_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "cgroup_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = cgroup_ns_get_size;
+	field->record = cgroup_ns_record;
+	field->get_value = cgroup_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_cgroup_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-ipc-ns.c b/lttng-context-ipc-ns.c
new file mode 100644
index 0000000..2c5ef9f
--- /dev/null
+++ b/lttng-context-ipc-ns.c
@@ -0,0 +1,110 @@
+/*
+ * lttng-context-ipc-ns.c
+ *
+ * LTTng ipc namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/ipc_namespace.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_IPC_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+static
+size_t ipc_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void ipc_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int ipc_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		ipc_ns_inum = 0;
+	else
+		ipc_ns_inum = current->nsproxy->ipc_ns->lttng_ns_inum;
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(ipc_ns_inum));
+	chan->ops->event_write(ctx, &ipc_ns_inum, sizeof(ipc_ns_inum));
+}
+
+static
+void ipc_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int ipc_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		ipc_ns_inum = 0;
+	else
+		ipc_ns_inum = current->nsproxy->ipc_ns->lttng_ns_inum;
+	value->s64 = ipc_ns_inum;
+}
+
+int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "ipc_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "ipc_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = ipc_ns_get_size;
+	field->record = ipc_ns_record;
+	field->get_value = ipc_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_ipc_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-mnt-ns.c b/lttng-context-mnt-ns.c
new file mode 100644
index 0000000..8cb301f
--- /dev/null
+++ b/lttng-context-mnt-ns.c
@@ -0,0 +1,111 @@
+/*
+ * lttng-context-mnt-ns.c
+ *
+ * LTTng mount namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+#include <../fs/mount.h>
+
+static
+size_t mnt_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void mnt_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int mnt_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		mnt_ns_inum = 0;
+	else
+		mnt_ns_inum = current->nsproxy->mnt_ns->lttng_ns_inum;
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(mnt_ns_inum));
+	chan->ops->event_write(ctx, &mnt_ns_inum, sizeof(mnt_ns_inum));
+}
+
+static
+void mnt_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int mnt_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		mnt_ns_inum = 0;
+	else
+		mnt_ns_inum = current->nsproxy->mnt_ns->lttng_ns_inum;
+	value->s64 = mnt_ns_inum;
+}
+
+int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "mnt_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "mnt_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = mnt_ns_get_size;
+	field->record = mnt_ns_record;
+	field->get_value = mnt_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_mnt_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-net-ns.c b/lttng-context-net-ns.c
new file mode 100644
index 0000000..ce01da6
--- /dev/null
+++ b/lttng-context-net-ns.c
@@ -0,0 +1,110 @@
+/*
+ * lttng-context-net-ns.c
+ *
+ * LTTng net namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <net/net_namespace.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_NET_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+static
+size_t net_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void net_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int net_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		net_ns_inum = 0;
+	else
+		net_ns_inum = current->nsproxy->net_ns->lttng_ns_inum;
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(net_ns_inum));
+	chan->ops->event_write(ctx, &net_ns_inum, sizeof(net_ns_inum));
+}
+
+static
+void net_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int net_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		net_ns_inum = 0;
+	else
+		net_ns_inum = current->nsproxy->net_ns->lttng_ns_inum;
+	value->s64 = net_ns_inum;
+}
+
+int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "net_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "net_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = net_ns_get_size;
+	field->record = net_ns_record;
+	field->get_value = net_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_net_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-pid-ns.c b/lttng-context-pid-ns.c
new file mode 100644
index 0000000..27c6531
--- /dev/null
+++ b/lttng-context-pid-ns.c
@@ -0,0 +1,106 @@
+/*
+ * lttng-context-pid-ns.c
+ *
+ * LTTng pid namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/pid_namespace.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_PID_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+static
+size_t pid_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void pid_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	struct pid_namespace *ns;
+	unsigned int pid_ns_inum;
+
+	ns = task_active_pid_ns(current);
+
+	if (!ns) {
+		pid_ns_inum = 0;
+	} else {
+		pid_ns_inum = ns->lttng_ns_inum;
+	}
+
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(pid_ns_inum));
+	chan->ops->event_write(ctx, &pid_ns_inum, sizeof(pid_ns_inum));
+}
+
+static
+void pid_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int pid_ns_inum;
+
+	pid_ns_inum = task_active_pid_ns(current)->lttng_ns_inum;
+	value->s64 = pid_ns_inum;
+}
+
+int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "pid_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "pid_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = pid_ns_get_size;
+	field->record = pid_ns_record;
+	field->get_value = pid_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_pid_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-user-ns.c b/lttng-context-user-ns.c
new file mode 100644
index 0000000..1b0f982
--- /dev/null
+++ b/lttng-context-user-ns.c
@@ -0,0 +1,98 @@
+/*
+ * lttng-context-user-ns.c
+ *
+ * LTTng user namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/user_namespace.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_USER_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+static
+size_t user_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void user_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int user_ns_inum;
+
+	user_ns_inum = current_user_ns()->lttng_ns_inum;
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(user_ns_inum));
+	chan->ops->event_write(ctx, &user_ns_inum, sizeof(user_ns_inum));
+}
+
+static
+void user_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int user_ns_inum;
+
+	user_ns_inum = current_user_ns()->lttng_ns_inum;
+	value->s64 = user_ns_inum;
+}
+
+int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "user_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "user_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = user_ns_get_size;
+	field->record = user_ns_record;
+	field->get_value = user_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_user_ns_to_ctx);
+
+#endif
diff --git a/lttng-context-uts-ns.c b/lttng-context-uts-ns.c
new file mode 100644
index 0000000..c6ee151
--- /dev/null
+++ b/lttng-context-uts-ns.c
@@ -0,0 +1,110 @@
+/*
+ * lttng-context-uts-ns.c
+ *
+ * LTTng uts namespace context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/utsname.h>
+#include <lttng-events.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/namespace.h>
+#include <lttng-tracer.h>
+
+#if defined(CONFIG_UTS_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+static
+size_t uts_ns_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+	size += sizeof(unsigned int);
+	return size;
+}
+
+static
+void uts_ns_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	unsigned int uts_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		uts_ns_inum = 0;
+	else
+		uts_ns_inum = current->nsproxy->uts_ns->lttng_ns_inum;
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(uts_ns_inum));
+	chan->ops->event_write(ctx, &uts_ns_inum, sizeof(uts_ns_inum));
+}
+
+static
+void uts_ns_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	unsigned int uts_ns_inum;
+
+	/*
+	 * nsproxy can be NULL when scheduled out of exit.
+	 */
+	if (!current->nsproxy)
+		uts_ns_inum = 0;
+	else
+		uts_ns_inum = current->nsproxy->uts_ns->lttng_ns_inum;
+	value->s64 = uts_ns_inum;
+}
+
+int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "uts_ns")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "uts_ns";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(unsigned int) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(unsigned int);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = uts_ns_get_size;
+	field->record = uts_ns_record;
+	field->get_value = uts_ns_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_uts_ns_to_ctx);
+
+#endif
diff --git a/lttng-context.c b/lttng-context.c
index 544e95f..dc91b8d 100644
--- a/lttng-context.c
+++ b/lttng-context.c
@@ -308,6 +308,34 @@ int lttng_context_init(void)
 	if (ret && ret != -ENOSYS) {
 		printk(KERN_WARNING "Cannot add context lttng_add_migratable_to_ctx");
 	}
+	ret = lttng_add_cgroup_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_cgroup_ns_to_ctx");
+	}
+	ret = lttng_add_ipc_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_ipc_ns_to_ctx");
+	}
+	ret = lttng_add_mnt_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_mnt_ns_to_ctx");
+	}
+	ret = lttng_add_net_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_net_ns_to_ctx");
+	}
+	ret = lttng_add_pid_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_pid_ns_to_ctx");
+	}
+	ret = lttng_add_user_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_user_ns_to_ctx");
+	}
+	ret = lttng_add_uts_ns_to_ctx(&lttng_static_ctx);
+	if (ret && ret != -ENOSYS) {
+		printk(KERN_WARNING "Cannot add context lttng_add_uts_ns_to_ctx");
+	}
 	/* TODO: perf counters for filtering */
 	return 0;
 }
diff --git a/lttng-events.h b/lttng-events.h
index 17dd8d3..f3b2b91 100644
--- a/lttng-events.h
+++ b/lttng-events.h
@@ -702,6 +702,85 @@ int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
 	return -ENOSYS;
 }
 #endif
+
+#if defined(CONFIG_CGROUPS) && \
+	((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \
+	 LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0))
+int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if defined(CONFIG_IPC_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if defined(CONFIG_NET_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if defined(CONFIG_PID_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if defined(CONFIG_USER_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
+#if defined(CONFIG_UTS_NS) && \
+	(LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
+{
+	return -ENOSYS;
+}
+#endif
+
 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,
 				  uint64_t config,
diff --git a/wrapper/namespace.h b/wrapper/namespace.h
new file mode 100644
index 0000000..7e82cba
--- /dev/null
+++ b/wrapper/namespace.h
@@ -0,0 +1,33 @@
+#ifndef _LTTNG_WRAPPER_NAMESPACE_H
+#define _LTTNG_WRAPPER_NAMESPACE_H
+
+/*
+ * wrapper/namespace.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
+#define lttng_ns_inum ns.inum
+#else
+#define lttng_ns_inum proc_inum
+#endif
+
+#endif /* _LTTNG_WRAPPER_NAMESPACE_H */
-- 
2.7.4

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH lttng-modules v2 2/3] RFC: Add uid/gid contexts
       [not found] <1520369592-10619-1-git-send-email-mjeanson@efficios.com>
  2018-03-06 20:53 ` [PATCH lttng-modules v2 1/3] RFC: Add namespace contexts Michael Jeanson
@ 2018-03-06 20:53 ` Michael Jeanson
  2018-03-06 20:53 ` [PATCH lttng-modules v2 3/3] RFC: Add namespaces statedump Michael Jeanson
  2 siblings, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2018-03-06 20:53 UTC (permalink / raw)
  To: lttng-dev

Add a context for each available kernel user and group IDs

  * uid : real user ID
  * euid : effective user ID
  * suid : saved set-user ID

These are the IDs as seen in the initial user namespace, see
credentials(7) for details on each type.

Also add a "virtual" version of each type with the "v" prefix that
are the IDs as seen in the current user namespace.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
---
 Makefile                 | 12 +++++++
 lttng-abi.c              | 24 +++++++++++++
 lttng-abi.h              | 12 +++++++
 lttng-context-egid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-euid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-gid.c      | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-sgid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-suid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-uid.c      | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-vegid.c    | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-veuid.c    | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-vgid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-vsgid.c    | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-vsuid.c    | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-context-vuid.c     | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 lttng-events.h           | 13 +++++++
 wrapper/user_namespace.h | 73 ++++++++++++++++++++++++++++++++++++++
 17 files changed, 1226 insertions(+)
 create mode 100644 lttng-context-egid.c
 create mode 100644 lttng-context-euid.c
 create mode 100644 lttng-context-gid.c
 create mode 100644 lttng-context-sgid.c
 create mode 100644 lttng-context-suid.c
 create mode 100644 lttng-context-uid.c
 create mode 100644 lttng-context-vegid.c
 create mode 100644 lttng-context-veuid.c
 create mode 100644 lttng-context-vgid.c
 create mode 100644 lttng-context-vsgid.c
 create mode 100644 lttng-context-vsuid.c
 create mode 100644 lttng-context-vuid.c
 create mode 100644 wrapper/user_namespace.h

diff --git a/Makefile b/Makefile
index 15f18c4..9ccf44f 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,18 @@ ifneq ($(KERNELRELEASE),)
                        lttng-context-vpid.o lttng-context-tid.o \
                        lttng-context-vtid.o lttng-context-ppid.o \
                        lttng-context-vppid.o lttng-context-cpu-id.o \
+                       lttng-context-uid.o \
+                       lttng-context-euid.o \
+                       lttng-context-suid.o \
+                       lttng-context-gid.o \
+                       lttng-context-egid.o \
+                       lttng-context-sgid.o \
+                       lttng-context-vuid.o \
+                       lttng-context-veuid.o \
+                       lttng-context-vsuid.o \
+                       lttng-context-vgid.o \
+                       lttng-context-vegid.o \
+                       lttng-context-vsgid.o \
                        lttng-context-interruptible.o \
                        lttng-context-need-reschedule.o lttng-calibrate.o \
                        lttng-context-hostname.o wrapper/random.o \
diff --git a/lttng-abi.c b/lttng-abi.c
index 1345e93..d730914 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -261,6 +261,30 @@ long lttng_abi_add_context(struct file *file,
 		return lttng_add_user_ns_to_ctx(ctx);
 	case LTTNG_KERNEL_CONTEXT_UTS_NS:
 		return lttng_add_uts_ns_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_UID:
+		return lttng_add_uid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_EUID:
+		return lttng_add_euid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_SUID:
+		return lttng_add_suid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_GID:
+		return lttng_add_gid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_EGID:
+		return lttng_add_egid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_SGID:
+		return lttng_add_sgid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VUID:
+		return lttng_add_vuid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VEUID:
+		return lttng_add_veuid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VSUID:
+		return lttng_add_vsuid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VGID:
+		return lttng_add_vgid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VEGID:
+		return lttng_add_vegid_to_ctx(ctx);
+	case LTTNG_KERNEL_CONTEXT_VSGID:
+		return lttng_add_vsgid_to_ctx(ctx);
 	default:
 		return -EINVAL;
 	}
diff --git a/lttng-abi.h b/lttng-abi.h
index 47cacec..90b0dcd 100644
--- a/lttng-abi.h
+++ b/lttng-abi.h
@@ -153,6 +153,18 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_PID_NS		= 20,
 	LTTNG_KERNEL_CONTEXT_USER_NS		= 21,
 	LTTNG_KERNEL_CONTEXT_UTS_NS		= 22,
+	LTTNG_KERNEL_CONTEXT_UID		= 23,
+	LTTNG_KERNEL_CONTEXT_EUID		= 24,
+	LTTNG_KERNEL_CONTEXT_SUID		= 25,
+	LTTNG_KERNEL_CONTEXT_GID		= 26,
+	LTTNG_KERNEL_CONTEXT_EGID		= 27,
+	LTTNG_KERNEL_CONTEXT_SGID		= 28,
+	LTTNG_KERNEL_CONTEXT_VUID		= 29,
+	LTTNG_KERNEL_CONTEXT_VEUID		= 30,
+	LTTNG_KERNEL_CONTEXT_VSUID		= 31,
+	LTTNG_KERNEL_CONTEXT_VGID		= 32,
+	LTTNG_KERNEL_CONTEXT_VEGID		= 33,
+	LTTNG_KERNEL_CONTEXT_VSGID		= 34,
 };
 
 struct lttng_kernel_perf_counter_ctx {
diff --git a/lttng-context-egid.c b/lttng-context-egid.c
new file mode 100644
index 0000000..ace7475
--- /dev/null
+++ b/lttng-context-egid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-egid.c
+ *
+ * LTTng effective group ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t egid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void egid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t egid;
+
+	egid = lttng_current_egid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(egid));
+	chan->ops->event_write(ctx, &egid, sizeof(egid));
+}
+
+static
+void egid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t egid;
+
+	egid = lttng_current_egid();
+	value->s64 = egid;
+}
+
+int lttng_add_egid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "egid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "egid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = egid_get_size;
+	field->record = egid_record;
+	field->get_value = egid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_egid_to_ctx);
diff --git a/lttng-context-euid.c b/lttng-context-euid.c
new file mode 100644
index 0000000..f12e96d
--- /dev/null
+++ b/lttng-context-euid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-euid.c
+ *
+ * LTTng effective user ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t euid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void euid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t euid;
+
+	euid = lttng_current_euid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(euid));
+	chan->ops->event_write(ctx, &euid, sizeof(euid));
+}
+
+static
+void euid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t euid;
+
+	euid = lttng_current_euid();
+	value->s64 = euid;
+}
+
+int lttng_add_euid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "euid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "euid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = euid_get_size;
+	field->record = euid_record;
+	field->get_value = euid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_euid_to_ctx);
diff --git a/lttng-context-gid.c b/lttng-context-gid.c
new file mode 100644
index 0000000..c31c00f
--- /dev/null
+++ b/lttng-context-gid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-gid.c
+ *
+ * LTTng real group ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t gid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void gid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t gid;
+
+	gid = lttng_current_gid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(gid));
+	chan->ops->event_write(ctx, &gid, sizeof(gid));
+}
+
+static
+void gid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t gid;
+
+	gid = lttng_current_gid();
+	value->s64 = gid;
+}
+
+int lttng_add_gid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "gid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "gid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = gid_get_size;
+	field->record = gid_record;
+	field->get_value = gid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_gid_to_ctx);
diff --git a/lttng-context-sgid.c b/lttng-context-sgid.c
new file mode 100644
index 0000000..7d3ce2f
--- /dev/null
+++ b/lttng-context-sgid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-sgid.c
+ *
+ * LTTng saved set-group-ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t sgid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void sgid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t sgid;
+
+	sgid = lttng_current_sgid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(sgid));
+	chan->ops->event_write(ctx, &sgid, sizeof(sgid));
+}
+
+static
+void sgid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t sgid;
+
+	sgid = lttng_current_sgid();
+	value->s64 = sgid;
+}
+
+int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "sgid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "sgid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = sgid_get_size;
+	field->record = sgid_record;
+	field->get_value = sgid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_sgid_to_ctx);
diff --git a/lttng-context-suid.c b/lttng-context-suid.c
new file mode 100644
index 0000000..2f13dd5
--- /dev/null
+++ b/lttng-context-suid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-suid.c
+ *
+ * LTTng saved set-user-ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t suid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void suid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t suid;
+
+	suid = lttng_current_suid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(suid));
+	chan->ops->event_write(ctx, &suid, sizeof(suid));
+}
+
+static
+void suid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t suid;
+
+	suid = lttng_current_suid();
+	value->s64 = suid;
+}
+
+int lttng_add_suid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "suid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "suid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = suid_get_size;
+	field->record = suid_record;
+	field->get_value = suid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_suid_to_ctx);
diff --git a/lttng-context-uid.c b/lttng-context-uid.c
new file mode 100644
index 0000000..089bfd0
--- /dev/null
+++ b/lttng-context-uid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-uid.c
+ *
+ * LTTng real user ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t uid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void uid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t uid;
+
+	uid = lttng_current_uid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(uid));
+	chan->ops->event_write(ctx, &uid, sizeof(uid));
+}
+
+static
+void uid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t uid;
+
+	uid = lttng_current_uid();
+	value->s64 = uid;
+}
+
+int lttng_add_uid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "uid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "uid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = uid_get_size;
+	field->record = uid_record;
+	field->get_value = uid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_uid_to_ctx);
diff --git a/lttng-context-vegid.c b/lttng-context-vegid.c
new file mode 100644
index 0000000..ec33bb0
--- /dev/null
+++ b/lttng-context-vegid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-vegid.c
+ *
+ * LTTng namespaced effective group ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t vegid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void vegid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t vegid;
+
+	vegid = lttng_current_vegid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(vegid));
+	chan->ops->event_write(ctx, &vegid, sizeof(vegid));
+}
+
+static
+void vegid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t vegid;
+
+	vegid = lttng_current_vegid();
+	value->s64 = vegid;
+}
+
+int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "vegid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "vegid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = vegid_get_size;
+	field->record = vegid_record;
+	field->get_value = vegid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vegid_to_ctx);
diff --git a/lttng-context-veuid.c b/lttng-context-veuid.c
new file mode 100644
index 0000000..4a620c6
--- /dev/null
+++ b/lttng-context-veuid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-veuid.c
+ *
+ * LTTng namespaced effective user ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t veuid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void veuid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t veuid;
+
+	veuid = lttng_current_veuid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(veuid));
+	chan->ops->event_write(ctx, &veuid, sizeof(veuid));
+}
+
+static
+void veuid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t veuid;
+
+	veuid = lttng_current_veuid();
+	value->s64 = veuid;
+}
+
+int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "veuid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "veuid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = veuid_get_size;
+	field->record = veuid_record;
+	field->get_value = veuid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_veuid_to_ctx);
diff --git a/lttng-context-vgid.c b/lttng-context-vgid.c
new file mode 100644
index 0000000..b26eebb
--- /dev/null
+++ b/lttng-context-vgid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-vgid.c
+ *
+ * LTTng namespaced real group ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t vgid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void vgid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t vgid;
+
+	vgid = lttng_current_vgid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(vgid));
+	chan->ops->event_write(ctx, &vgid, sizeof(vgid));
+}
+
+static
+void vgid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t vgid;
+
+	vgid = lttng_current_vgid();
+	value->s64 = vgid;
+}
+
+int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "vgid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "vgid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = vgid_get_size;
+	field->record = vgid_record;
+	field->get_value = vgid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vgid_to_ctx);
diff --git a/lttng-context-vsgid.c b/lttng-context-vsgid.c
new file mode 100644
index 0000000..1b65918
--- /dev/null
+++ b/lttng-context-vsgid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-vsgid.c
+ *
+ * LTTng namespaced saved set-group-ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t vsgid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(gid_t));
+	size += sizeof(gid_t);
+	return size;
+}
+
+static
+void vsgid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	gid_t vsgid;
+
+	vsgid = lttng_current_vsgid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(vsgid));
+	chan->ops->event_write(ctx, &vsgid, sizeof(vsgid));
+}
+
+static
+void vsgid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	gid_t vsgid;
+
+	vsgid = lttng_current_vsgid();
+	value->s64 = vsgid;
+}
+
+int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "vsgid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "vsgid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(gid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = vsgid_get_size;
+	field->record = vsgid_record;
+	field->get_value = vsgid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vsgid_to_ctx);
diff --git a/lttng-context-vsuid.c b/lttng-context-vsuid.c
new file mode 100644
index 0000000..ac0721e
--- /dev/null
+++ b/lttng-context-vsuid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-vsuid.c
+ *
+ * LTTng namespaced saved set-user-ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t vsuid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void vsuid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t vsuid;
+
+	vsuid = lttng_current_vsuid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(vsuid));
+	chan->ops->event_write(ctx, &vsuid, sizeof(vsuid));
+}
+
+static
+void vsuid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t vsuid;
+
+	vsuid = lttng_current_vsuid();
+	value->s64 = vsuid;
+}
+
+int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "vsuid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "vsuid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = vsuid_get_size;
+	field->record = vsuid_record;
+	field->get_value = vsuid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vsuid_to_ctx);
diff --git a/lttng-context-vuid.c b/lttng-context-vuid.c
new file mode 100644
index 0000000..4852ea7
--- /dev/null
+++ b/lttng-context-vuid.c
@@ -0,0 +1,91 @@
+/*
+ * lttng-context-vuid.c
+ *
+ * LTTng namespaced real user ID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *               2018 Michael Jeanson <mjeanson@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/module.h>
+#include <linux/sched.h>
+#include <lttng-events.h>
+#include <lttng-tracer.h>
+#include <wrapper/ringbuffer/frontend_types.h>
+#include <wrapper/vmalloc.h>
+#include <wrapper/user_namespace.h>
+
+static
+size_t vuid_get_size(size_t offset)
+{
+	size_t size = 0;
+
+	size += lib_ring_buffer_align(offset, lttng_alignof(uid_t));
+	size += sizeof(uid_t);
+	return size;
+}
+
+static
+void vuid_record(struct lttng_ctx_field *field,
+		 struct lib_ring_buffer_ctx *ctx,
+		 struct lttng_channel *chan)
+{
+	uid_t vuid;
+
+	vuid = lttng_current_vuid();
+	lib_ring_buffer_align_ctx(ctx, lttng_alignof(vuid));
+	chan->ops->event_write(ctx, &vuid, sizeof(vuid));
+}
+
+static
+void vuid_get_value(struct lttng_ctx_field *field,
+		struct lttng_probe_ctx *lttng_probe_ctx,
+		union lttng_ctx_value *value)
+{
+	uid_t vuid;
+
+	vuid = lttng_current_vuid();
+	value->s64 = vuid;
+}
+
+int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx)
+{
+	struct lttng_ctx_field *field;
+
+	field = lttng_append_context(ctx);
+	if (!field)
+		return -ENOMEM;
+	if (lttng_find_context(*ctx, "vuid")) {
+		lttng_remove_context_field(ctx, field);
+		return -EEXIST;
+	}
+	field->event_field.name = "vuid";
+	field->event_field.type.atype = atype_integer;
+	field->event_field.type.u.basic.integer.size = sizeof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
+	field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uid_t);
+	field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+	field->event_field.type.u.basic.integer.base = 10;
+	field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+	field->get_size = vuid_get_size;
+	field->record = vuid_record;
+	field->get_value = vuid_get_value;
+	lttng_context_update(*ctx);
+	wrapper_vmalloc_sync_all();
+	return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vuid_to_ctx);
diff --git a/lttng-events.h b/lttng-events.h
index f3b2b91..b43b560 100644
--- a/lttng-events.h
+++ b/lttng-events.h
@@ -781,6 +781,19 @@ int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx)
 }
 #endif
 
+int lttng_add_uid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_euid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_suid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_gid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_egid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx);
+
 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,
 				  uint64_t config,
diff --git a/wrapper/user_namespace.h b/wrapper/user_namespace.h
new file mode 100644
index 0000000..f1f4181
--- /dev/null
+++ b/wrapper/user_namespace.h
@@ -0,0 +1,73 @@
+#ifndef _LTTNG_WRAPPER_USER_NAMESPACE_H
+#define _LTTNG_WRAPPER_USER_NAMESPACE_H
+
+/*
+ * wrapper/user_namespace.h
+ *
+ * Copyright (C) 2018 Michael Jeanson <mjeanson@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/version.h>
+#include <linux/user_namespace.h>
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+
+#define lttng_current_xxuid(xxx)				\
+	(from_kuid_munged(&init_user_ns, current_##xxx()))
+
+#define lttng_current_vxxuid(xxx)				\
+	(from_kuid_munged(current_user_ns(), current_##xxx()))
+
+#define lttng_current_xxgid(xxx)				\
+	(from_kgid_munged(&init_user_ns, current_##xxx()))
+
+#define lttng_current_vxxgid(xxx)				\
+	(from_kgid_munged(current_user_ns(), current_##xxx()))
+
+#else
+
+#define lttng_current_xxuid(xxx)	(current_##xxx())
+
+#define lttng_current_vxxuid(xxx)					\
+	(user_ns_map_uid(current_user_ns(), current_cred(), current_##xxx()))
+
+#define lttng_current_xxgid(xxx)	(current_##xxx())
+
+#define lttng_current_vxxgid(xxx)					\
+	(user_ns_map_gid(current_user_ns(), current_cred(), current_##xxx()))
+#endif
+
+#define lttng_current_uid()	(lttng_current_xxuid(uid))
+#define lttng_current_euid()	(lttng_current_xxuid(euid))
+#define lttng_current_suid()	(lttng_current_xxuid(suid))
+#define lttng_current_fsuid()	(lttng_current_xxuid(fsuid))
+#define lttng_current_gid()	(lttng_current_xxgid(gid))
+#define lttng_current_egid()	(lttng_current_xxgid(egid))
+#define lttng_current_sgid()	(lttng_current_xxgid(sgid))
+#define lttng_current_fsgid()	(lttng_current_xxgid(fsgid))
+
+#define lttng_current_vuid()	(lttng_current_vxxuid(uid))
+#define lttng_current_veuid()	(lttng_current_vxxuid(euid))
+#define lttng_current_vsuid()	(lttng_current_vxxuid(suid))
+#define lttng_current_vfsuid()	(lttng_current_vxxuid(fsuid))
+#define lttng_current_vgid()	(lttng_current_vxxgid(gid))
+#define lttng_current_vegid()	(lttng_current_vxxgid(egid))
+#define lttng_current_vsgid()	(lttng_current_vxxgid(sgid))
+#define lttng_current_vfsgid()	(lttng_current_vxxgid(fsgid))
+
+#endif /* _LTTNG_WRAPPER_USER_NAMESPACE_H */
-- 
2.7.4



_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH lttng-modules v2 3/3] RFC: Add namespaces statedump
       [not found] <1520369592-10619-1-git-send-email-mjeanson@efficios.com>
  2018-03-06 20:53 ` [PATCH lttng-modules v2 1/3] RFC: Add namespace contexts Michael Jeanson
  2018-03-06 20:53 ` [PATCH lttng-modules v2 2/3] RFC: Add uid/gid contexts Michael Jeanson
@ 2018-03-06 20:53 ` Michael Jeanson
  2 siblings, 0 replies; 3+ messages in thread
From: Michael Jeanson @ 2018-03-06 20:53 UTC (permalink / raw)
  To: lttng-dev

Add a statedump event for each type of namespace.

The pid ns was already implemented as part of the lttng_statedump_process_state
event, move the "vtid" and "vpid" fields to the new
lttng_statedump_process_pid_ns event.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
---
 .../events/lttng-module/lttng-statedump.h          | 137 ++++++++++++++++++---
 lttng-statedump-impl.c                             |  72 ++++++++++-
 wrapper/namespace.h                                |   6 +
 wrapper/user_namespace.h                           |  55 +++++++++
 4 files changed, 250 insertions(+), 20 deletions(-)

diff --git a/instrumentation/events/lttng-module/lttng-statedump.h b/instrumentation/events/lttng-module/lttng-statedump.h
index e7c528d..c315acd 100644
--- a/instrumentation/events/lttng-module/lttng-statedump.h
+++ b/instrumentation/events/lttng-module/lttng-statedump.h
@@ -6,15 +6,22 @@
 
 #include <probes/lttng-tracepoint-event.h>
 #include <linux/nsproxy.h>
+#include <linux/cgroup.h>
+#include <linux/ipc_namespace.h>
+#include <net/net_namespace.h>
 #include <linux/pid_namespace.h>
+#include <linux/user_namespace.h>
+#include <linux/utsname.h>
 #include <linux/types.h>
 #include <linux/version.h>
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
-#define lttng_proc_inum ns.inum
-#else
-#define lttng_proc_inum proc_inum
+#include <wrapper/namespace.h>
+#include <wrapper/user_namespace.h>
+
+#ifndef LTTNG_MNT_NS_MISSING_HEADER
+# ifndef ONCE_LTTNG_FS_MOUNT_H
+#  define ONCE_LTTNG_FS_MOUNT_H
+#  include <../fs/mount.h>
+# endif
 #endif
 
 LTTNG_TRACEPOINT_EVENT(lttng_statedump_start,
@@ -32,14 +39,11 @@ LTTNG_TRACEPOINT_EVENT(lttng_statedump_end,
 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state,
 	TP_PROTO(struct lttng_session *session,
 		struct task_struct *p,
-		int type, int mode, int submode, int status,
-		struct pid_namespace *pid_ns),
-	TP_ARGS(session, p, type, mode, submode, status, pid_ns),
+		int type, int mode, int submode, int status),
+	TP_ARGS(session, p, type, mode, submode, status),
 	TP_FIELDS(
 		ctf_integer(pid_t, tid, p->pid)
-		ctf_integer(pid_t, vtid, pid_ns ? task_pid_nr_ns(p, pid_ns) : 0)
 		ctf_integer(pid_t, pid, p->tgid)
-		ctf_integer(pid_t, vpid, pid_ns ? task_tgid_nr_ns(p, pid_ns) : 0)
 		ctf_integer(pid_t, ppid,
 			({
 				pid_t ret;
@@ -49,6 +53,78 @@ LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state,
 				rcu_read_unlock();
 				ret;
 			}))
+		ctf_array_text(char, name, p->comm, TASK_COMM_LEN)
+		ctf_integer(int, type, type)
+		ctf_integer(int, mode, mode)
+		ctf_integer(int, submode, submode)
+		ctf_integer(int, status, status)
+		ctf_integer(unsigned int, cpu, task_cpu(p))
+	)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_cgroup_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct cgroup_namespace *cgroup_ns),
+	TP_ARGS(session, p, cgroup_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+		ctf_integer(unsigned int, ns_inum, cgroup_ns ? cgroup_ns->lttng_ns_inum : 0)
+	)
+)
+#endif
+
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_ipc_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct ipc_namespace *ipc_ns),
+	TP_ARGS(session, p, ipc_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+		ctf_integer(unsigned int, ns_inum, ipc_ns ? ipc_ns->lttng_ns_inum : 0)
+#endif
+	)
+)
+
+#if !defined(LTTNG_MNT_NS_MISSING_HEADER)
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_mnt_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct mnt_namespace *mnt_ns),
+	TP_ARGS(session, p, mnt_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+		ctf_integer(unsigned int, ns_inum, mnt_ns ? mnt_ns->lttng_ns_inum : 0)
+#endif
+	)
+)
+#endif
+
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_net_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct net *net_ns),
+	TP_ARGS(session, p, net_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+		ctf_integer(unsigned int, ns_inum, net_ns ? net_ns->lttng_ns_inum : 0)
+#endif
+	)
+)
+
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_pid_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct pid_namespace *pid_ns),
+	TP_ARGS(session, p, pid_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+		ctf_integer(pid_t, vtid, pid_ns ? task_pid_nr_ns(p, pid_ns) : 0)
+		ctf_integer(pid_t, vpid, pid_ns ? task_tgid_nr_ns(p, pid_ns) : 0)
 		ctf_integer(pid_t, vppid,
 			({
 				struct task_struct *parent;
@@ -62,16 +138,41 @@ LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state,
 				}
 				ret;
 			}))
-		ctf_array_text(char, name, p->comm, TASK_COMM_LEN)
-		ctf_integer(int, type, type)
-		ctf_integer(int, mode, mode)
-		ctf_integer(int, submode, submode)
-		ctf_integer(int, status, status)
 		ctf_integer(int, ns_level, pid_ns ? pid_ns->level : 0)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
-		ctf_integer(unsigned int, ns_inum, pid_ns ? pid_ns->lttng_proc_inum : 0)
+		ctf_integer(unsigned int, ns_inum, pid_ns ? pid_ns->lttng_ns_inum : 0)
+#endif
+	)
+)
+
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_user_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct user_namespace *user_ns),
+	TP_ARGS(session, p, user_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+		ctf_integer(uid_t, vuid, user_ns ? lttng_task_vuid(p, user_ns) : 0)
+		ctf_integer(gid_t, vgid, user_ns ? lttng_task_vgid(p, user_ns) : 0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+		ctf_integer(int, ns_level, user_ns ? user_ns->level : 0)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+		ctf_integer(unsigned int, ns_inum, user_ns ? user_ns->lttng_ns_inum : 0)
+#endif
+	)
+)
+
+LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_uts_ns,
+	TP_PROTO(struct lttng_session *session,
+		struct task_struct *p,
+		struct uts_namespace *uts_ns),
+	TP_ARGS(session, p, uts_ns),
+	TP_FIELDS(
+		ctf_integer(pid_t, tid, p->pid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+		ctf_integer(unsigned int, ns_inum, uts_ns ? uts_ns->lttng_ns_inum : 0)
 #endif
-		ctf_integer(unsigned int, cpu, task_cpu(p))
 	)
 )
 
diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c
index 1c09e51..479bc47 100644
--- a/lttng-statedump-impl.c
+++ b/lttng-statedump-impl.c
@@ -52,6 +52,7 @@
 #include <wrapper/irqdesc.h>
 #include <wrapper/spinlock.h>
 #include <wrapper/fdtable.h>
+#include <wrapper/namespace.h>
 #include <wrapper/irq.h>
 #include <wrapper/tracepoint.h>
 #include <wrapper/genhd.h>
@@ -75,6 +76,17 @@ DEFINE_TRACE(lttng_statedump_interrupt);
 DEFINE_TRACE(lttng_statedump_file_descriptor);
 DEFINE_TRACE(lttng_statedump_start);
 DEFINE_TRACE(lttng_statedump_process_state);
+DEFINE_TRACE(lttng_statedump_process_pid_ns);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+DEFINE_TRACE(lttng_statedump_process_cgroup_ns);
+#endif
+DEFINE_TRACE(lttng_statedump_process_ipc_ns);
+#ifndef LTTNG_MNT_NS_MISSING_HEADER
+DEFINE_TRACE(lttng_statedump_process_mnt_ns);
+#endif
+DEFINE_TRACE(lttng_statedump_process_net_ns);
+DEFINE_TRACE(lttng_statedump_process_user_ns);
+DEFINE_TRACE(lttng_statedump_process_uts_ns);
 DEFINE_TRACE(lttng_statedump_network_interface);
 
 struct lttng_fd_ctx {
@@ -381,6 +393,10 @@ int lttng_list_interrupts(struct lttng_session *session)
 #endif
 
 /*
+ * Statedump the task's namespaces using the proc filesystem inode number as
+ * the unique identifier. The user and pid ns are nested and will be dumped
+ * recursively.
+ *
  * Called with task lock held.
  */
 static
@@ -391,14 +407,62 @@ void lttng_statedump_process_ns(struct lttng_session *session,
 		enum lttng_execution_submode submode,
 		enum lttng_process_status status)
 {
+	struct nsproxy *proxy;
 	struct pid_namespace *pid_ns;
+	struct user_namespace *user_ns;
 
+	/*
+	 * The pid and user namespaces are special, they are nested and
+	 * accessed with specific functions instead of the nsproxy struct
+	 * like the other namespaces.
+	 */
 	pid_ns = task_active_pid_ns(p);
 	do {
-		trace_lttng_statedump_process_state(session,
-			p, type, mode, submode, status, pid_ns);
+		trace_lttng_statedump_process_pid_ns(session, p, pid_ns);
 		pid_ns = pid_ns->parent;
 	} while (pid_ns);
+
+
+	user_ns = task_cred_xxx(p, user_ns);
+	do {
+		trace_lttng_statedump_process_user_ns(session, p, user_ns);
+		user_ns = user_ns->lttng_user_ns_parent;
+	} while (user_ns);
+
+	/*
+	 * Back and forth on locking strategy within Linux upstream for nsproxy.
+	 * See Linux upstream commit 728dba3a39c66b3d8ac889ddbe38b5b1c264aec3
+	 * "namespaces: Use task_lock and not rcu to protect nsproxy"
+	 * for details.
+	 */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) || \
+		LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,36, 3,14,0,0) || \
+		LTTNG_UBUNTU_KERNEL_RANGE(3,16,1,11, 3,17,0,0) || \
+		LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,13,0, 3,11,0,0,0,0))
+	proxy = p->nsproxy;
+#else
+	rcu_read_lock();
+	proxy = task_nsproxy(p);
+#endif
+	if (proxy) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+		trace_lttng_statedump_process_cgroup_ns(session, p, proxy->cgroup_ns);
+#endif
+		trace_lttng_statedump_process_ipc_ns(session, p, proxy->ipc_ns);
+#ifndef LTTNG_MNT_NS_MISSING_HEADER
+		trace_lttng_statedump_process_mnt_ns(session, p, proxy->mnt_ns);
+#endif
+		trace_lttng_statedump_process_net_ns(session, p, proxy->net_ns);
+		trace_lttng_statedump_process_uts_ns(session, p, proxy->uts_ns);
+	}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0) || \
+		LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,36, 3,14,0,0) || \
+		LTTNG_UBUNTU_KERNEL_RANGE(3,16,1,11, 3,17,0,0) || \
+		LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,13,0, 3,11,0,0,0,0))
+	/* (nothing) */
+#else
+	rcu_read_unlock();
+#endif
 }
 
 static
@@ -450,6 +514,10 @@ int lttng_enumerate_process_states(struct lttng_session *session)
 				type = LTTNG_USER_THREAD;
 			else
 				type = LTTNG_KERNEL_THREAD;
+
+			trace_lttng_statedump_process_state(session,
+				p, type, mode, submode, status);
+
 			lttng_statedump_process_ns(session,
 				p, type, mode, submode, status);
 			task_unlock(p);
diff --git a/wrapper/namespace.h b/wrapper/namespace.h
index 7e82cba..977f14e 100644
--- a/wrapper/namespace.h
+++ b/wrapper/namespace.h
@@ -30,4 +30,10 @@
 #define lttng_ns_inum proc_inum
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+#define lttng_user_ns_parent parent
+#else
+#define lttng_user_ns_parent creator->user_ns
+#endif
+
 #endif /* _LTTNG_WRAPPER_NAMESPACE_H */
diff --git a/wrapper/user_namespace.h b/wrapper/user_namespace.h
index f1f4181..f0fa770 100644
--- a/wrapper/user_namespace.h
+++ b/wrapper/user_namespace.h
@@ -39,6 +39,30 @@
 #define lttng_current_vxxgid(xxx)				\
 	(from_kgid_munged(current_user_ns(), current_##xxx()))
 
+static inline
+uid_t lttng_task_vuid(struct task_struct *p, struct user_namespace *ns)
+{
+	uid_t uid;
+	kuid_t kuid;
+
+	kuid = task_cred_xxx(p, uid);
+	uid = from_kuid_munged(ns, kuid);
+
+	return uid;
+}
+
+static inline
+gid_t lttng_task_vgid(struct task_struct *p, struct user_namespace *ns)
+{
+	gid_t gid;
+	kgid_t kgid;
+
+	kgid = task_cred_xxx(p, gid);
+	gid = from_kgid_munged(ns, kgid);
+
+	return gid;
+}
+
 #else
 
 #define lttng_current_xxuid(xxx)	(current_##xxx())
@@ -50,6 +74,37 @@
 
 #define lttng_current_vxxgid(xxx)					\
 	(user_ns_map_gid(current_user_ns(), current_cred(), current_##xxx()))
+
+static inline
+uid_t lttng_task_vuid(struct task_struct *p, struct user_namespace *ns)
+{
+	uid_t uid;
+
+	/*
+	 * __task_cred requires the RCU readlock be held
+	 */
+	rcu_read_lock();
+	uid = user_ns_map_uid(ns, __task_cred(p), __task_cred(p)->uid);
+	rcu_read_unlock();
+
+	return uid;
+}
+
+static inline
+gid_t lttng_task_vgid(struct task_struct *p, struct user_namespace *ns)
+{
+	gid_t gid;
+
+	/*
+	 * __task_cred requires the RCU readlock be held
+	 */
+	rcu_read_lock();
+	gid = user_ns_map_gid(ns, __task_cred(p), __task_cred(p)->gid);
+	rcu_read_unlock();
+
+	return gid;
+}
+
 #endif
 
 #define lttng_current_uid()	(lttng_current_xxuid(uid))
-- 
2.7.4

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-06 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1520369592-10619-1-git-send-email-mjeanson@efficios.com>
2018-03-06 20:53 ` [PATCH lttng-modules v2 1/3] RFC: Add namespace contexts Michael Jeanson
2018-03-06 20:53 ` [PATCH lttng-modules v2 2/3] RFC: Add uid/gid contexts Michael Jeanson
2018-03-06 20:53 ` [PATCH lttng-modules v2 3/3] RFC: Add namespaces statedump Michael Jeanson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.