Lines Matching full:user

38  * Limits how many trace_event calls user processes can create:
59 * status of the event wanting tracing or not to user-programs via shared
69 * probes to print out to the user.
71 * These do not reflect the mapped bytes between the user and kernel space.
80 * matching page for status checks within user programs. This
81 * allows for isolation of events to user programs by various
146 typedef void (*user_event_func_t) (struct user_event *user, struct iov_iter *i,
275 void user_event_register_set(struct user_event *user) in user_event_register_set() argument
277 int i = user->index; in user_event_register_set()
279 user->group->register_page_data[MAP_STATUS_BYTE(i)] |= MAP_STATUS_MASK(i); in user_event_register_set()
283 void user_event_register_clear(struct user_event *user) in user_event_register_clear() argument
285 int i = user->index; in user_event_register_clear()
287 user->group->register_page_data[MAP_STATUS_BYTE(i)] &= ~MAP_STATUS_MASK(i); in user_event_register_clear()
291 bool user_event_last_ref(struct user_event *user) in user_event_last_ref() argument
293 return refcount_read(&user->refcnt) == 1; in user_event_last_ref()
312 struct user_event *user = (struct user_event *)call->data; in user_event_get_fields() local
314 return &user->fields; in user_event_get_fields()
325 * NOTE: Offsets are from the user data perspective, they are not from the
327 * sizes to the offset for the user.
380 /* long is not allowed from a user, since it's ambigious in size */ in user_field_size()
422 static void user_event_destroy_validators(struct user_event *user) in user_event_destroy_validators() argument
425 struct list_head *head = &user->validators; in user_event_destroy_validators()
433 static void user_event_destroy_fields(struct user_event *user) in user_event_destroy_fields() argument
436 struct list_head *head = &user->fields; in user_event_destroy_fields()
444 static int user_event_add_field(struct user_event *user, const char *type, in user_event_add_field() argument
482 list_add_tail(&validator->link, &user->validators); in user_event_add_field()
492 list_add(&field->link, &user->fields); in user_event_add_field()
495 * Min size from user writes that are required, this does not include in user_event_add_field()
498 user->min_size = (offset + size) - sizeof(struct trace_entry); in user_event_add_field()
507 static int user_event_parse_field(char *field, struct user_event *user, in user_event_parse_field() argument
594 return user_event_add_field(user, type, name, saved_offset, size, in user_event_parse_field()
598 static int user_event_parse_fields(struct user_event *user, char *args) in user_event_parse_fields() argument
608 ret = user_event_parse_field(field, user, &offset); in user_event_parse_fields()
716 static int user_event_set_print_fmt(struct user_event *user, char *buf, int len) in user_event_set_print_fmt() argument
719 struct list_head *head = &user->fields; in user_event_set_print_fmt()
750 static int user_event_create_print_fmt(struct user_event *user) in user_event_create_print_fmt() argument
755 len = user_event_set_print_fmt(user, NULL, 0); in user_event_create_print_fmt()
762 user_event_set_print_fmt(user, print_fmt, len); in user_event_create_print_fmt()
764 user->call.print_fmt = print_fmt; in user_event_create_print_fmt()
773 /* Unsafe to try to decode user provided print_fmt, use hex */ in user_event_print_trace()
784 static int user_event_set_call_visible(struct user_event *user, bool visible) in user_event_set_call_visible() argument
809 ret = trace_add_event_call(&user->call); in user_event_set_call_visible()
811 ret = trace_remove_event_call(&user->call); in user_event_set_call_visible()
819 static int destroy_user_event(struct user_event *user) in destroy_user_event() argument
824 user_event_destroy_fields(user); in destroy_user_event()
826 ret = user_event_set_call_visible(user, false); in destroy_user_event()
831 dyn_event_remove(&user->devent); in destroy_user_event()
833 user_event_register_clear(user); in destroy_user_event()
834 clear_bit(user->index, user->group->page_bitmap); in destroy_user_event()
835 hash_del(&user->node); in destroy_user_event()
837 user_event_destroy_validators(user); in destroy_user_event()
838 kfree(user->call.print_fmt); in destroy_user_event()
839 kfree(EVENT_NAME(user)); in destroy_user_event()
840 kfree(user); in destroy_user_event()
848 struct user_event *user; in find_user_event() local
853 hash_for_each_possible(group->register_table, user, node, key) in find_user_event()
854 if (!strcmp(EVENT_NAME(user), name)) { in find_user_event()
855 refcount_inc(&user->refcnt); in find_user_event()
856 return user; in find_user_event()
862 static int user_event_validate(struct user_event *user, void *data, int len) in user_event_validate() argument
864 struct list_head *head = &user->validators; in user_event_validate()
896 * Writes the user supplied payload out to a trace file.
898 static void user_event_ftrace(struct user_event *user, struct iov_iter *i, in user_event_ftrace() argument
922 if (!list_empty(&user->validators) && in user_event_ftrace()
923 unlikely(user_event_validate(user, entry, size))) in user_event_ftrace()
937 * Writes the user supplied payload out to perf ring buffer.
939 static void user_event_perf(struct user_event *user, struct iov_iter *i, in user_event_perf() argument
944 perf_head = this_cpu_ptr(user->call.perf_events); in user_event_perf()
963 if (!list_empty(&user->validators) && in user_event_perf()
964 unlikely(user_event_validate(user, perf_entry, size))) in user_event_perf()
968 user->call.event.type, 1, regs, in user_event_perf()
980 * Update the register page that is shared between user processes.
982 static void update_reg_page_for(struct user_event *user) in update_reg_page_for() argument
984 struct tracepoint *tp = &user->tracepoint; in update_reg_page_for()
1014 user_event_register_set(user); in update_reg_page_for()
1016 user_event_register_clear(user); in update_reg_page_for()
1018 user->status = status; in update_reg_page_for()
1028 struct user_event *user = (struct user_event *)call->data; in user_event_reg() local
1031 if (!user) in user_event_reg()
1074 refcount_inc(&user->refcnt); in user_event_reg()
1075 update_reg_page_for(user); in user_event_reg()
1078 update_reg_page_for(user); in user_event_reg()
1079 refcount_dec(&user->refcnt); in user_event_reg()
1086 struct user_event *user; in user_event_create() local
1110 ret = user_event_parse_cmd(group, name, &user); in user_event_create()
1113 refcount_dec(&user->refcnt); in user_event_create()
1125 struct user_event *user = container_of(ev, struct user_event, devent); in user_event_show() local
1130 seq_printf(m, "%s%s", USER_EVENTS_PREFIX, EVENT_NAME(user)); in user_event_show()
1132 head = trace_get_fields(&user->call); in user_event_show()
1155 struct user_event *user = container_of(ev, struct user_event, devent); in user_event_is_busy() local
1157 return !user_event_last_ref(user); in user_event_is_busy()
1162 struct user_event *user = container_of(ev, struct user_event, devent); in user_event_free() local
1164 if (!user_event_last_ref(user)) in user_event_free()
1167 return destroy_user_event(user); in user_event_free()
1207 static bool user_fields_match(struct user_event *user, int argc, in user_fields_match() argument
1211 struct list_head *head = &user->fields; in user_fields_match()
1227 struct user_event *user = container_of(ev, struct user_event, devent); in user_event_match() local
1230 match = strcmp(EVENT_NAME(user), event) == 0 && in user_event_match()
1234 match = user_fields_match(user, argc, argv); in user_event_match()
1247 static int user_event_trace_register(struct user_event *user) in user_event_trace_register() argument
1251 ret = register_trace_event(&user->call.event); in user_event_trace_register()
1256 ret = user_event_set_call_visible(user, true); in user_event_trace_register()
1259 unregister_trace_event(&user->call.event); in user_event_trace_register()
1276 struct user_event *user; in user_event_parse() local
1280 user = find_user_event(group, name, &key); in user_event_parse()
1283 if (user) { in user_event_parse()
1284 *newuser = user; in user_event_parse()
1298 user = kzalloc(sizeof(*user), GFP_KERNEL); in user_event_parse()
1300 if (!user) in user_event_parse()
1303 INIT_LIST_HEAD(&user->class.fields); in user_event_parse()
1304 INIT_LIST_HEAD(&user->fields); in user_event_parse()
1305 INIT_LIST_HEAD(&user->validators); in user_event_parse()
1307 user->group = group; in user_event_parse()
1308 user->tracepoint.name = name; in user_event_parse()
1310 ret = user_event_parse_fields(user, args); in user_event_parse()
1315 ret = user_event_create_print_fmt(user); in user_event_parse()
1320 user->call.data = user; in user_event_parse()
1321 user->call.class = &user->class; in user_event_parse()
1322 user->call.name = name; in user_event_parse()
1323 user->call.flags = TRACE_EVENT_FL_TRACEPOINT; in user_event_parse()
1324 user->call.tp = &user->tracepoint; in user_event_parse()
1325 user->call.event.funcs = &user_event_funcs; in user_event_parse()
1326 user->class.system = group->system_name; in user_event_parse()
1328 user->class.fields_array = user_event_fields_array; in user_event_parse()
1329 user->class.get_fields = user_event_get_fields; in user_event_parse()
1330 user->class.reg = user_event_reg; in user_event_parse()
1331 user->class.probe = user_event_ftrace; in user_event_parse()
1333 user->class.perf_probe = user_event_perf; in user_event_parse()
1338 ret = user_event_trace_register(user); in user_event_parse()
1343 user->index = index; in user_event_parse()
1346 refcount_set(&user->refcnt, 2); in user_event_parse()
1348 dyn_event_init(&user->devent, &user_event_dops); in user_event_parse()
1349 dyn_event_add(&user->devent, &user->call); in user_event_parse()
1350 set_bit(user->index, group->page_bitmap); in user_event_parse()
1351 hash_add(group->register_table, &user->node, key); in user_event_parse()
1355 *newuser = user; in user_event_parse()
1360 user_event_destroy_fields(user); in user_event_parse()
1361 user_event_destroy_validators(user); in user_event_parse()
1362 kfree(user); in user_event_parse()
1372 struct user_event *user = find_user_event(group, name, &key); in delete_user_event() local
1374 if (!user) in delete_user_event()
1377 refcount_dec(&user->refcnt); in delete_user_event()
1379 if (!user_event_last_ref(user)) in delete_user_event()
1382 return destroy_user_event(user); in delete_user_event()
1386 * Validates the user payload and writes via iterator.
1392 struct user_event *user = NULL; in user_events_write_core() local
1406 * added. But the user retrieved from indexing into the events array in user_events_write_core()
1410 user = refs->events[idx]; in user_events_write_core()
1414 if (unlikely(user == NULL)) in user_events_write_core()
1417 if (unlikely(i->count < user->min_size)) in user_events_write_core()
1420 tp = &user->tracepoint; in user_events_write_core()
1447 probe_func(user, &copy, tpdata, &faulted); in user_events_write_core()
1504 struct user_event *user) in user_events_ref_add() argument
1517 if (refs->events[i] == user) in user_events_ref_add()
1533 new_refs->events[i] = user; in user_events_ref_add()
1535 refcount_inc(&user->refcnt); in user_events_ref_add()
1572 * Registers a user_event on behalf of a user process.
1579 struct user_event *user; in user_events_ioctl_reg() local
1596 ret = user_event_parse_cmd(info->group, name, &user); in user_events_ioctl_reg()
1603 ret = user_events_ref_add(info, user); in user_events_ioctl_reg()
1606 refcount_dec(&user->refcnt); in user_events_ioctl_reg()
1613 put_user(user->index, &ureg->status_bit); in user_events_ioctl_reg()
1619 * Deletes a user_event on behalf of a user process.
1644 * Handles the ioctl from user mode to register or alter operations.
1671 * Handles the final close of the file from user mode.
1678 struct user_event *user; in user_events_release() local
1703 user = refs->events[i]; in user_events_release()
1705 if (user) in user_events_release()
1706 refcount_dec(&user->refcnt); in user_events_release()
1738 * Maps the shared page into the user process for checking if event is enabled.
1780 struct user_event *user; in user_seq_show() local
1789 hash_for_each(group->register_table, i, user, node) { in user_seq_show()
1790 status = user->status; in user_seq_show()
1791 flags = user->flags; in user_seq_show()
1793 seq_printf(m, "%d:%s", user->index, EVENT_NAME(user)); in user_seq_show()
1861 * Creates a set of tracefs files to allow user mode interactions.