ext4:fix use after free in __ext4_journal_stop
authorAmulya Y <ayarlagadda@nvidia.com>
Thu, 5 Apr 2018 22:06:13 +0000 (15:06 -0700)
committerWinnie Hsu <whsu@nvidia.com>
Thu, 19 Apr 2018 17:01:26 +0000 (10:01 -0700)
commitc89a160df8862708602fe8857747251c8b481f7d
treea98bda7dbee737cb746a50846ebb3efc1cf3048b
parentcc6fff57cf0a8bcee5ebd7edd963f6f2deee0961
ext4:fix 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>
Signed-off-by: Amulya Yarlagadda <ayarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/1259975
(cherry picked from commit 3c15c37dc613cb75339f8e0d546ab30643e65b84)
Reviewed-on: https://git-master.nvidia.com/r/1689577
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
fs/ext4/ext4_jbd2.c