Skip to content

base-manager: fix crash when uninhibiting partially removed device

If the device is not fully removed from the system during inhibition and port additions happen, we reach a state where the MMDevice object is still tracked by ModemManager and we also have new port additions tracked that will require explicit port probings before a new modem object can be created.

Solve this mixup by faking the removal of all existing device ports, which will end up completely removing hte MMDevice, so that new port additions reported afterwards also involve the full device probing process triggered by the plugin manager.

The issue could be reproduced easily on a MBIM device that also exposed TTYs, as follows:

  • mmcli -m a --inhibit, leave it running
  • rmmod cdc_mbim && sleep 5 && modprobe cdc_mbim (so that the cdc-wdm and net ports go away from the system but NOT the TTYs.)
  • Cltr+C to stop the inhibit in the mmcli call.

ModemManager would assert as follows:

  0x000079918bcf2a3f (libc.so.6 + 0x00087a3f)     pthread_key_delete
  0x000079918bca7c6c (libc.so.6 + 0x0003cc6c)     gsignal
  0x000079918bc93462 (libc.so.6 + 0x00028462)     abort
  0x000079918bf26f03 (libglib-2.0.so.0 - gtestutils.c: 3253)      g_assertion_message
  0x000079918bf26f66 (libglib-2.0.so.0 - gtestutils.c: 3279)      g_assertion_message_expr
  0x0000594ff1093d0c (ModemManager - mm-base-manager.c: 1110)     remove_device_inhibition
  0x0000594ff1093968 (ModemManager - mm-base-manager.c: 1247)     inhibit_device_auth_ready
  0x000079918c0536a8 (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x000079918c0536db (libgio-2.0.so.0 - gtask.c: 1244)    complete_in_idle_cb
  0x000079918bf053fc (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
  0x000079918bf05704 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
  0x000079918bf05978 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
  0x0000594ff108de66 (ModemManager - main.c: 217) main
  0x000079918bc936c5 (libc.so.6 + 0x000286c5)     __libc_init_first
  0x000079918bc93781 (libc.so.6 + 0x00028781)     __libc_start_main
  0x0000594ff108db80 (ModemManager + 0x00061b80)  _start
Edited by Aleksander Morgado

Merge request reports