[kernel/f14] CVE-2011-4132: jbd/jbd2: invalid value of first log block leads to oops (rhbz 753346)

Josh Boyer jwboyer at fedoraproject.org
Mon Nov 14 16:14:28 UTC 2011


commit 4f79121e0c32962e2cab046b6ec44c63d8eb97f9
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Mon Nov 14 10:03:45 2011 -0500

    CVE-2011-4132: jbd/jbd2: invalid value of first log block leads to oops (rhbz 753346)

 ...lidate-sb-s_first-in-journal_get_superblo.patch |   95 ++++++++++++++++++++
 kernel.spec                                        |   10 ++-
 2 files changed, 104 insertions(+), 1 deletions(-)
---
diff --git a/jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch b/jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch
new file mode 100644
index 0000000..f5d8291
--- /dev/null
+++ b/jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch
@@ -0,0 +1,95 @@
+From 8762202dd0d6e46854f786bdb6fb3780a1625efe Mon Sep 17 00:00:00 2001
+From: Eryu Guan <guaneryu at gmail.com>
+Date: Tue, 1 Nov 2011 19:04:59 -0400
+Subject: [PATCH] jbd/jbd2: validate sb->s_first in journal_get_superblock()
+
+I hit a J_ASSERT(blocknr != 0) failure in cleanup_journal_tail() when
+mounting a fsfuzzed ext3 image. It turns out that the corrupted ext3
+image has s_first = 0 in journal superblock, and the 0 is passed to
+journal->j_head in journal_reset(), then to blocknr in
+cleanup_journal_tail(), in the end the J_ASSERT failed.
+
+So validate s_first after reading journal superblock from disk in
+journal_get_superblock() to ensure s_first is valid.
+
+The following script could reproduce it:
+
+fstype=ext3
+blocksize=1024
+img=$fstype.img
+offset=0
+found=0
+magic="c0 3b 39 98"
+
+dd if=/dev/zero of=$img bs=1M count=8
+mkfs -t $fstype -b $blocksize -F $img
+filesize=`stat -c %s $img`
+while [ $offset -lt $filesize ]
+do
+        if od -j $offset -N 4 -t x1 $img | grep -i "$magic";then
+                echo "Found journal: $offset"
+                found=1
+                break
+        fi
+        offset=`echo "$offset+$blocksize" | bc`
+done
+
+if [ $found -ne 1 ];then
+        echo "Magic \"$magic\" not found"
+        exit 1
+fi
+
+dd if=/dev/zero of=$img seek=$(($offset+23)) conv=notrunc bs=1 count=1
+
+mkdir -p ./mnt
+mount -o loop $img ./mnt
+
+Cc: Jan Kara <jack at suse.cz>
+Signed-off-by: Eryu Guan <guaneryu at gmail.com>
+Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
+---
+ fs/jbd/journal.c  |    8 ++++++++
+ fs/jbd2/journal.c |    8 ++++++++
+ 2 files changed, 16 insertions(+), 0 deletions(-)
+
+diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
+index 9fe061f..fea8dd6 100644
+--- a/fs/jbd/journal.c
++++ b/fs/jbd/journal.c
+@@ -1135,6 +1135,14 @@ static int journal_get_superblock(journal_t *journal)
+ 		goto out;
+ 	}
+ 
++	if (be32_to_cpu(sb->s_first) == 0 ||
++	    be32_to_cpu(sb->s_first) >= journal->j_maxlen) {
++		printk(KERN_WARNING
++			"JBD: Invalid start block of journal: %u\n",
++			be32_to_cpu(sb->s_first));
++		goto out;
++	}
++
+ 	return 0;
+ 
+ out:
+diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
+index f24df13..d6e93d0 100644
+--- a/fs/jbd2/journal.c
++++ b/fs/jbd2/journal.c
+@@ -1251,6 +1251,14 @@ static int journal_get_superblock(journal_t *journal)
+ 		goto out;
+ 	}
+ 
++	if (be32_to_cpu(sb->s_first) == 0 ||
++	    be32_to_cpu(sb->s_first) >= journal->j_maxlen) {
++		printk(KERN_WARNING
++			"JBD2: Invalid start block of journal: %u\n",
++			be32_to_cpu(sb->s_first));
++		goto out;
++	}
++
+ 	return 0;
+ 
+ out:
+-- 
+1.7.7.1
+
diff --git a/kernel.spec b/kernel.spec
index 8199481..0395b5c 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -48,7 +48,7 @@ Summary: The Linux kernel
 # reset this by hand to 1 (or to 0 and then use rpmdev-bumpspec).
 # scripts/rebase.sh should be made to do that for you, actually.
 #
-%global baserelease 103
+%global baserelease 104
 %global fedora_build %{baserelease}
 
 # base_sublevel is the kernel version we're starting with and patching
@@ -739,6 +739,9 @@ Patch2950: linux-2.6-via-velocity-dma-fix.patch
 
 Patch3010: linux-2.6-rcu-netpoll.patch
 
+#rhbz 753346
+Patch3500: jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch
+
 Patch4000: rcutree-avoid-false-quiescent-states.patch
 
 Patch5000: acer-wmi-modalias.patch
@@ -1375,6 +1378,8 @@ ApplyPatch linux-2.6-32bit-mmap-exec-randomization.patch
 #
 
 # ext4
+#rhbz 753346
+ApplyPatch jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch
 
 # rhbz#578674
 ApplyPatch ext4-always-journal-quota-file-modifications.patch
@@ -2313,6 +2318,9 @@ fi
 # and build.
 
 %changelog
+* Mon Nov 14 2011 Josh Boyer <jwboyer at redhat.com> 2.6.41.1-2
+- CVE-2011-4132: jbd/jbd2: invalid value of first log block leads to oops (rhbz 753346)
+
 * Tue Nov 01 2011 Dave Jones <davej at redhat.com>
 - Add another Sony laptop to the nonvs blacklist. (rhbz 641789)
 


More information about the scm-commits mailing list