• Patrick Rohr's avatar
    Fix fdsan Issue in Android Cast Shell · 2a054c16
    Patrick Rohr authored
    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}
    2a054c16
cast_main_delegate.cc 11.3 KB