Skip to content

35.3.0 crash due to UaF in file_dialog::(anonymous namespace)::CheckPortalAvailabilityOnBusThread () (regression from 35.2.2) #47007

Closed

Description

@brjsp

Preflight Checklist

Electron Version

35.3.0

What operating system(s) are you using?

Other Linux

Operating System Version

openSUSE Tumbleweed

What arch are you using?

x64

Last Known Working Electron version

35.2.2

Expected Behavior

Electron upon start displays the about dialog

Actual Behavior

The main process, after printing the help message, immediately crashes with the following stack trace

#0  0x000055eb7e56d444 in dbus_utils::NameHasOwner (bus=0x0, name="org.freedesktop.portal.Desktop", callback=...) at ../../components/dbus/utils/name_has_owner.cc:42
#1  0x000055eb7e56d7bb in dbus_utils::CheckForServiceAndStart (bus=..., name="org.freedesktop.portal.Desktop", callback=...) at ../../base/memory/scoped_refptr.h:284
#2  0x000055eb7c98674c in file_dialog::(anonymous namespace)::CheckPortalAvailabilityOnBusThread () at ../../electron/shell/browser/ui/file_dialog_linux_portal.cc:66
#3  0x000055eb840b625d in base::OnceCallback<void ()>::Run() && (this=0x7fe2e0bf8ec8) at ../../third_party/blink/renderer/core/frame/local_dom_window.cc:193329985
#4  base::TaskAnnotator::RunTaskImpl(base::PendingTask&) [clone .isra.0] (pending_task=..., this=<optimized out>) at ../../base/task/common/task_annotator.cc:209
#5  0x000055eb7fa29511 in base::TaskAnnotator::RunTask<base::internal::TaskTracker::RunTaskImpl(base::internal::Task&, const base::TaskTraits&, base::internal::TaskSource*, const base::internal::SequenceToken&)::<lambda(perfetto::EventContext&)> > (
    this=0x17700009c648, event_name=..., pending_task=...) at ../../base/task/common/task_annotator.h:106
#6  base::internal::TaskTracker::RunTaskImpl (this=this@entry=0x17700009c640, task=..., traits=..., task_source=task_source@entry=0x177000100fc0, token=...) at ../../base/task/thread_pool/task_tracker.cc:691
#7  0x000055eb7fa29af5 in base::internal::TaskTracker::RunSkipOnShutdown (this=this@entry=0x17700009c640, task=..., traits=..., task_source=task_source@entry=0x177000100fc0, token=...) at ../../base/task/thread_pool/task_tracker.cc:676
#8  0x000055eb7fa31fce in base::internal::TaskTracker::RunTaskWithShutdownBehavior (this=0x17700009c640, task=..., traits=..., task_source=0x177000100fc0, token=...) at ../../base/task/thread_pool/task_tracker.cc:706
#9  base::internal::TaskTracker::RunTask (this=<optimized out>, task=..., task_source=0x177000100fc0, traits=...) at ../../base/task/thread_pool/task_tracker.cc:504
#10 0x000055eb7fa33403 in base::internal::TaskTracker::RunAndPopNextTask (this=0x17700009c640, task_source=...) at ../../base/task/thread_pool/task_tracker.cc:394
#11 base::internal::WorkerThread::RunWorker (this=0x1770000dea80) at ../../base/task/thread_pool/worker_thread.cc:473
#12 0x000055eb7fa341a5 in base::internal::WorkerThread::RunSharedWorker (this=<optimized out>) at ../../base/task/thread_pool/worker_thread.cc:369
#13 0x000055eb7fa342f8 in base::internal::WorkerThread::ThreadMain (this=0x1770000dea80) at ../../base/task/thread_pool/worker_thread.cc:342
#14 0x000055eb7f8b3b67 in base::(anonymous namespace)::ThreadFunc (params=<optimized out>) at ../../base/threading/platform_thread_posix.cc:103
#15 0x00007fe2eae99546 in start_thread (arg=<optimized out>) at pthread_create.c:448
#16 0x00007fe2eaf1d94c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Testcase Gist URL

No response

Additional Information

I am building Electron from source. I do not remember touching any of the crashing code, and my patches from 35.2.2 applied cleanly (aside from a missing STL include causing one build error).

The offending code was added in commit cd871fd.

Activity

  1. added theissue type on May 8, 2025
  2. brjsp commented on May 8, 2025

    @brjsp
    ContributorAuthor

    This is the offending code:

      dbus_utils::CheckForServiceAndStart(
          bus, kXdgPortalService,
          base::BindOnce(
              [](scoped_refptr<dbus::Bus> bus, base::AtomicFlag* flag,
                 std::optional<bool> name_has_owner) {
               // …
              },
              std::move(bus), flag));

    the bus is passed to CheckForServiceAndStart after already being moved from inside the functor's constructor. The bus's contained pointer is 0 after the scoped_refptr's move constructor executes.

  3. changed the title [-]35.3.0 crash in dbus_util::NameHasOwner (regression from 35.2.2)[/-] [+]35.3.0 crash due to UaF in `file_dialog::(anonymous namespace)::CheckPortalAvailabilityOnBusThread ()` (regression from 35.2.2)[/+] on May 8, 2025
  4. self-assigned this
    on May 8, 2025
  5. added
    status/confirmed
    on May 8, 2025
  6. moved this to 👀 Unsorted Items in 37-x-yon May 8, 2025
  7. moved this to 👀 Unsorted Items in 36-x-yon May 8, 2025
  8. deepak1556 commented on May 8, 2025

    @deepak1556
    Member

    Sorry for the regression, will have a fix up shortly.

  9. deepak1556 commented on May 8, 2025

    @deepak1556
    Member

    @brjsp can you validate the change from #47008 in your build. Thanks!

  10. nikwen commented on May 8, 2025

    @nikwen
    Member

    @brjsp For our internal testing, would you be able to make a testcase gist with Electron Fiddle that allows us to reproduce the crash and verify the fix? Thank you so much in advance!

    EDIT: @deepak1556 told me the code path will always execute once on startup for Linux. No further repro needed in that case. The simple "hello world" Fiddle example will trigger the code path.

  11. brjsp commented on May 8, 2025

    @brjsp
    ContributorAuthor

    the official binaries don't crash. Whether this code gets misoptimized is hard to predict since it may depend both on the compiler used and on stuff like which function gets inlined first.

  12. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 36-x-yon May 14, 2025
  13. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 37-x-yon May 14, 2025
  14. moved this from 👍 Does Not Block Stable to 🛠️ Fixed for Next Release in 37-x-yon May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

35-x-y36-x-y37-x-ybug 🪲component/dialogcrash 💥platform/linuxstatus/confirmed

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions