Skip to content
Snippets Groups Projects
Commit c18bc51c authored by yangerkun's avatar yangerkun Committed by Yang Yingliang
Browse files

jbd2: fix kabi broken in struct journal_s


hulk inclusion
category: bugfix
bugzilla: 172974
CVE: NA
---------------------------

72c9e4df ('jbd2: ensure abort the journal if detect IO error when
writing original buffer back') will add 'j_atomic_flags' which can lead
lots of kabi broken like jbd2_journal_destroy/jbd2_journal_abort and so
on.

Fix it by add a wrapper.

Signed-off-by: default avataryangerkun <yangerkun@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent ed46208d
No related branches found
No related tags found
No related merge requests found
......@@ -562,6 +562,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
struct transaction_chp_stats_s *stats;
transaction_t *transaction;
journal_t *journal;
journal_wrapper_t *journal_wrapper;
struct buffer_head *bh = jh2bh(jh);
JBUFFER_TRACE(jh, "entry");
......@@ -572,6 +573,8 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
return 0;
}
journal = transaction->t_journal;
journal_wrapper = container_of(journal, journal_wrapper_t,
jw_journal);
JBUFFER_TRACE(jh, "removing from transaction");
......@@ -583,7 +586,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh)
* journal here and we abort the journal later from a better context.
*/
if (buffer_write_io_error(bh))
set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags);
set_bit(JBD2_CHECKPOINT_IO_ERROR, &journal_wrapper->j_atomic_flags);
__buffer_unlink(jh);
jh->b_cp_transaction = NULL;
......
......@@ -1129,14 +1129,17 @@ static journal_t *journal_init_common(struct block_device *bdev,
{
static struct lock_class_key jbd2_trans_commit_key;
journal_t *journal;
journal_wrapper_t *journal_wrapper;
int err;
struct buffer_head *bh;
int n;
journal = kzalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
journal_wrapper = kzalloc(sizeof(*journal_wrapper), GFP_KERNEL);
if (!journal_wrapper)
return NULL;
journal = &(journal_wrapper->jw_journal);
init_waitqueue_head(&journal->j_wait_transaction_locked);
init_waitqueue_head(&journal->j_wait_done_commit);
init_waitqueue_head(&journal->j_wait_commit);
......@@ -1195,7 +1198,7 @@ static journal_t *journal_init_common(struct block_device *bdev,
err_cleanup:
kfree(journal->j_wbuf);
jbd2_journal_destroy_revoke(journal);
kfree(journal);
kfree(journal_wrapper);
return NULL;
}
......@@ -1425,11 +1428,13 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
unsigned long tail_block, int write_op)
{
journal_superblock_t *sb = journal->j_superblock;
journal_wrapper_t *journal_wrapper = container_of(journal,
journal_wrapper_t, jw_journal);
int ret;
if (is_journal_aborted(journal))
return -EIO;
if (test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags)) {
if (test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal_wrapper->j_atomic_flags)) {
jbd2_journal_abort(journal, -EIO);
return -EIO;
}
......@@ -1754,6 +1759,8 @@ int jbd2_journal_load(journal_t *journal)
int jbd2_journal_destroy(journal_t *journal)
{
int err = 0;
journal_wrapper_t *journal_wrapper = container_of(journal,
journal_wrapper_t, jw_journal);
/* Wait for the commit thread to wake up and die. */
journal_kill_thread(journal);
......@@ -1795,7 +1802,7 @@ int jbd2_journal_destroy(journal_t *journal)
* may become inconsistent.
*/
if (!is_journal_aborted(journal) &&
test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal->j_atomic_flags))
test_bit(JBD2_CHECKPOINT_IO_ERROR, &journal_wrapper->j_atomic_flags))
jbd2_journal_abort(journal, -EIO);
if (journal->j_sb_buffer) {
......@@ -1823,7 +1830,7 @@ int jbd2_journal_destroy(journal_t *journal)
if (journal->j_chksum_driver)
crypto_free_shash(journal->j_chksum_driver);
kfree(journal->j_wbuf);
kfree(journal);
kfree(journal_wrapper);
return err;
}
......
......@@ -105,6 +105,8 @@ typedef struct jbd2_journal_handle handle_t; /* Atomic operation type */
* This is an opaque datatype.
**/
typedef struct journal_s journal_t; /* Journal control structure */
typedef struct journal_wrapper_s journal_wrapper_t;
#endif
/*
......@@ -780,11 +782,6 @@ struct journal_s
*/
unsigned long j_flags;
/**
* @j_atomic_flags: Atomic journaling state flags.
*/
unsigned long j_atomic_flags;
/**
* @j_errno:
*
......@@ -1199,6 +1196,22 @@ struct journal_s
#endif
};
/**
* struct journal_wrapper_s - The wrapper of journal_s to fix KABI.
*/
struct journal_wrapper_s
{
/**
* @jw_journal: real journal.
*/
journal_t jw_journal;
/**
* @j_atomic_flags: Atomic journaling state flags.
*/
unsigned long j_atomic_flags;
};
#define jbd2_might_wait_for_commit(j) \
do { \
rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment