Skip to content

Commit

Permalink
evl/thread: use canonical way of updating current->comm
Browse files Browse the repository at this point in the history
Updating tsk->comm requires holding the task lock, along with
propagating the change to a few subsystems (e.g. trace, perf). Use
set_task_comm() to update such field instead of open coding the change
in a half baked way. Also, make sure such change is forwarded to the
process event connector.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
  • Loading branch information
pgerum committed Sep 23, 2024
1 parent cf3904a commit c01074b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/evl/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/err.h>
#include <linux/ptrace.h>
#include <linux/math64.h>
#include <linux/cn_proc.h>
#include <uapi/linux/sched/types.h>
#include <evl/sched.h>
#include <evl/timer.h>
Expand Down Expand Up @@ -2386,6 +2387,7 @@ thread_factory_build(struct evl_factory *fac, const char __user *u_name,
struct evl_observable *observable = NULL;
struct task_struct *tsk = current;
struct evl_init_thread_attr iattr;
unsigned char comm[sizeof(tsk->comm)];
struct evl_thread *curr;
int ret;

Expand Down Expand Up @@ -2464,9 +2466,10 @@ thread_factory_build(struct evl_factory *fac, const char __user *u_name,
*/
evl_get_element(&curr->element);

strncpy(tsk->comm, evl_element_name(&curr->element),
sizeof(tsk->comm));
tsk->comm[sizeof(tsk->comm) - 1] = '\0';
strncpy(comm, evl_element_name(&curr->element), sizeof(comm));
comm[sizeof(comm) - 1] = '\0';
set_task_comm(tsk, comm);
proc_comm_connector(tsk);

return &curr->element;

Expand Down

0 comments on commit c01074b

Please sign in to comment.