mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	9p: Fix writeback fid incorrectly being attached to dentry
v9fs_dir_release needs fid->ilist to have been initialized for filp's
fid, not the inode's writeback fid's.
With refcounting this can be improved on later but this appears to fix
null deref issues.
Link: http://lkml.kernel.org/r/1605802012-31133-3-git-send-email-asmadeus@codewreck.org
Fixes: 6636b6dcc3 ("fs/9p: track open fids")
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
			
			
This commit is contained in:
		
							parent
							
								
									ff5e72ebef
								
							
						
					
					
						commit
						5bfe97d738
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -46,7 +46,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	struct v9fs_inode *v9inode;
 | 
						struct v9fs_inode *v9inode;
 | 
				
			||||||
	struct v9fs_session_info *v9ses;
 | 
						struct v9fs_session_info *v9ses;
 | 
				
			||||||
	struct p9_fid *fid;
 | 
						struct p9_fid *fid, *writeback_fid;
 | 
				
			||||||
	int omode;
 | 
						int omode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
 | 
						p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
 | 
				
			||||||
| 
						 | 
					@ -85,13 +85,13 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 | 
				
			||||||
		 * because we want write after unlink usecase
 | 
							 * because we want write after unlink usecase
 | 
				
			||||||
		 * to work.
 | 
							 * to work.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		fid = v9fs_writeback_fid(file_dentry(file));
 | 
							writeback_fid = v9fs_writeback_fid(file_dentry(file));
 | 
				
			||||||
		if (IS_ERR(fid)) {
 | 
							if (IS_ERR(fid)) {
 | 
				
			||||||
			err = PTR_ERR(fid);
 | 
								err = PTR_ERR(fid);
 | 
				
			||||||
			mutex_unlock(&v9inode->v_mutex);
 | 
								mutex_unlock(&v9inode->v_mutex);
 | 
				
			||||||
			goto out_error;
 | 
								goto out_error;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		v9inode->writeback_fid = (void *) fid;
 | 
							v9inode->writeback_fid = (void *) writeback_fid;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mutex_unlock(&v9inode->v_mutex);
 | 
						mutex_unlock(&v9inode->v_mutex);
 | 
				
			||||||
	if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
 | 
						if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue