From: Greg Kroah-Hartman Date: Wed, 7 Mar 2012 18:07:11 +0000 (-0800) Subject: 3.0-stable patches X-Git-Tag: v3.0.24~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8346b27023127e89673dfeaca849f64c22335c8a;p=thirdparty%2Fkernel%2Fstable-queue.git 3.0-stable patches added patches: cifs-fix-dentry-refcount-leak-when-opening-a-fifo-on-lookup.patch --- diff --git a/queue-3.0/cifs-fix-dentry-refcount-leak-when-opening-a-fifo-on-lookup.patch b/queue-3.0/cifs-fix-dentry-refcount-leak-when-opening-a-fifo-on-lookup.patch new file mode 100644 index 00000000000..a594cbce95c --- /dev/null +++ b/queue-3.0/cifs-fix-dentry-refcount-leak-when-opening-a-fifo-on-lookup.patch @@ -0,0 +1,61 @@ +From 5bccda0ebc7c0331b81ac47d39e4b920b198b2cd Mon Sep 17 00:00:00 2001 +From: Jeff Layton +Date: Thu, 23 Feb 2012 09:37:45 -0500 +Subject: cifs: fix dentry refcount leak when opening a FIFO on lookup + +From: Jeff Layton + +commit 5bccda0ebc7c0331b81ac47d39e4b920b198b2cd upstream. + +The cifs code will attempt to open files on lookup under certain +circumstances. What happens though if we find that the file we opened +was actually a FIFO or other special file? + +Currently, the open filehandle just ends up being leaked leading to +a dentry refcount mismatch and oops on umount. Fix this by having the +code close the filehandle on the server if it turns out not to be a +regular file. While we're at it, change this spaghetti if statement +into a switch too. + +Reported-by: CAI Qian +Tested-by: CAI Qian +Reviewed-by: Shirish Pargaonkar +Signed-off-by: Jeff Layton +Signed-off-by: Steve French +Signed-off-by: Greg Kroah-Hartman + +--- + fs/cifs/dir.c | 20 ++++++++++++++++++-- + 1 file changed, 18 insertions(+), 2 deletions(-) + +--- a/fs/cifs/dir.c ++++ b/fs/cifs/dir.c +@@ -583,10 +583,26 @@ cifs_lookup(struct inode *parent_dir_ino + * If either that or op not supported returned, follow + * the normal lookup. + */ +- if ((rc == 0) || (rc == -ENOENT)) ++ switch (rc) { ++ case 0: ++ /* ++ * The server may allow us to open things like ++ * FIFOs, but the client isn't set up to deal ++ * with that. If it's not a regular file, just ++ * close it and proceed as if it were a normal ++ * lookup. ++ */ ++ if (newInode && !S_ISREG(newInode->i_mode)) { ++ CIFSSMBClose(xid, pTcon, fileHandle); ++ break; ++ } ++ case -ENOENT: + posix_open = true; +- else if ((rc == -EINVAL) || (rc != -EOPNOTSUPP)) ++ case -EOPNOTSUPP: ++ break; ++ default: + pTcon->broken_posix_open = true; ++ } + } + if (!posix_open) + rc = cifs_get_inode_info_unix(&newInode, full_path, diff --git a/queue-3.0/series b/queue-3.0/series index ce4f1e1f943..178e1dbc0a0 100644 --- a/queue-3.0/series +++ b/queue-3.0/series @@ -23,3 +23,4 @@ alpha-fix-32-64-bit-bug-in-futex-support.patch mmc-sdhci-esdhc-imx-fix-for-mmc-cards-on-i.mx5.patch mm-memcg-correct-unregistring-of-events-attached-to-the-same-eventfd.patch nommu-don-t-need-to-clear-vm_mm-when-deleting-a-vma.patch +cifs-fix-dentry-refcount-leak-when-opening-a-fifo-on-lookup.patch