aboutsummaryrefslogtreecommitdiff
path: root/fs/ext4/ext4_jbd2.c
Commit message (Collapse)AuthorAgeFilesLines
* UPSTREAM: ext4: fix potential use after free in __ext4_journal_stopLukas Czerner2017-12-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | There is a use-after-free possibility in __ext4_journal_stop() in the case that we free the handle in the first jbd2_journal_stop() because we're referencing handle->h_err afterwards. This was introduced in 9705acd63b125dee8b15c705216d7186daea4625 and it is wrong. Fix it by storing the handle->h_err value beforehand and avoid referencing potentially freed handle. Fixes: 9705acd63b125dee8b15c705216d7186daea4625 Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Cc: stable@vger.kernel.org (cherry picked from commit 6934da9238da947628be83635e365df41064b09b) Signed-off-by: Bernie Thompson <bhthompson@google.com> Change-Id: I788135d7558d1c6ddcdef4366e106b17e9df80a5 Reviewed-on: https://chromium-review.googlesource.com/412985 Commit-Ready: Bernie Thompson <bhthompson@chromium.org> Tested-by: Bernie Thompson <bhthompson@chromium.org> Reviewed-by: Bernie Thompson <bhthompson@chromium.org> Signed-off-by: Joe Maples <joe@frap129.org>
* UPSTREAM: ext4: fix NULL pointer dereference when journal restart failsLukas Czerner2017-12-311-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when journal restart fails, we'll have the h_transaction of the handle set to NULL to indicate that the handle has been effectively aborted. We handle this situation quietly in the jbd2_journal_stop() and just free the handle and exit because everything else has been done before we attempted (and failed) to restart the journal. Unfortunately there are a number of problems with that approach introduced with commit 41a5b913197c "jbd2: invalidate handle if jbd2_journal_restart() fails" First of all in ext4 jbd2_journal_stop() will be called through __ext4_journal_stop() where we would try to get a hold of the superblock by dereferencing h_transaction which in this case would lead to NULL pointer dereference and crash. In addition we're going to free the handle regardless of the refcount which is bad as well, because others up the call chain will still reference the handle so we might potentially reference already freed memory. Moreover it's expected that we'll get aborted handle as well as detached handle in some of the journalling function as the error propagates up the stack, so it's unnecessary to call WARN_ON every time we get detached handle. And finally we might leak some memory by forgetting to free reserved handle in jbd2_journal_stop() in the case where handle was detached from the transaction (h_transaction is NULL). Fix the NULL pointer dereference in __ext4_journal_stop() by just calling jbd2_journal_stop() quietly as suggested by Jan Kara. Also fix the potential memory leak in jbd2_journal_stop() and use proper handle refcounting before we attempt to free it to avoid use-after-free issues. And finally remove all WARN_ON(!transaction) from the code so that we do not get random traces when something goes wrong because when journal restart fails we will get to some of those functions. Cc: stable@vger.kernel.org Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz> (cherry picked from commit 9d506594069355d1fb2de3f9104667312ff08ed3) Signed-off-by: Bernie Thompson <bhthompson@google.com> Change-Id: Ic0b0f902ccbacb6d5f3388e601464e203b78ccf0 Reviewed-on: https://chromium-review.googlesource.com/412984 Commit-Ready: Bernie Thompson <bhthompson@chromium.org> Tested-by: Bernie Thompson <bhthompson@chromium.org> Reviewed-by: Bernie Thompson <bhthompson@chromium.org> Signed-off-by: Joe Maples <joe@frap129.org>
* BACKPORT: ext4 from 3.18 to mtk-3.10Mister Oyster2017-05-271-23/+64
|
* ext4: fix potential use after free in __ext4_journal_stopLukas Czerner2016-11-171-1/+7
| | | | | | | | | | | | | | | | There is a use-after-free possibility in __ext4_journal_stop() in the case that we free the handle in the first jbd2_journal_stop() because we're referencing handle->h_err afterwards. This was introduced in 9705acd63b125dee8b15c705216d7186daea4625 and it is wrong. Fix it by storing the handle->h_err value beforehand and avoid referencing potentially freed handle. Issue: CYNGNOS-3304 Change-Id: I6e969a7f6214479d6b60627307327e5b720e338c Fixes: 9705acd63b125dee8b15c705216d7186daea4625 Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Cc: stable@vger.kernel.org
* first commitMeizu OpenSource2016-08-151-0/+274