From: Jadhav Vikram Date: Tue, 5 Jan 2016 09:32:24 +0000 (+0530) Subject: LU-6961 ldiskfs: buffer head leak in mmp X-Git-Tag: 2.7.66~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a4d7408cccb2df5c1b15c1228527acc01e3ac88a;hp=9fd9042b212a521a122e97aea45ed3d7443b1eb8 LU-6961 ldiskfs: buffer head leak in mmp Release bh_check in case of error. patch added for following kernel RHEL7.2 3.10.0-327.3.1.el7 SLES11SP3 3.0.101-0.47.55 SLES12 - since the code is fairly same across RHEL7 versions adding the patch from RHEL7 to the SLES12 patch series. Seagate-bug-id: MRP-2337 Signed-off-by: Jadhav Vikram Change-Id: Ib3712abcc3e754077882f9302b6065e38e1f014c Reviewed-on: http://review.whamcloud.com/17841 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch index 3221b25..5ce0da8 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mmp.patch @@ -156,7 +156,7 @@ Index: linux-stage/fs/ext4/mmp.c =================================================================== --- /dev/null +++ linux-stage/fs/ext4/mmp.c -@@ -0,0 +1,356 @@ +@@ -0,0 +1,357 @@ +#include +#include +#include @@ -220,6 +220,7 @@ Index: linux-stage/fs/ext4/mmp.c + mmp = (struct mmp_struct *)((*bh)->b_data); + if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) { + brelse(*bh); ++ *bh = NULL; + return -EINVAL; + } + diff --git a/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch b/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch index 10637ef..70f04bb 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.4/ext4-mmp.patch @@ -156,7 +156,7 @@ Index: linux-stage/fs/ext4/mmp.c =================================================================== --- /dev/null +++ linux-stage/fs/ext4/mmp.c -@@ -0,0 +1,356 @@ +@@ -0,0 +1,357 @@ +#include +#include +#include @@ -220,6 +220,7 @@ Index: linux-stage/fs/ext4/mmp.c + mmp = (struct mmp_struct *)((*bh)->b_data); + if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) { + brelse(*bh); ++ *bh = NULL; + return -EINVAL; + } + diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-brelse.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-brelse.patch new file mode 100644 index 0000000..486beb2 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-brelse.patch @@ -0,0 +1,23 @@ +--- linux-stage.orig/fs/ext4/mmp.c 2015-10-06 08:21:12.013939184 +0530 ++++ linux-stage/fs/ext4/mmp.c 2015-10-06 08:20:35.242939292 +0530 +@@ -99,8 +99,11 @@ static int read_mmp_block(struct super_b + + mmp = (struct mmp_struct *)((*bh)->b_data); + if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC || +- !ext4_mmp_csum_verify(sb, mmp)) ++ !ext4_mmp_csum_verify(sb, mmp)) { ++ brelse(*bh); ++ *bh = NULL; + return -EINVAL; ++ } + + return 0; + } +@@ -219,6 +221,7 @@ static int kmmpd(void *data) + "The filesystem seems to have been" + " multiply mounted."); + ext4_error(sb, "abort"); ++ put_bh(bh_check); + goto failed; + } + put_bh(bh_check); diff --git a/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch b/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch new file mode 100644 index 0000000..d74007e --- /dev/null +++ b/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch @@ -0,0 +1,23 @@ +--- linux-stage.orig/fs/ext4/mmp.c 2015-11-01 15:42:38.069175571 +0530 ++++ linux-stage/fs/ext4/mmp.c 2015-11-01 15:46:53.840174791 +0530 +@@ -59,8 +59,11 @@ + } + + 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) { ++ brelse(*bh); ++ *bh = NULL; + return -EINVAL; ++ } + + return 0; + } +@@ -178,6 +180,7 @@ + "The filesystem seems to have been" + " multiply mounted."); + ext4_error(sb, "abort"); ++ put_bh(bh_check); + goto failed; + } + put_bh(bh_check); diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series index 4630175..9cb4ecd 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series @@ -39,3 +39,4 @@ rhel6.3/ext4-journal-path-opt.patch sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch rhel6.3/ext4-notalloc_under_idatasem.patch rhel6.5/ext4-give-warning-with-dir-htree-growing.patch +sles11sp3/ext4-mmp-brelse.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series index 51fdeba..1e673fd 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series @@ -17,3 +17,4 @@ rhel7.2/ext4-pdirop.patch rhel7/ext4-max-dir-size.patch rhel7/ext4-remove-truncate-warning.patch rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +rhel7/ext4-mmp-brelse.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series index fc947ed..cee174a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series @@ -18,3 +18,4 @@ rhel7/ext4-max-dir-size.patch rhel7/ext4-remove-truncate-warning.patch rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch rhel7/ext4-give-warning-with-dir-htree-growing.patch +rhel7/ext4-mmp-brelse.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series index d644b58..2c303c1 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series @@ -17,3 +17,4 @@ sles12/ext4-pdirop.patch rhel7/ext4-max-dir-size.patch rhel7/ext4-remove-truncate-warning.patch sles12/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +rhel7/ext4-mmp-brelse.patch