ext4: fix potential use after free in __ext4_journal_stop
authorLukas Czerner <lczerner@redhat.com>
Sun, 18 Oct 2015 02:57:06 +0000 (22:57 -0400)
committermobile promotions <svcmobile_promotions@nvidia.com>
Mon, 28 Nov 2016 17:26:17 +0000 (09:26 -0800)
commit3c15c37dc613cb75339f8e0d546ab30643e65b84
tree9686639e8325b7259b4d13d88636f985e308c7a0
parent15e376e5d8b1399d02814cf8b1481f7ac40dc483
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.

Bug 1823317

Change-Id: Ib6fe50ed8013943d5fc3459eb499ecda5533c6ef
Fixes: 9705acd63b125dee8b15c705216d7186daea4625
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Cc: stable@vger.kernel.org
Signed-off-by: Gagan Grover <ggrover@nvidia.com>
Reviewed-on: http://git-master/r/1259975
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
fs/ext4/ext4_jbd2.c