Skip to contentSkip to conversation

cifs: fix potential use-after-free in cifs_oplock_break_put

PATCH In review Jeff Layton 2 participants 2 messages Nov 10, 2010 – Nov 11, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix potential use-after-free in cifs_oplock_break_put

cfile may very well be freed after the cifsFileInfo_put. Make sure we have a valid pointer to the superblock for cifs_sb_deactive.

---
 fs/cifs/file.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/cifs/file.c +3 -1
index 06c3e83..b857ce5 100644
@@ -2271,8 +2271,10 @@ void cifs_oplock_break_get(struct cifsFileInfo *cfile)
 
 void cifs_oplock_break_put(struct cifsFileInfo *cfile)
 {
+	struct super_block *sb = cfile->dentry->d_sb;
+
 	cifsFileInfo_put(cfile);
-	cifs_sb_deactive(cfile->dentry->d_sb);
+	cifs_sb_deactive(sb);
 }
 
 const struct address_space_operations cifs_addr_ops = {
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1289402350-14218-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 13 lines · Jeff Layton

cfile may very well be freed after the cifsFileInfo_put. Make sure we have a valid pointer to the superblock for cifs_sb_deactive.

---
 fs/cifs/file.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/cifs/file.c +0 -0
index 06c3e83..b857ce5 100644

fs/cifs/file.c void cifs_oplock_break_get(struct cifsFileInfo *cfile) · line 2279

Quoted 10 lines
fs/cifs/file.c +3 -1
@@ -2271,8 +2271,10 @@ void cifs_oplock_break_get(struct cifsFileInfo *cfile)
 
 void cifs_oplock_break_put(struct cifsFileInfo *cfile)
 {
+	struct super_block *sb = cfile->dentry->d_sb;
+
 	cifsFileInfo_put(cfile);
-	cifs_sb_deactive(cfile->dentry->d_sb);
+	cifs_sb_deactive(sb);
 }
 

Looks correct to me.