Commit 2a054c16 authored by Patrick Rohr's avatar Patrick Rohr Committed by Commit Bot

Fix fdsan Issue in Android Cast Shell

InitSharedInstanceWithPakFileRegion() takes ownership of the passed file
and assigns it to a static instance variable. This means that the next
time base::File(pake_fd) is called on line 250, the file descriptor
already has an owner (and a FdEntry respectively) and
android_fdsan_exchange_owner_tag fails
(in order to prevent a double close. See bionic/libc/bionic/fdsan.cpp
for further information).

Duplicating the file descriptor before calling
InitSharedInstanceWithPakFileRegion should prevent this problem.

Test: Tested on device. Casting a few times back to back does not
trigger the error, while without the fix the error is thrown right away.

Bug: b/142898745
Change-Id: I153ed21eaaa5280d63a296d272cd4f7b46d67859
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003321Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Commit-Queue: Patrick Rohr <prohr@google.com>
Cr-Commit-Position: refs/heads/master@{#732757}
parent 82457287
......@@ -244,10 +244,12 @@ void CastMainDelegate::InitializeResourceBundle() {
base::MemoryMappedFile::Region pak_region;
if (pak_fd >= 0) {
pak_region = global_descriptors->GetRegion(kAndroidPakDescriptor);
ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
pak_region);
base::File android_pak_file(pak_fd);
ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(
android_pak_file.Duplicate(), pak_region);
ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P);
std::move(android_pak_file), pak_region, ui::SCALE_FACTOR_100P);
return;
} else {
pak_fd = base::android::OpenApkAsset("assets/cast_shell.pak", &pak_region);
......
Markdown is supported
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