1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
5 * LTTng saved set-user-ID context.
7 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * 2019 Michael Jeanson <mjeanson@efficios.com>
12 #include <linux/module.h>
13 #include <linux/sched.h>
14 #include <lttng/events.h>
15 #include <lttng/tracer.h>
16 #include <ringbuffer/frontend_types.h>
17 #include <wrapper/vmalloc.h>
18 #include <wrapper/user_namespace.h>
21 size_t suid_get_size(size_t offset
)
25 size
+= lib_ring_buffer_align(offset
, lttng_alignof(uid_t
));
26 size
+= sizeof(uid_t
);
31 void suid_record(struct lttng_ctx_field
*field
,
32 struct lib_ring_buffer_ctx
*ctx
,
33 struct lttng_channel
*chan
)
37 suid
= lttng_current_suid();
38 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(suid
));
39 chan
->ops
->event_write(ctx
, &suid
, sizeof(suid
));
43 void suid_get_value(struct lttng_ctx_field
*field
,
44 struct lttng_probe_ctx
*lttng_probe_ctx
,
45 union lttng_ctx_value
*value
)
47 value
->s64
= lttng_current_suid();
50 int lttng_add_suid_to_ctx(struct lttng_ctx
**ctx
)
52 struct lttng_ctx_field
*field
;
54 field
= lttng_append_context(ctx
);
57 if (lttng_find_context(*ctx
, "suid")) {
58 lttng_remove_context_field(ctx
, field
);
61 field
->event_field
.name
= "suid";
62 field
->event_field
.type
.atype
= atype_integer
;
63 field
->event_field
.type
.u
.integer
.size
= sizeof(uid_t
) * CHAR_BIT
;
64 field
->event_field
.type
.u
.integer
.alignment
= lttng_alignof(uid_t
) * CHAR_BIT
;
65 field
->event_field
.type
.u
.integer
.signedness
= lttng_is_signed_type(uid_t
);
66 field
->event_field
.type
.u
.integer
.reverse_byte_order
= 0;
67 field
->event_field
.type
.u
.integer
.base
= 10;
68 field
->event_field
.type
.u
.integer
.encoding
= lttng_encode_none
;
69 field
->get_size
= suid_get_size
;
70 field
->record
= suid_record
;
71 field
->get_value
= suid_get_value
;
72 lttng_context_update(*ctx
);
73 wrapper_vmalloc_sync_mappings();
76 EXPORT_SYMBOL_GPL(lttng_add_suid_to_ctx
);
This page took 0.051566 seconds and 4 git commands to generate.