mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-01 00:58:39 +02:00 
			
		
		
		
	bch2_ioctl_subvolume_destroy(): fix locking
make it use user_path_locked_at() to get the normal directory protection for modifications, as well as stable ->d_parent and ->d_name in victim Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									74d016ecc1
								
							
						
					
					
						commit
						bbe6a7c899
					
				
					 1 changed files with 17 additions and 14 deletions
				
			
		|  | @ -453,33 +453,36 @@ static long bch2_ioctl_subvolume_create(struct bch_fs *c, struct file *filp, | |||
| static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp, | ||||
| 				struct bch_ioctl_subvolume arg) | ||||
| { | ||||
| 	const char __user *name = (void __user *)(unsigned long)arg.dst_ptr; | ||||
| 	struct path path; | ||||
| 	struct inode *dir; | ||||
| 	struct dentry *victim; | ||||
| 	int ret = 0; | ||||
| 
 | ||||
| 	if (arg.flags) | ||||
| 		return -EINVAL; | ||||
| 
 | ||||
| 	ret = user_path_at(arg.dirfd, | ||||
| 			(const char __user *)(unsigned long)arg.dst_ptr, | ||||
| 			LOOKUP_FOLLOW, &path); | ||||
| 	if (ret) | ||||
| 		return ret; | ||||
| 	victim = user_path_locked_at(arg.dirfd, name, &path); | ||||
| 	if (IS_ERR(victim)) | ||||
| 		return PTR_ERR(victim); | ||||
| 
 | ||||
| 	if (path.dentry->d_sb->s_fs_info != c) { | ||||
| 	if (victim->d_sb->s_fs_info != c) { | ||||
| 		ret = -EXDEV; | ||||
| 		goto err; | ||||
| 	} | ||||
| 
 | ||||
| 	dir = path.dentry->d_parent->d_inode; | ||||
| 
 | ||||
| 	ret = __bch2_unlink(dir, path.dentry, true); | ||||
| 	if (ret) | ||||
| 	if (!d_is_positive(victim)) { | ||||
| 		ret = -ENOENT; | ||||
| 		goto err; | ||||
| 
 | ||||
| 	fsnotify_rmdir(dir, path.dentry); | ||||
| 	d_delete(path.dentry); | ||||
| 	} | ||||
| 	dir = d_inode(path.dentry); | ||||
| 	ret = __bch2_unlink(dir, victim, true); | ||||
| 	if (!ret) { | ||||
| 		fsnotify_rmdir(dir, victim); | ||||
| 		d_delete(victim); | ||||
| 	} | ||||
| 	inode_unlock(dir); | ||||
| err: | ||||
| 	dput(victim); | ||||
| 	path_put(&path); | ||||
| 	return ret; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Al Viro
						Al Viro