#include <linux/user_namespace.h>
#include <linux/utsname.h>
#include <linux/types.h>
+#include <linux/user_namespace.h>
+
#include <lttng/kernel-version.h>
-#include <wrapper/user_namespace.h>
+
#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0) || \
LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0))
#include <linux/time_namespace.h>
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)
+ ctf_integer(uid_t, vuid, user_ns ? from_kuid_munged(user_ns, task_cred_xxx(p, uid)) : 0)
+ ctf_integer(gid_t, vgid, user_ns ? from_kgid_munged(user_ns, task_cred_xxx(p, gid)) : 0)
#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0))
ctf_integer(int, ns_level, user_ns ? user_ns->level : 0)
#endif
#include <linux/rculist.h>
#include <asm/byteorder.h>
#include <linux/swab.h>
+#include <linux/user_namespace.h>
#include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
#include <ringbuffer/frontend_types.h>
#include <ringbuffer/backend.h>
#include <wrapper/rcu.h>
-#include <wrapper/user_namespace.h>
#include <lttng/types.h>
#include <lttng/probe-user.h>
#include <lttng/events.h>
return; \
__lf = lttng_rcu_dereference(__session->uid_tracker.p); \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
- lttng_current_uid()))) \
+ from_kuid_munged(&init_user_ns, current_uid())))) \
return; \
__lf = lttng_rcu_dereference(__session->vuid_tracker.p); \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
- lttng_current_vuid()))) \
+ from_kuid_munged(current_user_ns(), current_uid())))) \
return; \
__lf = lttng_rcu_dereference(__session->gid_tracker.p); \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
- lttng_current_gid()))) \
+ from_kgid_munged(&init_user_ns, current_gid())))) \
return; \
__lf = lttng_rcu_dereference(__session->vgid_tracker.p); \
if (__lf && likely(!lttng_id_tracker_lookup(__lf, \
- lttng_current_vgid()))) \
+ from_kgid_munged(current_user_ns(), current_gid())))) \
return; \
break; \
} \
+++ /dev/null
-/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
- *
- * wrapper/user_namespace.h
- *
- * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
- *
- */
-
-#ifndef _LTTNG_WRAPPER_USER_NAMESPACE_H
-#define _LTTNG_WRAPPER_USER_NAMESPACE_H
-
-#include <lttng/kernel-version.h>
-#include <linux/user_namespace.h>
-
-
-#if LTTNG_LINUX_VERSION_CODE >= LTTNG_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()))
-
-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())
-
-#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()))
-
-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))
-#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 */
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t egid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t egid;
- egid = lttng_current_egid();
+ egid = from_kgid_munged(&init_user_ns, current_egid());
chan->ops->event_write(ctx, &egid, sizeof(egid), lttng_alignof(egid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_egid();
+ value->u.s64 = from_kgid_munged(&init_user_ns, current_egid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t euid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t euid;
- euid = lttng_current_euid();
+ euid = from_kuid_munged(&init_user_ns, current_euid());
chan->ops->event_write(ctx, &euid, sizeof(euid), lttng_alignof(euid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_euid();
+ value->u.s64 = from_kuid_munged(&init_user_ns, current_euid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t gid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t gid;
- gid = lttng_current_gid();
+ gid = from_kgid_munged(&init_user_ns, current_gid());
chan->ops->event_write(ctx, &gid, sizeof(gid), lttng_alignof(gid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_gid();
+ value->u.s64 = from_kgid_munged(&init_user_ns, current_gid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t sgid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t sgid;
- sgid = lttng_current_sgid();
+ sgid = from_kgid_munged(&init_user_ns, current_sgid());
chan->ops->event_write(ctx, &sgid, sizeof(sgid), lttng_alignof(sgid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_sgid();
+ value->u.s64 = from_kgid_munged(&init_user_ns, current_sgid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t suid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t suid;
- suid = lttng_current_suid();
+ suid = from_kuid_munged(&init_user_ns, current_suid());
chan->ops->event_write(ctx, &suid, sizeof(suid), lttng_alignof(suid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_suid();
+ value->u.s64 = from_kuid_munged(&init_user_ns, current_suid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t uid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t uid;
- uid = lttng_current_uid();
+ uid = from_kuid_munged(&init_user_ns, current_uid());
chan->ops->event_write(ctx, &uid, sizeof(uid), lttng_alignof(uid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_uid();
+ value->u.s64 = from_kuid_munged(&init_user_ns, current_uid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t vegid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t vegid;
- vegid = lttng_current_vegid();
+ vegid = from_kgid_munged(current_user_ns(), current_egid());
chan->ops->event_write(ctx, &vegid, sizeof(vegid), lttng_alignof(vegid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_vegid();
+ value->u.s64 = from_kgid_munged(current_user_ns(), current_egid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t veuid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t veuid;
- veuid = lttng_current_veuid();
+ veuid = from_kuid_munged(current_user_ns(), current_euid());
chan->ops->event_write(ctx, &veuid, sizeof(veuid), lttng_alignof(veuid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_veuid();
+ value->u.s64 = from_kuid_munged(current_user_ns(), current_euid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t vgid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t vgid;
- vgid = lttng_current_vgid();
+ vgid = from_kgid_munged(current_user_ns(), current_gid());
chan->ops->event_write(ctx, &vgid, sizeof(vgid), lttng_alignof(vgid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_vgid();
+ value->u.s64 = from_kgid_munged(current_user_ns(), current_gid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t vsgid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
gid_t vsgid;
- vsgid = lttng_current_vsgid();
+ vsgid = from_kgid_munged(current_user_ns(), current_sgid());
chan->ops->event_write(ctx, &vsgid, sizeof(vsgid), lttng_alignof(vsgid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_vsgid();
+ value->u.s64 = from_kgid_munged(current_user_ns(), current_sgid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t vsuid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t vsuid;
- vsuid = lttng_current_vsuid();
+ vsuid = from_kuid_munged(current_user_ns(), current_suid());
chan->ops->event_write(ctx, &vsuid, sizeof(vsuid), lttng_alignof(vsuid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_vsuid();
+ value->u.s64 = from_kuid_munged(current_user_ns(), current_suid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
#include <linux/module.h>
#include <linux/sched.h>
+#include <linux/user_namespace.h>
+
#include <lttng/events.h>
#include <lttng/events-internal.h>
#include <lttng/tracer.h>
#include <ringbuffer/frontend_types.h>
#include <wrapper/vmalloc.h>
-#include <wrapper/user_namespace.h>
static
size_t vuid_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
{
uid_t vuid;
- vuid = lttng_current_vuid();
+ vuid = from_kuid_munged(current_user_ns(), current_uid());
chan->ops->event_write(ctx, &vuid, sizeof(vuid), lttng_alignof(vuid));
}
struct lttng_kernel_probe_ctx *lttng_probe_ctx,
struct lttng_ctx_value *value)
{
- value->u.s64 = lttng_current_vuid();
+ value->u.s64 = from_kuid_munged(current_user_ns(), current_uid());
}
static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(