From 4b4b699dc55425eb582fb233b7815ce0ecd97147 Mon Sep 17 00:00:00 2001 From: Mike Kravetz Date: Sun, 22 Aug 2004 22:26:30 -0700 Subject: [PATCH] proc fs task name locking fix Races have been observed between excec-time overwriting of task->comm and /proc accesses to the same data. This causes environment string information to appear in /proc. Fix that up by taking task_lock() around updates to and accesses to task->comm. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/sched.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/sched.h b/include/linux/sched.h index ed6acd78eb8b..65256f313eb6 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -887,6 +887,9 @@ extern int do_execve(char *, char __user * __user *, char __user * __user *, str extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); extern struct task_struct * copy_process(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); +extern void set_task_comm(struct task_struct *tsk, char *from); +extern void get_task_comm(char *to, struct task_struct *tsk); + #ifdef CONFIG_SMP extern void wait_task_inactive(task_t * p); #else @@ -941,8 +944,8 @@ static inline int thread_group_empty(task_t *p) extern void unhash_process(struct task_struct *p); /* - * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info and synchronises with - * wait4(). + * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info, ->comm and + * synchronises with wait4(). * * Nests both inside and outside of read_lock(&tasklist_lock). * It must not be nested with write_lock_irq(&tasklist_lock), -- cgit v1.2.3