X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fexec.c;h=623a5cc3076a114af8808ca030f04bdd82638829;hb=a2770d86b33024f71df269fde2de096df89d6a48;hp=c0c636e34f60f5b347407f1c43599e088d7fedca;hpb=18821b0408efc92ec2804128ba9382a3bcebf132;p=pandora-kernel.git diff --git a/fs/exec.c b/fs/exec.c index c0c636e34f60..623a5cc3076a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -923,6 +923,15 @@ char *get_task_comm(char *buf, struct task_struct *tsk) void set_task_comm(struct task_struct *tsk, char *buf) { task_lock(tsk); + + /* + * Threads may access current->comm without holding + * the task lock, so write the string carefully. + * Readers without a lock may see incomplete new + * names but are safe from non-terminating string reads. + */ + memset(tsk->comm, 0, TASK_COMM_LEN); + wmb(); strlcpy(tsk->comm, buf, sizeof(tsk->comm)); task_unlock(tsk); perf_event_comm(tsk);