From: Michael Jeanson Date: Tue, 12 Feb 2019 16:51:42 +0000 (-0500) Subject: Add kernel uid/gid contexts X-Git-Tag: v2.12.0-rc1~286 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=499cbfa121fa1bc9ea78294f26b274b35fbc5e0a;p=lttng-tools.git Add kernel uid/gid contexts Add the following kernel tracer context fields: - uid Real user ID - euid Effective user ID - uid Real user ID - suid Saved set-user ID - gid Real group ID - egid Effective group ID - sgid Effective saved set-user group ID - vuid Virtual real user ID: real user ID as seen from the point of view of the current user namespace - veuid Virtual effective user ID: effective user ID as seen from the point of view of the current user namespace - vsuid Virtual saved set-user ID: saved set-user ID as seen from the point of view of the current user namespace - vgid Virtual real group ID: real group ID as seen from the point of view of the current user namespace - vegid Virtual effective group ID: effective group ID as seen from the point of view of the current user namespace - vsgid Virtual saved set-group ID: saved set-group ID as seen from the point of view of the current user namespace Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/event.h b/include/lttng/event.h index 35c8d96f5..451a43351 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -153,6 +153,18 @@ enum lttng_event_context_type { LTTNG_EVENT_CONTEXT_PID_NS = 26, LTTNG_EVENT_CONTEXT_USER_NS = 27, LTTNG_EVENT_CONTEXT_UTS_NS = 28, + LTTNG_EVENT_CONTEXT_UID = 29, + LTTNG_EVENT_CONTEXT_EUID = 30, + LTTNG_EVENT_CONTEXT_SUID = 31, + LTTNG_EVENT_CONTEXT_GID = 32, + LTTNG_EVENT_CONTEXT_EGID = 33, + LTTNG_EVENT_CONTEXT_SGID = 34, + LTTNG_EVENT_CONTEXT_VUID = 35, + LTTNG_EVENT_CONTEXT_VEUID = 36, + LTTNG_EVENT_CONTEXT_VSUID = 37, + LTTNG_EVENT_CONTEXT_VGID = 38, + LTTNG_EVENT_CONTEXT_VEGID = 39, + LTTNG_EVENT_CONTEXT_VSGID = 40, }; enum lttng_event_field_type { diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 8f473cd3f..1bb7310a6 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -288,6 +288,42 @@ int context_kernel_add(struct ltt_kernel_session *ksession, case LTTNG_EVENT_CONTEXT_UTS_NS: kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_UTS_NS; break; + case LTTNG_EVENT_CONTEXT_UID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_UID; + break; + case LTTNG_EVENT_CONTEXT_EUID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_EUID; + break; + case LTTNG_EVENT_CONTEXT_SUID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_SUID; + break; + case LTTNG_EVENT_CONTEXT_GID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_GID; + break; + case LTTNG_EVENT_CONTEXT_EGID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_EGID; + break; + case LTTNG_EVENT_CONTEXT_SGID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_SGID; + break; + case LTTNG_EVENT_CONTEXT_VUID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VUID; + break; + case LTTNG_EVENT_CONTEXT_VEUID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VEUID; + break; + case LTTNG_EVENT_CONTEXT_VSUID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VSUID; + break; + case LTTNG_EVENT_CONTEXT_VGID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VGID; + break; + case LTTNG_EVENT_CONTEXT_VEGID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VEGID; + break; + case LTTNG_EVENT_CONTEXT_VSGID: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VSGID; + break; default: ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 6c7ca6757..cb8a6b060 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -315,6 +315,42 @@ const char *get_kernel_context_type_string( case LTTNG_KERNEL_CONTEXT_UTS_NS: context_type_string = config_event_context_uts_ns; break; + case LTTNG_KERNEL_CONTEXT_UID: + context_type_string = config_event_context_uid; + break; + case LTTNG_KERNEL_CONTEXT_EUID: + context_type_string = config_event_context_euid; + break; + case LTTNG_KERNEL_CONTEXT_SUID: + context_type_string = config_event_context_suid; + break; + case LTTNG_KERNEL_CONTEXT_GID: + context_type_string = config_event_context_gid; + break; + case LTTNG_KERNEL_CONTEXT_EGID: + context_type_string = config_event_context_egid; + break; + case LTTNG_KERNEL_CONTEXT_SGID: + context_type_string = config_event_context_sgid; + break; + case LTTNG_KERNEL_CONTEXT_VUID: + context_type_string = config_event_context_vuid; + break; + case LTTNG_KERNEL_CONTEXT_VEUID: + context_type_string = config_event_context_veuid; + break; + case LTTNG_KERNEL_CONTEXT_VSUID: + context_type_string = config_event_context_vsuid; + break; + case LTTNG_KERNEL_CONTEXT_VGID: + context_type_string = config_event_context_vgid; + break; + case LTTNG_KERNEL_CONTEXT_VEGID: + context_type_string = config_event_context_vegid; + break; + case LTTNG_KERNEL_CONTEXT_VSGID: + context_type_string = config_event_context_vsgid; + break; default: context_type_string = NULL; } diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index a9ef0ddad..9fcb16d6e 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -93,6 +93,18 @@ enum context_type { CONTEXT_PID_NS = 26, CONTEXT_USER_NS = 27, CONTEXT_UTS_NS = 28, + CONTEXT_UID = 29, + CONTEXT_EUID = 30, + CONTEXT_SUID = 31, + CONTEXT_GID = 32, + CONTEXT_EGID = 33, + CONTEXT_SGID = 34, + CONTEXT_VUID = 35, + CONTEXT_VEUID = 36, + CONTEXT_VSUID = 37, + CONTEXT_VGID = 38, + CONTEXT_VEGID = 39, + CONTEXT_VSGID = 40, }; /* @@ -260,6 +272,18 @@ const struct ctx_opts { { "pid_ns", CONTEXT_PID_NS }, { "user_ns", CONTEXT_USER_NS }, { "uts_ns", CONTEXT_UTS_NS }, + { "uid", CONTEXT_UID }, + { "euid", CONTEXT_EUID }, + { "suid", CONTEXT_SUID }, + { "gid", CONTEXT_GID }, + { "egid", CONTEXT_EGID }, + { "sgid", CONTEXT_SGID }, + { "vuid", CONTEXT_VUID }, + { "veuid", CONTEXT_VEUID }, + { "vsuid", CONTEXT_VSUID }, + { "vgid", CONTEXT_VGID }, + { "vegid", CONTEXT_VEGID }, + { "vsgid", CONTEXT_VSGID }, /* Perf options */ diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h index ced35254d..12dfe600c 100644 --- a/src/common/config/config-session-abi.h +++ b/src/common/config/config-session-abi.h @@ -158,5 +158,17 @@ extern const char * const config_event_context_net_ns; extern const char * const config_event_context_pid_ns; extern const char * const config_event_context_user_ns; extern const char * const config_event_context_uts_ns; +extern const char * const config_event_context_uid; +extern const char * const config_event_context_euid; +extern const char * const config_event_context_suid; +extern const char * const config_event_context_gid; +extern const char * const config_event_context_egid; +extern const char * const config_event_context_sgid; +extern const char * const config_event_context_vuid; +extern const char * const config_event_context_veuid; +extern const char * const config_event_context_vsuid; +extern const char * const config_event_context_vgid; +extern const char * const config_event_context_vegid; +extern const char * const config_event_context_vsgid; #endif /* CONFIG_SESSION_INTERNAL_H */ diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index 01f39d8be..c2ae5e120 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -212,6 +212,18 @@ LTTNG_HIDDEN const char * const config_event_context_net_ns = "NET_NS"; LTTNG_HIDDEN const char * const config_event_context_pid_ns = "PID_NS"; LTTNG_HIDDEN const char * const config_event_context_user_ns = "USER_NS"; LTTNG_HIDDEN const char * const config_event_context_uts_ns = "UTS_NS"; +LTTNG_HIDDEN const char * const config_event_context_uid = "UID"; +LTTNG_HIDDEN const char * const config_event_context_euid = "EUID"; +LTTNG_HIDDEN const char * const config_event_context_suid = "SUID"; +LTTNG_HIDDEN const char * const config_event_context_gid = "GID"; +LTTNG_HIDDEN const char * const config_event_context_egid = "EGID"; +LTTNG_HIDDEN const char * const config_event_context_sgid = "SGID"; +LTTNG_HIDDEN const char * const config_event_context_vuid = "VUID"; +LTTNG_HIDDEN const char * const config_event_context_veuid = "VEUID"; +LTTNG_HIDDEN const char * const config_event_context_vsuid = "VSUID"; +LTTNG_HIDDEN const char * const config_event_context_vgid = "VGID"; +LTTNG_HIDDEN const char * const config_event_context_vegid = "VEGID"; +LTTNG_HIDDEN const char * const config_event_context_vsgid = "VSGID"; /* Deprecated symbols */ const char * const config_element_perf; @@ -1075,6 +1087,42 @@ int get_context_type(xmlChar *context_type) } else if (!strcmp((char *) context_type, config_event_context_uts_ns)) { ret = LTTNG_EVENT_CONTEXT_UTS_NS; + } else if (!strcmp((char *) context_type, + config_event_context_uid)) { + ret = LTTNG_EVENT_CONTEXT_UID; + } else if (!strcmp((char *) context_type, + config_event_context_euid)) { + ret = LTTNG_EVENT_CONTEXT_EUID; + } else if (!strcmp((char *) context_type, + config_event_context_suid)) { + ret = LTTNG_EVENT_CONTEXT_SUID; + } else if (!strcmp((char *) context_type, + config_event_context_gid)) { + ret = LTTNG_EVENT_CONTEXT_GID; + } else if (!strcmp((char *) context_type, + config_event_context_egid)) { + ret = LTTNG_EVENT_CONTEXT_EGID; + } else if (!strcmp((char *) context_type, + config_event_context_sgid)) { + ret = LTTNG_EVENT_CONTEXT_SGID; + } else if (!strcmp((char *) context_type, + config_event_context_vuid)) { + ret = LTTNG_EVENT_CONTEXT_VUID; + } else if (!strcmp((char *) context_type, + config_event_context_veuid)) { + ret = LTTNG_EVENT_CONTEXT_VEUID; + } else if (!strcmp((char *) context_type, + config_event_context_vsuid)) { + ret = LTTNG_EVENT_CONTEXT_VSUID; + } else if (!strcmp((char *) context_type, + config_event_context_vgid)) { + ret = LTTNG_EVENT_CONTEXT_VGID; + } else if (!strcmp((char *) context_type, + config_event_context_vegid)) { + ret = LTTNG_EVENT_CONTEXT_VEGID; + } else if (!strcmp((char *) context_type, + config_event_context_vsgid)) { + ret = LTTNG_EVENT_CONTEXT_VSGID; } else { goto error; } diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index be7de5268..4008b50cf 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -73,6 +73,18 @@ enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_PID_NS = 22, LTTNG_KERNEL_CONTEXT_USER_NS = 23, LTTNG_KERNEL_CONTEXT_UTS_NS = 24, + LTTNG_KERNEL_CONTEXT_UID = 25, + LTTNG_KERNEL_CONTEXT_EUID = 26, + LTTNG_KERNEL_CONTEXT_SUID = 27, + LTTNG_KERNEL_CONTEXT_GID = 28, + LTTNG_KERNEL_CONTEXT_EGID = 29, + LTTNG_KERNEL_CONTEXT_SGID = 30, + LTTNG_KERNEL_CONTEXT_VUID = 31, + LTTNG_KERNEL_CONTEXT_VEUID = 32, + LTTNG_KERNEL_CONTEXT_VSUID = 33, + LTTNG_KERNEL_CONTEXT_VGID = 34, + LTTNG_KERNEL_CONTEXT_VEGID = 35, + LTTNG_KERNEL_CONTEXT_VSGID = 36, }; /* Perf counter attributes */