In the Linux kernel, the following vulnerability has been resolved:
jbd2: check 'jh->b_transaction' before removing it from checkpoint
Following process will corrupt ext4 image: Step 1: jbd2journalcommittransaction _jbd2journalinsertcheckpoint(jh, committransaction) // Put jh into trans1->tcheckpointlist journal->jcheckpointtransactions = committransaction // Put trans1 into journal->jcheckpoint_transactions
Step 2: dogetwriteaccess testclearbufferdirty(bh) // clear buffer dirty,set jbd dirty _jbd2journalfilebuffer(jh, transaction) // jh belongs to trans2
Step 3: dropcache journalshrinkonecplist jbd2journaltryremovecheckpoint if (!trylockbuffer(bh)) // lock bh, true if (bufferdirty(bh)) // buffer is not dirty _jbd2journalremovecheckpoint(jh) // remove jh from trans1->tcheckpoint_list
Step 4: jbd2logdocheckpoint trans1 = journal->jcheckpointtransactions // jh is not in trans1->tcheckpointlist jbd2cleanupjournaltail(journal) // trans1 is done
Step 5: Power cut, trans2 is not committed, jh is lost in next mounting.
Fix it by checking 'jh->b_transaction' before remove it from checkpoint.