On Wed 23-09-15 13:07:40, Vladimir Davydov wrote: > On Wed, Sep 23, 2015 at 06:50:22PM +0900, Sergey Senozhatsky wrote: > > On (09/23/15 11:43), Michal Hocko wrote: > > [..] > > > > > the previous name was already null terminated, > > > > > > > > Yeah, but if the old name is shorter than the new one, set_task_comm() > > > > overwrites the terminating null of the old name before writing the new > > > > terminating null, so there is a short time window during which tsk->comm > > > > might be not null-terminated, no? > > > > > > Not really: > > > case PR_SET_NAME: > > > comm[sizeof(me->comm) - 1] = 0; > > > if (strncpy_from_user(comm, (char __user *)arg2, > > > sizeof(me->comm) - 1) < 0) > > > return -EFAULT; > > > > > > So it first writes the terminating 0 and only then starts copying. > > It writes 0 to a temporary buffer, not to tsk->comm, so I don't think > it's related. However, reading tsk->comm w/o locking must be safe > anyway, because tsk->comm[TASK_COMM_LEN-1] is always 0 (inherited from > init_task) and it never gets overwritten, because __set_task_comm() uses > strlcpy().
Right you are! I am blind obviously... Thought we are copying directly to the task->comm. -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

