aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-04-30 18:28:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-30 20:04:07 -0400
commit12eaaf309a798973d215f7f21aa5a67a760ed7c8 (patch)
tree6be40c0ec42f7cf8eb5d09c31e1f36cc21499720 /fs/exec.c
parent830e0fc967a7ee5013d5d1cf6a3cea71a8868466 (diff)
set_task_comm: kill the pointless memset() + wmb()
set_task_comm() does memset() + wmb() before strlcpy(). This buys nothing and to add to the confusion, the comment is wrong. - We do not need memset() to be "safe from non-terminating string reads", the final char is always zero and we never change it. - wmb() is paired with nothing, it cannot prevent from printing the mixture of the old/new data unless the reader takes the lock. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: John Stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 87e731f020fb..260f89f66651 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1027,17 +1027,7 @@ EXPORT_SYMBOL_GPL(get_task_comm);
1027void set_task_comm(struct task_struct *tsk, char *buf) 1027void set_task_comm(struct task_struct *tsk, char *buf)
1028{ 1028{
1029 task_lock(tsk); 1029 task_lock(tsk);
1030
1031 trace_task_rename(tsk, buf); 1030 trace_task_rename(tsk, buf);
1032
1033 /*
1034 * Threads may access current->comm without holding
1035 * the task lock, so write the string carefully.
1036 * Readers without a lock may see incomplete new
1037 * names but are safe from non-terminating string reads.
1038 */
1039 memset(tsk->comm, 0, TASK_COMM_LEN);
1040 wmb();
1041 strlcpy(tsk->comm, buf, sizeof(tsk->comm)); 1031 strlcpy(tsk->comm, buf, sizeof(tsk->comm));
1042 task_unlock(tsk); 1032 task_unlock(tsk);
1043 perf_event_comm(tsk); 1033 perf_event_comm(tsk);