summaryrefslogtreecommitdiff
path: root/net/switchdev/switchdev.c
diff options
context:
space:
mode:
authorSahitya Tummala <stummala@codeaurora.org>2016-12-07 11:34:08 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-02-05 19:13:43 -0800
commitcd899455944cf33d6adf0fea3be84f70e04a800c (patch)
treed6a7de63774b3bc52bcdebe65d4ff003325d8846 /net/switchdev/switchdev.c
parent2e47ba9a64f870431dd7709f454ba51dca0f89e9 (diff)
jbd2: Fix use after free in kjournald2()
Below is the synchronization issue between unmount and kjournald2 contexts, which results into use after free issue in kjournald2(). Fix this issue by using journal->j_state_lock to synchronize the wait_event() done in journal_kill_thread() and the wake_up() done in kjournald2(). TASK 1: umount cmd: |--jbd2_journal_destroy() { |--journal_kill_thread() { write_lock(&journal->j_state_lock); journal->j_flags |= JBD2_UNMOUNT; ... write_unlock(&journal->j_state_lock); wake_up(&journal->j_wait_commit); TASK 2 wakes up here: kjournald2() { ... checks JBD2_UNMOUNT flag and calls goto end-loop; ... end_loop: write_unlock(&journal->j_state_lock); journal->j_task = NULL; --> If this thread gets pre-empted here, then TASK 1 wait_event will exit even before this thread is completely done. wait_event(journal->j_wait_done_commit, journal->j_task == NULL); ... write_lock(&journal->j_state_lock); write_unlock(&journal->j_state_lock); } |--kfree(journal); } } wake_up(&journal->j_wait_done_commit); --> this step now results into use after free issue. } Change-Id: I7487aff6f946544cfcfc38a9f28769be762e3969 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Diffstat (limited to 'net/switchdev/switchdev.c')
0 files changed, 0 insertions, 0 deletions