linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFS: fix potential NULL deref in nfs_closedir()
@ 2015-03-21  4:21 Taesoo Kim
  2015-03-21 18:01 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Taesoo Kim @ 2015-03-21  4:21 UTC (permalink / raw)
  To: trond.myklebust, anna.schumaker, linux-nfs, linux-kernel
  Cc: taesoo, changwoo, sanidhya, blee, csong84, Byoungyoung Lee,
	Taesoo Kim

From: Byoungyoung Lee <lifeasageek@gmail.com>

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).

Signed-off-by: Byoungyoung Lee <lifeasageek@gmail.com>
Signed-off-by: Taesoo Kim <tsgatesv@gmail.com>
---
 fs/nfs/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index c19e16f..434ecf1 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: fix potential NULL deref in nfs_closedir()
  2015-03-21  4:21 [PATCH] NFS: fix potential NULL deref in nfs_closedir() Taesoo Kim
@ 2015-03-21 18:01 ` Christoph Hellwig
  2015-03-21 18:47   ` Taesoo Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2015-03-21 18:01 UTC (permalink / raw)
  To: Taesoo Kim
  Cc: trond.myklebust, anna.schumaker, linux-nfs, linux-kernel, taesoo,
	changwoo, sanidhya, blee, csong84, Byoungyoung Lee

On Sat, Mar 21, 2015 at 12:21:18AM -0400, Taesoo Kim wrote:
> From: Byoungyoung Lee <lifeasageek@gmail.com>
> 
> 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).

Why woud filp->private_data ever be NULL here?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: fix potential NULL deref in nfs_closedir()
  2015-03-21 18:01 ` Christoph Hellwig
@ 2015-03-21 18:47   ` Taesoo Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Taesoo Kim @ 2015-03-21 18:47 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Taesoo Kim, trond.myklebust, anna.schumaker, linux-nfs,
	linux-kernel, changwoo, sanidhya, blee, csong84, Byoungyoung Lee

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

On 03/21/15 at 11:01am, Christoph Hellwig wrote:
> On Sat, Mar 21, 2015 at 12:21:18AM -0400, Taesoo Kim wrote:
> > From: Byoungyoung Lee <lifeasageek@gmail.com>
> > 
> > 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).
> 
> Why woud filp->private_data ever be NULL here?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-21 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-21  4:21 [PATCH] NFS: fix potential NULL deref in nfs_closedir() Taesoo Kim
2015-03-21 18:01 ` Christoph Hellwig
2015-03-21 18:47   ` Taesoo Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).