[kernel] r18550 - in dists/lenny-security/linux-2.6/debian: . patches/bugfix/all patches/series

Dann Frazier dannf at alioth.debian.org
Tue Jan 17 17:36:44 UTC 2012


Author: dannf
Date: Tue Jan 17 17:36:42 2012
New Revision: 18550

Log:
jbd/jbd2: validate sb->s_first in journal_get_superblock() (CVE-2011-4132)

Added:
   dists/lenny-security/linux-2.6/debian/patches/bugfix/all/jbd,jb2-validate-sb-s_first-in-journal_get_superblock.patch
Modified:
   dists/lenny-security/linux-2.6/debian/changelog
   dists/lenny-security/linux-2.6/debian/patches/series/27lenny1

Modified: dists/lenny-security/linux-2.6/debian/changelog
==============================================================================
--- dists/lenny-security/linux-2.6/debian/changelog	Tue Jan 17 17:36:35 2012	(r18549)
+++ dists/lenny-security/linux-2.6/debian/changelog	Tue Jan 17 17:36:42 2012	(r18550)
@@ -7,6 +7,7 @@
   * rose: Add length checks to CALL_REQUEST parsing (CVE-2011-4914)
   * [x86] KVM: Prevent starting PIT timers in the absence of irqchip support
     (CVE-2011-4622)
+  * jbd/jbd2: validate sb->s_first in journal_get_superblock() (CVE-2011-4132)
 
  -- dann frazier <dannf at debian.org>  Fri, 06 Jan 2012 21:15:07 -0700
 

Added: dists/lenny-security/linux-2.6/debian/patches/bugfix/all/jbd,jb2-validate-sb-s_first-in-journal_get_superblock.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny-security/linux-2.6/debian/patches/bugfix/all/jbd,jb2-validate-sb-s_first-in-journal_get_superblock.patch	Tue Jan 17 17:36:42 2012	(r18550)
@@ -0,0 +1,86 @@
+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>
+[dannf: backported to Debian's 2.6.26]
+
+diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
+index b99c3b3..7f784bc 100644
+--- a/fs/jbd/journal.c
++++ b/fs/jbd/journal.c
+@@ -1031,6 +1031,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 2e24567..8c876fa 100644
+--- a/fs/jbd2/journal.c
++++ b/fs/jbd2/journal.c
+@@ -1333,6 +1333,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:

Modified: dists/lenny-security/linux-2.6/debian/patches/series/27lenny1
==============================================================================
--- dists/lenny-security/linux-2.6/debian/patches/series/27lenny1	Tue Jan 17 17:36:35 2012	(r18549)
+++ dists/lenny-security/linux-2.6/debian/patches/series/27lenny1	Tue Jan 17 17:36:42 2012	(r18550)
@@ -5,3 +5,4 @@
 + bugfix/all/futex-nullify-robust-lists-after-cleanup.patch
 + bugfix/all/rose-add-length-checks-to-CALL_REQUEST-parsing.patch
 + bugfix/x86/kvm-prevent-starting-pit-timers-in-the-absence-of-irqchip-support.patch
++ bugfix/all/jbd,jb2-validate-sb-s_first-in-journal_get_superblock.patch



More information about the Kernel-svn-changes mailing list