diff options
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -923,6 +923,15 @@ char *get_task_comm(char *buf, struct task_struct *tsk) | |||
923 | void set_task_comm(struct task_struct *tsk, char *buf) | 923 | void set_task_comm(struct task_struct *tsk, char *buf) |
924 | { | 924 | { |
925 | task_lock(tsk); | 925 | task_lock(tsk); |
926 | |||
927 | /* | ||
928 | * Threads may access current->comm without holding | ||
929 | * the task lock, so write the string carefully. | ||
930 | * Readers without a lock may see incomplete new | ||
931 | * names but are safe from non-terminating string reads. | ||
932 | */ | ||
933 | memset(tsk->comm, 0, TASK_COMM_LEN); | ||
934 | wmb(); | ||
926 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); | 935 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); |
927 | task_unlock(tsk); | 936 | task_unlock(tsk); |
928 | perf_event_comm(tsk); | 937 | perf_event_comm(tsk); |