Re: /proc visibility patch breaks GDB, etc.
From: Kingsley Cheung
Date:  Thu Feb 26 2004 - 18:43:09 EST
On Thu, Feb 26, 2004 at 03:19:17PM -0800, Andrew Morton wrote:
> Kingsley Cheung <kingsley@xxxxxxxxxx> wrote:
> >
> > Am I correct to assume though that the corresponding change in
> > proc_task_lookup() should stay?  The existing behaviour there was that
> > one could do say,
> > 
> > cat /proc/<pid>/task/<tid>/stat, where tid could be any thread and not
> > a part of the thread group pid.  
> 
> That sounds especially broken - let's hope that nobody has started using it
> (but how did you even discover this?  Code audit?)
Completely an accident on my part.  While writing code to traverse
threads in a group and obtain their data usage, I was comparing what I
could see from the output with the shell and I just happened to do a
typo on the tid value... To my suprise it worked.
> 
> How's this?
Looks like proc_pid_lookup() was never changed at all :)
> 
> diff -puN fs/proc/base.c~proc-thread-visibility-revert fs/proc/base.c
> --- 25/fs/proc/base.c~proc-thread-visibility-revert	Thu Feb 26 15:17:48 2004
> +++ 25-akpm/fs/proc/base.c	Thu Feb 26 15:17:48 2004
> @@ -1582,13 +1582,14 @@ struct dentry *proc_pid_lookup(struct in
>  	read_unlock(&tasklist_lock);
>  	if (!task)
>  		goto out;
> -	if (!thread_group_leader(task))
> -		goto out_drop_task;
>  
>  	inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
>  
> -	if (!inode)
> -		goto out_drop_task;
> +
> +	if (!inode) {
> +		put_task_struct(task);
> +		goto out;
> +	}
>  	inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
>  	inode->i_op = &proc_tgid_base_inode_operations;
>  	inode->i_fop = &proc_tgid_base_operations;
> @@ -1613,8 +1614,6 @@ struct dentry *proc_pid_lookup(struct in
>  		goto out;
>  	}
>  	return NULL;
> -out_drop_task:
> -	put_task_struct(task);
>  out:
>  	return ERR_PTR(-ENOENT);
>  }
> 
> _
-- 
		Kingsley
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/