[natty, natty/ti-omap4 CVE 1/1] ext4: init timer earlier to avoid a kernel panic in __save_error_info

Andy Whitcroft apw at canonical.com
Thu Jul 7 12:39:00 UTC 2011

From: Tao Ma <boyu.mt at taobao.com>

During mount, when we fail to open journal inode or root inode, the
__save_error_info will mod_timer. But actually s_err_report isn't
initialized yet and the kernel oops. The detailed information can
be found https://bugzilla.kernel.org/show_bug.cgi?id=32082.

The best way is to check whether the timer s_err_report is initialized
or not. But it seems that in include/linux/timer.h, we can't find a
good function to check the status of this timer, so this patch just
move the initializtion of s_err_report earlier so that we can avoid
the kernel panic. The corresponding del_timer is also added in the
error path.

Reported-by: Sami Liedes <sliedes at cc.hut.fi>
Signed-off-by: Tao Ma <boyu.mt at taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>

(cherry picked from commit 0449641130f5652b344ef6fa39fa019d7e94660a)
BugLink: http://bugs.launchpad.net/bugs/806929
Signed-off-by: Andy Whitcroft <apw at canonical.com>
 fs/ext4/super.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9bada49..59e567e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3377,6 +3377,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
+	init_timer(&sbi->s_err_report);
+	sbi->s_err_report.function = print_daily_error_info;
+	sbi->s_err_report.data = (unsigned long) sb;
 	err = percpu_counter_init(&sbi->s_freeblocks_counter,
 	if (!err) {
@@ -3632,9 +3636,6 @@ no_journal:
 		 "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts,
 		 *sbi->s_es->s_mount_opts ? "; " : "", orig_data);
-	init_timer(&sbi->s_err_report);
-	sbi->s_err_report.function = print_daily_error_info;
-	sbi->s_err_report.data = (unsigned long) sb;
 	if (es->s_error_count)
 		mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */
@@ -3656,6 +3657,7 @@ failed_mount_wq:
 		sbi->s_journal = NULL;
+	del_timer(&sbi->s_err_report);
 	if (sbi->s_flex_groups) {
 		if (is_vmalloc_addr(sbi->s_flex_groups))

More information about the kernel-team mailing list