ext4: fix potential use after free in __ext4_journal_stop
PATCH 1/1 ext4: fix potential use after free in __ext4_journal_stop
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.
--- fs/ext4/ext4_jbd2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/ext4_jbd2.c +3 -3
@@ -88,13 +88,13 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)return 0 ; } + err = handle->h_err;if (!handle->h_transaction) { - err =jbd2_journal_stop (handle); -return handle->h_err ? handle->h_err : err; + rc =jbd2_journal_stop (handle); +return err ? err : rc; } sb = handle->h_transaction->t_journal->j_private; - err = handle->h_err; rc =jbd2_journal_stop (handle);if (!err)
Signature · 1 line
1.8.3.1
Quoted 6 lines · Lukas Czerner
Date: Wed, 2 Sep 2015 16:45:54 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: Lukas Czerner <[email protected]>
Subject: [PATCH] ext4: fix potential use after free in__ext4_journal_stop
Quoted 6 lines
There is a use-after-free possibility in
__ext4_journal_stop()in the case that we free the handle in the firstjbd2_journal_stop()because we're referencinghandle->h_errafterwards. This was introduced in9705acd63b125dee8b15c705216d7186daea4625and it is wrong. Fix it by storing thehandle->h_errvalue beforehand and avoid referencing potentially freed handle.
ping
-Lukas
Quoted 28 lines
Signed-off-by Lukas Czerner <[email protected]>--- fs/ext4/ext4_jbd2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/ext4/ext4_jbd2.c +3
-3@@ -88,13 +88,13 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)return 0 ; } + err = handle->h_err;if (!handle->h_transaction) { - err =jbd2_journal_stop (handle); -return handle->h_err ? handle->h_err : err; + rc =jbd2_journal_stop (handle); +return err ? err : rc; } sb = handle->h_transaction->t_journal->j_private; - err = handle->h_err; rc =jbd2_journal_stop (handle);if (!err)
Andreas Dilger
Reviewed-byQuoted 11 lines · Lukáš Czerner
Quoted 6 lines · Lukas Czerner
Date: Wed, 2 Sep 2015 16:45:54 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: Lukas Czerner <[email protected]>
Subject: [PATCH] ext4: fix potential use after free in__ext4_journal_stop
Quoted 10 lines
Quoted 6 lines
There is a use-after-free possibility in
__ext4_journal_stop()in the case that we free the handle in the firstjbd2_journal_stop()because we're referencinghandle->h_errafterwards. This was introduced in9705acd63b125dee8b15c705216d7186daea4625and it is wrong. Fix it by storing thehandle->h_errvalue beforehand and avoid referencing potentially freed handle.ping
Quoted 2 lines
Signed-off-by Lukas Czerner <[email protected]>
Quoted 24 lines
Quoted 24 lines
---
fs/ext4/ext4_jbd2.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)fs/ext4/ext4_jbd2.c +3
-3@@ -88,13 +88,13 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle)return 0 ; } + err = handle->h_err;if (!handle->h_transaction) { - err =jbd2_journal_stop (handle); -return handle->h_err ? handle->h_err : err; + rc =jbd2_journal_stop (handle); +return err ? err : rc; } sb = handle->h_transaction->t_journal->j_private; - err = handle->h_err; rc =jbd2_journal_stop (handle);
Quoted 6 lines
fs/ext4/ext4_jbd2.c int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) · line 100
Quoted 2 lines
fs/ext4/ext4_jbd2.c +0
-0if (!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
Cheers, Andreas
Quoted 16 lines · Andreas Dilger
Quoted 16 lines · Lukáš Czerner
Quoted 12 lines · Lukas Czerner
Date: Wed, 2 Sep 2015 16:45:54 +0200
From: Lukas Czerner <[email protected]>
To: [email protected]
Cc: Lukas Czerner <[email protected]>
Subject: [PATCH] ext4: fix potential use after free in__ext4_journal_stopThere is a use-after-free possibility in
__ext4_journal_stop()in the case that we free the handle in the firstjbd2_journal_stop()because we're referencinghandle->h_errafterwards. This was introduced in9705acd63b125dee8b15c705216d7186daea4625and it is wrong. Fix it by storing thehandle->h_errvalue beforehand and avoid referencing potentially freed handle.
Quoted 5 lines
Quoted 3 lines
ping
Quoted 2 lines
Signed-off-by Lukas Czerner <[email protected]>Reviewed-by Andreas Dilger <[email protected]>
Applied, thanks.
- Ted
--
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