Re: + procfs-directory-entry-cleanup.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 20, 2007 at 08:41:02PM -0700, [email protected] wrote:
> Subject: procfs directory entry cleanup
> From: "Changli Gao" <[email protected]>
>
> Function proc_register() will assign proc_dir_operations and
> proc_dir_inode_operations to ent's members proc_fops and proc_iops
> correctly if ent is a directory. So the early assignment isn't
> necessary.

> --- a/fs/proc/generic.c~procfs-directory-entry-cleanup
> +++ a/fs/proc/generic.c
> @@ -649,9 +649,6 @@ struct proc_dir_entry *proc_mkdir_mode(c
>  
>  	ent = proc_create(&parent, name, S_IFDIR | mode, 2);
>  	if (ent) {
> -		ent->proc_fops = &proc_dir_operations;
> -		ent->proc_iops = &proc_dir_inode_operations;
> -
>  		if (proc_register(parent, ent) < 0) {
>  			kfree(ent);
>  			ent = NULL;
> @@ -686,10 +683,6 @@ struct proc_dir_entry *create_proc_entry
>  
>  	ent = proc_create(&parent,name,mode,nlink);
>  	if (ent) {
> -		if (S_ISDIR(mode)) {
> -			ent->proc_fops = &proc_dir_operations;
> -			ent->proc_iops = &proc_dir_inode_operations;
> -		}
>  		if (proc_register(parent, ent) < 0) {
>  			kfree(ent);
>  			ent = NULL;

This should add race because new PDE for directory will be glued to tree
with NULL ->proc_iops and, at least, vfs_getattr() doesn't check for
NULL ->i_op.

I've tried to reproduce this scenario with udelay() inserted before
S_ISDIR checks in proc_register() but got some panic while in X,
so no cookie for me. Maybe it's impossible, indeed.

Anyway, this patch + moving ->proc_fops and ->proc_iops initialization
before gluing is OK with me.

-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux