Re: Fw: [Bugme-new] [Bug 9849] New: NULL pointer deref in journal_wait_on_commit_record

2008-02-04 Thread Aneesh Kumar K.V
On Wed, Jan 30, 2008 at 03:17:57PM -0800, Mingming Cao wrote:
 
 The buufer head pointer passed to journal_wait_on_commit_record() could
 be NULL if the previous journal_submit_commit_record() failed or journal
 has already aborted.
 
 Looking at the jbd2 debug messages, before the oops happen, the jbd2 is
 aborted due to trying to access the next log block beyond the end of
 device. This might be caused by using a corrupted image.
 
 We need to check the error returns from journal_submit_commit_record()
 and avoid calling journal_wait_on_commit_record() in the failure case.
 
 Signed-off-by: Mingming Cao [EMAIL PROTECTED]
 The buufer head pointer passed to journal_wait_on_commit_record()
 could be NULL if the previous journal_submit_commit_record() failed
 or journal has already aborted.
 
 We need to check the error returns from journal_submit_commit_record()
 and avoid calling journal_wait_on_commit_record() in the failure case.
 
 Signed-off-by: Mingming Cao [EMAIL PROTECTED]
 ---
  fs/jbd2/commit.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 Index: linux-2.6.24-rc8/fs/jbd2/commit.c
 ===
 --- linux-2.6.24-rc8.orig/fs/jbd2/commit.c2008-01-30 14:12:10.0 
 -0800
 +++ linux-2.6.24-rc8/fs/jbd2/commit.c 2008-01-30 15:09:50.0 -0800
 @@ -872,7 +872,8 @@ wait_for_iobuf:
   if (err)
   __jbd2_journal_abort_hard(journal);
   }
 - err = journal_wait_on_commit_record(cbh);
 + if (!err  !is_journal_aborted(journal))
 + err = journal_wait_on_commit_record(cbh);
 
   if (err)
   jbd2_journal_abort(journal, err);
 
 

Needs the below small change also. I don't see this patch in the patch
queue. So i guess we can add the below diff to the same. The change was
suggested by Girish. Before journal checksum changes sync_dirty_buffer
did the get_bh.

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index da8d0eb..2b88ab0 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -136,7 +136,7 @@ static int journal_submit_commit_record(journal_t *journal,
 
JBUFFER_TRACE(descriptor, submit commit block);
lock_buffer(bh);
-
+   get_bh(bh);
set_buffer_dirty(bh);
set_buffer_uptodate(bh);
bh-b_end_io = journal_end_buffer_io_sync;
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fw: [Bugme-new] [Bug 9849] New: NULL pointer deref in journal_wait_on_commit_record

2008-01-31 Thread Eric Sesterhenn
* Mingming Cao ([EMAIL PROTECTED]) wrote:
 We need to check the error returns from journal_submit_commit_record()
 and avoid calling journal_wait_on_commit_record() in the failure case.
 
 Signed-off-by: Mingming Cao [EMAIL PROTECTED]

thanks, the patch works for me, i closed the bugzilla entry
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fw: [Bugme-new] [Bug 9849] New: NULL pointer deref in journal_wait_on_commit_record

2008-01-30 Thread Andrew Morton


Begin forwarded message:

Date: Wed, 30 Jan 2008 03:24:08 -0800 (PST)
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [Bugme-new] [Bug 9849] New: NULL pointer deref in 
journal_wait_on_commit_record


http://bugzilla.kernel.org/show_bug.cgi?id=9849

   Summary: NULL pointer deref in journal_wait_on_commit_record
   Product: File System
   Version: 2.5
 KernelVersion: 2.6.24-03997-g85004cc
  Platform: All
OS/Version: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: ext4
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]


Latest working kernel version: -
Earliest failing kernel version: 2.6.24-03863-g0ba6c33
Distribution: Ubuntu
Problem Description:

using a corrupted image causes an oops in unmount, seems as if
journal_wait_on_commit_record() gets passed a NULL pointer

Steps to reproduce:

using fsfuzz with ext4, I'll attach the image which causes this for me

one oops can be found here
http://kerneloops.org/raw.php?rawid=3160msgid=

here is another one with full jbd2 debugging enabled (there are a lot of
log_do_checkpoint messages above this)

[  242.863778] (fs/jbd2/checkpoint.c, 308): jbd2_log_do_checkpoint: Start
checkpoint
[  242.863790] (fs/jbd2/checkpoint.c, 316): jbd2_log_do_checkpoint:
cleanup_journal_tail returned 1
[  242.863810] (fs/jbd2/checkpoint.c, 308): jbd2_log_do_checkpoint: Start
checkpoint
[  242.863822] (fs/jbd2/checkpoint.c, 316): jbd2_log_do_checkpoint:
cleanup_journal_tail returned 1
[  242.863842] (fs/jbd2/checkpoint.c, 308): jbd2_log_do_checkpoint: Start
checkpoint
[  242.863854] (fs/jbd2/checkpoint.c, 316): jbd2_log_do_checkpoint:
cleanup_journal_tail returned 1
[  242.863874] (fs/jbd2/checkpoint.c, 308): jbd2_log_do_checkpoint: Start
checkpoint
[  242.863886] (fs/jbd2/checkpoint.c, 316): jbd2_log_do_checkpoint:
cleanup_journal_tail returned 1
[  242.864017] (fs/jbd2/journal.c, 193): kjournald2: kjournald2 wakes
[  242.864027] (fs/jbd2/journal.c, 201): kjournald2: woke because of timeout
[  242.864035] (fs/jbd2/journal.c, 145): kjournald2: commit_sequence=1,
commit_request=2
[  242.864044] (fs/jbd2/journal.c, 148): kjournald2: OK, requests differ
[  242.864055] (fs/jbd2/commit.c, 415): jbd2_journal_commit_transaction: super
block updated
[  242.864066] (fs/jbd2/journal.c, 1264): jbd2_journal_update_superblock: JBD:
updating superblock (start 15335425, seq 2, errno 0)
[  242.864385] (fs/jbd2/commit.c, 428): jbd2_journal_commit_transaction: JBD:
starting commit of transaction 2
[  242.864409] (fs/jbd2/commit.c, 501): jbd2_journal_commit_transaction: JBD:
commit phase 1
[  242.864428] (fs/jbd2/commit.c, 519): jbd2_journal_commit_transaction: JBD:
commit phase 2
[  242.864459] (fs/jbd2/revoke.c, 537): jbd2_journal_write_revoke_records:
Wrote 0 revoke records
[  242.864469] (fs/jbd2/commit.c, 561): jbd2_journal_commit_transaction: JBD:
commit phase 2
[  242.864478] (fs/jbd2/commit.c, 571): jbd2_journal_commit_transaction: JBD:
commit phase 3
[  242.864487] (fs/jbd2/commit.c, 780): jbd2_journal_commit_transaction: JBD:
commit phase 4
[  242.864496] (fs/jbd2/commit.c, 839): jbd2_journal_commit_transaction: JBD:
commit phase 5
[  242.864505] (fs/jbd2/commit.c, 866): jbd2_journal_commit_transaction: JBD:
commit phase 6
[  242.864599] attempt to access beyond end of device
[  242.864609] loop0: rw=0, want=200708, limit=16384
[  242.864633] jbd2_journal_bmap: journal block not found at offset 15335425 on
loop0
[  242.864680] Aborting journal on device loop0.
[  242.864733] (fs/jbd2/journal.c, 1264): jbd2_journal_update_superblock: JBD:
updating superblock (start 15335425, seq 2, errno -5)
[  242.864868] BUG: unable to handle kernel NULL pointer dereference at virtual
address 
[  242.864962] printing eip: c023c2a7 *pde =  
[  242.865048] Oops: 0002 [#1] PREEMPT 
[  242.865108] Modules linked in:
[  242.865218] 
[  242.865243] Pid: 3698, comm: kjournald2 Not tainted (2.6.24-03997-g85004cc
#16)
[  242.865268] EIP: 0060:[c023c2a7] EFLAGS: 00010202 CPU: 0
[  242.865382] EIP is at journal_wait_on_commit_record+0x7/0x50
[  242.865407] EAX:  EBX:  ECX: 0001 EDX: 0001
[  242.865431] ESI:  EDI: c07835d2 EBP: cb229ee4 ESP: cb229edc
[  242.865455]  DS: 007b ES: 007b FS:  GS:  SS: 0068
[  242.865539] Process kjournald2 (pid: 3698, ti=cb229000 task=cb208000
task.ti=cb229000)
[  242.865564] Stack:   cb229f88 c023cb07  c07835d2
0362 c069c620 
[  242.865864]cb2316e0 cb231504 cb2314f0 cb134960  cb231920
  
[  242.865918]cb208000   0008  
  
[  242.865918] Call Trace:
[  242.865918]  [c0104c0a] show_trace_log_lvl+0x1a/0x30
[  242.865918]  [c0104cc9] show_stack_log_lvl+0xa9/0xd0
[  242.865918]  [c0104dba] show_registers+0xca/0x250
[  242.865918]  [c01051e1] die+0x101/0x220
[  

Re: Fw: [Bugme-new] [Bug 9849] New: NULL pointer deref in journal_wait_on_commit_record

2008-01-30 Thread Mingming Cao
On Wed, 2008-01-30 at 12:00 -0800, Andrew Morton wrote:
 
 Begin forwarded message:
 
 Date: Wed, 30 Jan 2008 03:24:08 -0800 (PST)
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: [Bugme-new] [Bug 9849] New: NULL pointer deref in 
 journal_wait_on_commit_record
 
 
 http://bugzilla.kernel.org/show_bug.cgi?id=9849
 
Summary: NULL pointer deref in journal_wait_on_commit_record
Product: File System
Version: 2.5
  KernelVersion: 2.6.24-03997-g85004cc
   Platform: All
 OS/Version: Linux
   Tree: Mainline
 Status: NEW
   Severity: normal
   Priority: P1
  Component: ext4
 AssignedTo: [EMAIL PROTECTED]
 ReportedBy: [EMAIL PROTECTED]
 
 
 Latest working kernel version: -
 Earliest failing kernel version: 2.6.24-03863-g0ba6c33
 Distribution: Ubuntu
 Problem Description:
 
 using a corrupted image causes an oops in unmount, seems as if
 journal_wait_on_commit_record() gets passed a NULL pointer
 

The buufer head pointer passed to journal_wait_on_commit_record() could
be NULL if the previous journal_submit_commit_record() failed or journal
has already aborted.

Looking at the jbd2 debug messages, before the oops happen, the jbd2 is
aborted due to trying to access the next log block beyond the end of
device. This might be caused by using a corrupted image.

We need to check the error returns from journal_submit_commit_record()
and avoid calling journal_wait_on_commit_record() in the failure case.

Signed-off-by: Mingming Cao [EMAIL PROTECTED]
The buufer head pointer passed to journal_wait_on_commit_record()
could be NULL if the previous journal_submit_commit_record() failed
or journal has already aborted.

We need to check the error returns from journal_submit_commit_record()
and avoid calling journal_wait_on_commit_record() in the failure case.

Signed-off-by: Mingming Cao [EMAIL PROTECTED]
---
 fs/jbd2/commit.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.24-rc8/fs/jbd2/commit.c
===
--- linux-2.6.24-rc8.orig/fs/jbd2/commit.c  2008-01-30 14:12:10.0 
-0800
+++ linux-2.6.24-rc8/fs/jbd2/commit.c   2008-01-30 15:09:50.0 -0800
@@ -872,7 +872,8 @@ wait_for_iobuf:
if (err)
__jbd2_journal_abort_hard(journal);
}
-   err = journal_wait_on_commit_record(cbh);
+   if (!err  !is_journal_aborted(journal))
+   err = journal_wait_on_commit_record(cbh);
 
if (err)
jbd2_journal_abort(journal, err);


-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Fw: [Bugme-new] [Bug 9849] New: NULL pointer deref in journal_wait_on_commit_record

2008-01-30 Thread Andrew Morton
On Wed, 30 Jan 2008 15:17:57 -0800
Mingming Cao [EMAIL PROTECTED] wrote:

 The buufer head pointer passed to journal_wait_on_commit_record()
 could be NULL if the previous journal_submit_commit_record() failed
 or journal has already aborted.
 
 We need to check the error returns from journal_submit_commit_record()
 and avoid calling journal_wait_on_commit_record() in the failure case.
 
 Signed-off-by: Mingming Cao [EMAIL PROTECTED]
 ---
  fs/jbd2/commit.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 Index: linux-2.6.24-rc8/fs/jbd2/commit.c
 ===
 --- linux-2.6.24-rc8.orig/fs/jbd2/commit.c2008-01-30 14:12:10.0 
 -0800
 +++ linux-2.6.24-rc8/fs/jbd2/commit.c 2008-01-30 15:09:50.0 -0800
 @@ -872,7 +872,8 @@ wait_for_iobuf:
   if (err)
   __jbd2_journal_abort_hard(journal);
   }
 - err = journal_wait_on_commit_record(cbh);
 + if (!err  !is_journal_aborted(journal))
 + err = journal_wait_on_commit_record(cbh);
  
   if (err)
   jbd2_journal_abort(journal, err);

Thanks.  Please note that I Cc'ed [EMAIL PROTECTED] on this, for a 2.6.24.x
backport.
-
To unsubscribe from this list: send the line unsubscribe linux-ext4 in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html