NFS: fix potential NULL deref in nfs_closedir()
Subsystems (2)
PATCH 1/1 NFS: fix potential NULL deref in nfs_closedir()
From: Byoungyoung Lee <[email protected]>
When filp->private_data is NULL, put_nfs_open_dir_context() deferences its pointer (fi->list, fi->cred), similar to what other file systems handle '.release' api (9p, cifs, btrfs, ext4, ocfs2).
--- fs/nfs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/dir.c +2 -1
@@ -133,7 +133,8 @@ out:static int nfs_closedir (struct inode *inode,struct file *filp) { -put_nfs_open_dir_context (file_inode (filp), filp->private_data); +if (filp->private_data) +put_nfs_open_dir_context (file_inode (filp), filp->private_data);return 0 ; }
Signature · 1 line
1.9.1
Quoted 6 lines · Taesoo Kim
From: Byoungyoung Lee <[email protected]>
When
filp->private_datais NULL,put_nfs_open_dir_context()deferences its pointer (fi->list,fi->cred), similar to what other file systems handle '.release' api (9p, cifs, btrfs, ext4, ocfs2).
Why woud filp->private_data ever be NULL here?
Ops. After reading nfs code, we also find out that nfs_opendir() always allocates ctx obj (for private_data), unlike other fs allocate private_data right before seeking dentries.
Sorry for the false alarm.
Taesoo
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Taesoo Kim
From: Byoungyoung Lee <[email protected]>
When
filp->private_datais NULL,put_nfs_open_dir_context()deferences its pointer (fi->list,fi->cred), similar to what other file systems handle '.release' api (9p, cifs, btrfs, ext4, ocfs2).Why woud
filp->private_dataever be NULL here?