Re: [PATCH/Request for review]: check for fops->owner in anon_inode_getfd

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

 



On Thu, 27 Nov 2008, Christian Borntraeger wrote:

> Am Dienstag, 25. November 2008 schrieb Avi Kivity:
> > I agree with your analysis, and also that the anon_inodes change is 
> > useful.  If it's acceptable to the vfs/anon_inode maintainers, I'll 
> > apply the patch.
> 
> I think it is a good idea to strip the fs specific changes into a separate
> patch for easier review:
> 
> From: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> 
> There is an imbalance for anonymous inodes. If the fops->owner field is set,
> the module reference count of owner is decreases on release. 
> ("filp_close" --> "__fput" ---> "fops_put")
> 
> On the other hand, anon_inode_getfd does not increase the module reference 
> count of owner. This causes two problems:
> 
> - if owner is set, the module refcount goes negative
> - if owner is not set, the module can be unloaded while code is running 
> 
> This patch changes anon_inode_getfd to be symmetric regarding fops->owner 
> handling.
> 
> I have checked all existing users of anon_inode_getfd. Noone sets fops->owner, 
> thats why nobody has seen the module refcount negative.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> 
> --- kvm.orig/fs/anon_inodes.c
> +++ kvm/fs/anon_inodes.c
> @@ -79,6 +79,9 @@ int anon_inode_getfd(const char *name, c
>  	if (IS_ERR(anon_inode_inode))
>  		return -ENODEV;
>  
> +	if (fops->owner && !try_module_get(fops->owner))
> +		return -ENOENT;
> +
>  	error = get_unused_fd_flags(flags);
>  	if (error < 0)
>  		return error;

What if get_unused_fd_flags() (or the following error-returing ops) fails 
after a successful try_module_get()?


- Davide


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux