linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Buffer Head Leak In mmp
@ 2016-01-20 15:48 vikram.jadhav07
  2016-02-08 21:40 ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: vikram.jadhav07 @ 2016-01-20 15:48 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Theodore Ts'o, linux-ext4

[-- Attachment #1: Type: text/plain, Size: 1447 bytes --]

Description:  ext4: Buffer Head Leak In mmp

There is memory leak as both caller function kmmpd() and callee
read_mmp_block() not releasing bh_check  (i.e buffer_head).
Given patch fixes this problem.

Signed-off-by: Jadhav Vikram <vikramjadhavpucsd2007@gmail.com>

Patch:
=====
--- /root/linux.orig/fs/ext4/mmp.c      2016-01-18 07:23:06.227519005 +0530
+++ /root/linux/fs/ext4/mmp.c   2016-01-18 07:31:18.545518552 +0530
@@ -98,12 +98,17 @@
        }

        mmp = (struct mmp_struct *)((*bh)->b_data);
-       if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
+       if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) {
                ret = -EFSCORRUPTED;
-       else if (!ext4_mmp_csum_verify(sb, mmp))
+               brelse(*bh);
+               *bh = NULL;
+       } else if (!ext4_mmp_csum_verify(sb, mmp)) {
                ret = -EFSBADCRC;
-       else
+               brelse(*bh);
+               *bh = NULL;
+       } else {
                return 0;
+       }

 warn_exit:
        ext4_warning(sb, "Error %d while reading MMP block %llu",
@@ -225,6 +230,7 @@
                                             "The filesystem seems to have been"
                                             " multiply mounted.");
                                ext4_error(sb, "abort");
+                               put_bh(bh_check);
                                goto failed;
                        }
                        put_bh(bh_check);

[-- Attachment #2: ext4-mmp-brelse.patch --]
[-- Type: application/octet-stream, Size: 823 bytes --]

--- /root/linux.orig/fs/ext4/mmp.c	2016-01-18 07:23:06.227519005 +0530
+++ /root/linux/fs/ext4/mmp.c	2016-01-18 07:31:18.545518552 +0530
@@ -98,12 +98,17 @@
 	}
 
 	mmp = (struct mmp_struct *)((*bh)->b_data);
-	if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
+	if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) {
 		ret = -EFSCORRUPTED;
-	else if (!ext4_mmp_csum_verify(sb, mmp))
+		brelse(*bh);
+		*bh = NULL;
+	} else if (!ext4_mmp_csum_verify(sb, mmp)) {
 		ret = -EFSBADCRC;
-	else
+		brelse(*bh);
+		*bh = NULL;
+	} else {
 		return 0;
+	}
 
 warn_exit:
 	ext4_warning(sb, "Error %d while reading MMP block %llu",
@@ -225,6 +230,7 @@
 					     "The filesystem seems to have been"
 					     " multiply mounted.");
 				ext4_error(sb, "abort");
+				put_bh(bh_check);
 				goto failed;
 			}
 			put_bh(bh_check);

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

end of thread, other threads:[~2016-03-14 14:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-20 15:48 [PATCH] ext4: Buffer Head Leak In mmp vikram.jadhav07
2016-02-08 21:40 ` Andreas Dilger
2016-03-13 21:57   ` Theodore Ts'o
2016-03-14  8:41     ` Andreas Dilger
2016-03-14 14:40       ` Theodore Ts'o

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