Fix NULL point deref in v9fs_dir_release
Subsystems (2)
PATCH v2 1/1 Fix NULL point deref in v9fs_dir_release
changes from v1:
Now checking fid instead of filp.
There are situations in VFS where we endup calling v9fs_dir_release() before even we instantiate the fid in filp. Hence the check.
--- fs/9p/vfs_dir.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/9p/vfs_dir.c +2 -0
@@ -291,6 +291,8 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)struct p9_fid *fid; fid = filp->private_data; +if (!fid) +return 0 ;P9_DPRINTK (P9_DEBUG_VFS ,"inode: %p filp: %p fid: %d\n" , inode, filp, fid->fid);filemap_write_and_wait (inode->i_mapping);
Signature · 1 line
1.6.5.2
Quoted 16 lines · Venkateswararao Jujjuri (JV)
changes from v1:
Now checking fid instead of filp.There are situations in VFS where we endup calling
v9fs_dir_release()before even we instantiate the fid in filp. Hence the check.Signed-off-by Venkateswararao Jujjuri <[email protected]>---
fs/9p/vfs_dir.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)fs/9p/vfs_dir.c +0
-0
fs/9p/vfs_dir.c int v9fs_dir_release(struct inode *inode, struct file *filp) · line 298
Quoted 8 lines
fs/9p/vfs_dir.c +2
-0@@ -291,6 +291,8 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) struct p9_fid *fid; fid = filp->private_data; + if (!fid) + return 0; P9_DPRINTK(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n", inode, filp, fid->fid); filemap_write_and_wait(inode->i_mapping);
It's probably a safe bet that if don't have a fid then filemap_write_and_wait either won't have anything to write or won't be able to. Still, I'm a bit uncomfortable as if we lost the fid for some reason and it did have something to write it would be treated as a silent error. I think it would probably be safer to remove the fid->fid from the debug print (or make it conditional on fid being non-null) and then change the clunk to be conditional on the presence of a fid.
-eric
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html