[lttng-dev] [PATCH lttng-tools 3/4] RFC: Add kernel uid/gid contexts

Michael Jeanson mjeanson at efficios.com
Tue Mar 6 15:53:51 EST 2018


Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 include/lttng/event.h                  | 12 +++++++++
 src/bin/lttng-sessiond/context.c       | 36 +++++++++++++++++++++++++
 src/bin/lttng-sessiond/save.c          | 36 +++++++++++++++++++++++++
 src/bin/lttng/commands/add_context.c   | 24 +++++++++++++++++
 src/common/config/config-session-abi.h | 12 +++++++++
 src/common/config/session-config.c     | 48 ++++++++++++++++++++++++++++++++++
 src/common/lttng-kernel.h              | 12 +++++++++
 7 files changed, 180 insertions(+)

diff --git a/include/lttng/event.h b/include/lttng/event.h
index 44edd52..b19d5f9 100644
--- a/include/lttng/event.h
+++ b/include/lttng/event.h
@@ -149,6 +149,18 @@ enum lttng_event_context_type {
 	LTTNG_EVENT_CONTEXT_PID_NS		= 24,
 	LTTNG_EVENT_CONTEXT_USER_NS		= 25,
 	LTTNG_EVENT_CONTEXT_UTS_NS		= 26,
+	LTTNG_EVENT_CONTEXT_UID			= 27,
+	LTTNG_EVENT_CONTEXT_EUID		= 28,
+	LTTNG_EVENT_CONTEXT_SUID		= 29,
+	LTTNG_EVENT_CONTEXT_GID			= 30,
+	LTTNG_EVENT_CONTEXT_EGID		= 31,
+	LTTNG_EVENT_CONTEXT_SGID		= 32,
+	LTTNG_EVENT_CONTEXT_VUID		= 33,
+	LTTNG_EVENT_CONTEXT_VEUID		= 34,
+	LTTNG_EVENT_CONTEXT_VSUID		= 35,
+	LTTNG_EVENT_CONTEXT_VGID		= 36,
+	LTTNG_EVENT_CONTEXT_VEGID		= 37,
+	LTTNG_EVENT_CONTEXT_VSGID		= 38,
 };
 
 enum lttng_event_field_type {
diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c
index 14f2180..5121134 100644
--- a/src/bin/lttng-sessiond/context.c
+++ b/src/bin/lttng-sessiond/context.c
@@ -280,6 +280,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 cf8c830..9550774 100644
--- a/src/bin/lttng-sessiond/save.c
+++ b/src/bin/lttng-sessiond/save.c
@@ -306,6 +306,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 1e9977f..c1a4c3e 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -91,6 +91,18 @@ enum context_type {
 	CONTEXT_PID_NS       = 24,
 	CONTEXT_USER_NS      = 25,
 	CONTEXT_UTS_NS       = 26,
+	CONTEXT_UID          = 27,
+	CONTEXT_EUID         = 28,
+	CONTEXT_SUID         = 29,
+	CONTEXT_GID          = 30,
+	CONTEXT_EGID         = 31,
+	CONTEXT_SGID         = 32,
+	CONTEXT_VUID         = 33,
+	CONTEXT_VEUID        = 34,
+	CONTEXT_VSUID        = 35,
+	CONTEXT_VGID         = 36,
+	CONTEXT_VEGID        = 37,
+	CONTEXT_VSGID        = 38,
 };
 
 /*
@@ -254,6 +266,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 d1c51c0c..5ca27ac 100644
--- a/src/common/config/config-session-abi.h
+++ b/src/common/config/config-session-abi.h
@@ -136,5 +136,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 130a095..dcbb32c 100644
--- a/src/common/config/session-config.c
+++ b/src/common/config/session-config.c
@@ -186,6 +186,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;
@@ -1041,6 +1053,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 a55baee..2a548da 100644
--- a/src/common/lttng-kernel.h
+++ b/src/common/lttng-kernel.h
@@ -65,6 +65,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,
 };
 
 /* Perf counter attributes */
-- 
2.7.4



More information about the lttng-dev mailing list