Skip to content
Commit b8e7ed42 authored by void0red's avatar void0red Committed by Greg Kroah-Hartman
Browse files

btrfs: fix extent map use-after-free when handling missing device in read_one_chunk

[ Upstream commit 1742e1c9 ]

Store the error code before freeing the extent_map. Though it's
reference counted structure, in that function it's the first and last
allocation so this would lead to a potential use-after-free.

The error can happen eg. when chunk is stored on a missing device and
the degraded mount option is missing.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216721


Reported-by: default avatareriri <1527030098@qq.com>
Fixes: adfb69af ("btrfs: add_missing_dev() should return the actual error")
CC: stable@vger.kernel.org # 4.9+
Signed-off-by: default avatarvoid0red <void0red@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9c3beebd
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment