Commit Graph
4539 Commits
Author SHA1 Message Date
Aleksander Morgado 1532545efa base-sim: fix loading GID2
We were not even trying to load it if GID1 was successfully loaded.
2022-10-27 11:22:16 +02:00
Aleksander Morgado 1bc9df2a08 sim-mbim: read exact GID1/GID2 file size 2022-10-27 11:22:16 +02:00
Akash Aggarwal cce9ba475d mm-broadband-modem-qmi: do not set "enable refresh" in PDC "register" QMI message
If "enable refresh" is set, QMI modem expects an acknowledgement upon receiving a PDC refresh indication,
otherwise the modem resets assuming clients are facing an issue in refreshing their cache.

Register for PDC refresh indication without setting "enable refresh" TLV.
We would still receive the refresh indication to notify that the list of profiles stored has changed and
would not have to acknowledge the modem.
2022-10-27 11:07:07 +05:30
Aleksander Morgado c73cbcc309 core: update copyright years 2022-10-19 11:18:38 +00:00
Akash Aggarwal 034383a650 broadband-modem-qmi: support for setting up signal thresholds 2022-10-18 15:54:37 +05:30
Akash Aggarwal 04ed52a74c mm-iface-modem: always require a SIM card in 3GPP modules
Avoid removing 3GPP capabilities if sim is absent.
Transition to 'Failed' state for 3GPP capable devices if sim is absent.
2022-10-11 11:55:28 +05:30
Fanice.luo fab0481027 foxconn: remove QMI_SERVICE_FOX from Generic MBIM modem object
Allocate the fox_client to attempt loading the firmware info using
QMI_SERVICE_FOX,and release it when no longer needed.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/599
2022-10-10 11:46:57 +00:00
Aleksander Morgado 1db9cf4689 sms-part-3gpp: coding style fixes 2022-10-06 09:18:38 +00:00
Aleksander Morgado 795103cf3a broadband-modem-mbim: ensure message array contains valid PDUs
When reading SMS PDUs during initialization or upon a notification of
a new PDU arriving, we should ensure that the array of messages
returned is of type PDU, and also validate whether the array contains
valid PDUs before processing them, otherwise we could be dereferencing
invalid memory.

This is trying to fix crashes like the following:

    0x000059502b7ebaa2(ModemManager -mm-broadband-modem-mbim.c:7816)add_sms_part
    0x000059502b7f5cf5(ModemManager -mm-broadband-modem-mbim.c:7849)sms_read_query_ready
    0x000079e48edb36d3(libgio-2.0.so.0 -gtask.c:1230)g_task_return_now
    0x000079e48edb2732(libgio-2.0.so.0 -gtask.c:1300)g_task_return
    0x000079e48ee64ce5(libmbim-glib.so.4 -mbim-device.c:240)transaction_task_complete_and_free
    0x000079e48ee6665f(libmbim-glib.so.4 -mbim-device.c:1017)data_available
    0x000079e48ec65463(libglib-2.0.so.0 -gmain.c:3417)g_main_context_dispatch
    0x000079e48ec6576e(libglib-2.0.so.0 -gmain.c:4211)g_main_context_iterate
    0x000079e48ec659e2(libglib-2.0.so.0 -gmain.c:4411)g_main_loop_run
    0x000059502b7796b1(ModemManager -main.c:217)main
    0x000079e48e9f77a7(libc.so.6 + 0x000227a7)__libc_start_main
    0x000059502b7794b9(ModemManager + 0x0005f4b9)_start
    0x00007ffef825c6a7
2022-10-06 11:12:48 +02:00
Aleksander Morgado 125ef27274 sim-mbim: fix race condition when sync requested during preload
This is an extremely tricky race condition.

 * During SIM object initialization, we try to load SIM type (first
   item loaded).
 * MMSimMbim SIM type loading step runs preload_subscriber_info(),
   which:
   ** Sets self->priv->preload = TRUE; so that it is not run anymore.
   ** Sets the sync monitor to clear preloaded info if sync needed.
   ** Runs the subscriber ready status operation asynchronously.
   ** Just before the subscriber ready status operation returns, the
      system goes to sleep.
   ** The resume logic kicks in, and we flag the modem with sync
      needed, which clears the self->priv->preload flag.
 * Then the subscriber ready status operation response arrives, and we
   store the IMSI and the other things.
 * When the next initialization step happens, given that
   self->priv->preload is cleared, we run attempt to run
   preload_subscriber_info() again, and this time it finds the info like
   IMSI is already set, so asserts:

    0x00007cbcd287523f (libglib-2.0.so.0 - gtestutils.c: 3253)      g_assertion_message
    0x00007cbcd28752a2 (libglib-2.0.so.0 - gtestutils.c: 3279)      g_assertion_message_expr
    0x00005cbdab0a2dc0 (ModemManager - mm-sim-mbim.c: 253)  subscriber_ready_status_ready
    0x00007cbcd29a173b (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
    0x00007cbcd29a0799 (libgio-2.0.so.0 - gtask.c: 1300)    g_task_return
    0x00007cbcd2a548e0 (libmbim-glib.so.4 - mbim-device.c: 264)     transaction_task_complete_and_free
    0x00007cbcd2a562fc (libmbim-glib.so.4 - mbim-device.c: 1047)    data_available
    0x00007cbcd28534a6 (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
    0x00007cbcd28537b1 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
    0x00007cbcd2853a25 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
    0x00005cbdab034d26 (ModemManager - main.c: 217) main
    0x00007cbcd25e16c5 (libc.so.6 + 0x000286c5)     __libc_init_first
    0x00007cbcd25e1781 (libc.so.6 + 0x00028781)     __libc_start_main
    0x00005cbdab034a40 (ModemManager + 0x00061a40)  _start

In order to solve this, upon a sync request the ongoing preload
operation will be cancelled.
2022-10-05 13:12:09 +00:00
Aleksander Morgado eee9a6f6b4 iface-modem-3gpp: disallow Scan() or Register() if Locked
We are exporting the 3GPP interface even when locked, so we should
cleanly disallow the Scan() and Register() operations on that state,
instead of wrongly assuming they may never happen.

  0x00007c192134944a (libc.so.6 + 0x0003744a)     gsignal
  0x00007c19213344e8 (libc.so.6 + 0x000224e8)     abort
  0x00007c19215c4221 (libglib-2.0.so.0 - gtestutils.c: 3253)      g_assertion_message
  0x00007c19215c4284 (libglib-2.0.so.0 - gtestutils.c: 3279)      g_assertion_message_expr
  0x00005b3eec9c9fbc (ModemManager - mm-iface-modem-3gpp.c)       handle_scan_auth_ready
  0x00007c19216ef75b (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x00007c19216ee7b9 (libgio-2.0.so.0 - gtask.c: 1300)    g_task_return
  0x00005b3eec99a5ef (ModemManager - mm-dispatcher-fcc-unlock.c: 69)      dispatcher_run_ready
  0x00007c19216ef75b (libgio-2.0.so.0 - gtask.c: 1230)    g_task_return_now
  0x00007c19216ef78e (libgio-2.0.so.0 - gtask.c: 1244)    complete_in_idle_cb
  0x00007c19215a2486 (libglib-2.0.so.0 - gmain.c: 3417)   g_main_context_dispatch
  0x00007c19215a2791 (libglib-2.0.so.0 - gmain.c: 4211)   g_main_context_iterate
  0x00007c19215a2a05 (libglib-2.0.so.0 - gmain.c: 4411)   g_main_loop_run
  0x00005b3eec998451 (ModemManager - main.c: 217) main
  0x00007c19213347a7 (libc.so.6 + 0x000227a7)     __libc_start_main
  0x00005b3eec998259 (ModemManager + 0x00060259)  _start

Fixes 83e7600a67
2022-10-05 11:04:20 +00:00
Angus Ainslie 4628056a3e mm-modem-helpers.c: adjust the RING regex
The Broadmobi BM818 has some additional carriage returns in the RING message

Fixes: #626

Signed-off-by: Angus Ainslie <angus@akkea.ca>
2022-09-30 14:29:39 -06:00
Aleksander Morgado a74f11ae43 sim-mbim: fallback to AT commands if reading GID via MBIM fails
Older MBIM modems don't support the low level UICC reading extension
defined by Microsoft. In those case, fallback to reading the GID
values using AT commands wherever possible.
2022-09-30 13:51:56 +00:00
Aleksander Morgado fa6d64550b base-sim: implement GID1 and GID2 loading using AT commands 2022-09-30 13:51:56 +00:00
Aleksander Morgado 2c66d43bb9 broadband-modem-qmi: select last used level when enabling SAR
Same as we do in the MBIM protocol implementation.
2022-09-27 08:28:07 +00:00
Aleksander Morgado 1ea5a577e3 iface-modem-sar: report updated level on SAR enable
The SAR enable operation may be selecting an explicit SAR level by
itself, so make sure the protocol implementation reports back to the
interface the default level that was used while enabling SAR.

No level change is reported in the interface if the SAR is being
disabled.
2022-09-27 08:28:07 +00:00
Aleksander Morgado 950d36d4ee iface-modem-sar: avoid changing level if already in the target level 2022-09-27 08:28:07 +00:00
Aleksander Morgado 72457c25f4 iface-modem-sar: avoid changing state if already in the target state 2022-09-27 08:28:07 +00:00
Aleksander Morgado b50c24acd1 iface-modem-sar: disallow changing SAR level if SAR disabled
This was already forbidden in the MBIM implementation, and we should
also have it in the QMI implementation, so just make it a generic
check in the interface.
2022-09-27 08:28:07 +00:00
Aleksander Morgado 0994087f18 iface-modem-sar: fix set power level async method completion
Not a big deal because both enable_finish() and set_power_level()
finish were doing the same thing until a recent change.
2022-09-27 08:28:07 +00:00
Aleksander Morgado 258b8f8ee5 broadband-modem-qmi: attempt to preallocate SAR client
Otherwise the SAR support check will fail.
2022-09-27 08:28:07 +00:00
Madhav 04e7f777be broadband-modem-qmi: Implement the SAR interface
Implement the sar interface for QMI modems.
2022-09-27 08:28:07 +00:00
Aleksander Morgado 4a36f50de8 iface-modem-3gpp-profile-manager: fix requested IP type normalization
mm_iface_modem_3gpp_profile_manager_set_profile() was changed so that
the input profile object was not touched, and instead a copy of the
same would be used within the method.

Unfortunately, that change missed the update of the IP type
normalization step, which would end up modifying the original settings
instead of the newly created copy.

Fixes 7464940971
2022-09-26 08:49:47 +00:00
Aleksander Morgado 7b0b3e7e48 iface-modem-3gpp: helpers to check if specific domains are supported 2022-09-20 14:09:41 +00:00
Aleksander Morgado 1fa67b3842 iface-modem-3gpp: allow applying domain registration updates altogether
When processing QMI and MBIM messages to report domain registration
updates, we should do that altogether so that we don't report bogus
transitions to idle if the registration state switches from one domain
to another.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/629
2022-09-20 14:09:41 +00:00
Aleksander Morgado 453e8bc7d1 iface-modem-3gpp: fix clearing 5GS reg status if explicit registration fails 2022-09-20 14:09:41 +00:00
Jack Song ab80c31898 mm-iface-modem: don't attempt to check lock status when current active slot have eSIM without profiles
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/630
2022-09-19 16:11:48 +08:00
Alexey Orishko 4ab2c80858 enum, bearer: added non-ip bearer 2022-09-16 10:52:56 +00:00
Andrey Skvortsov 22ba849724 charsets: Add test_text_split_two_pdu_gsm7_extended_chars to use extended character 2022-09-13 20:49:01 +00:00
Andrey Skvortsov 4ebf8ca4e0 sms: fix spliting messages into chunks in gsm7 encoding
1) Not every allowed GSM7 character in UTF-8 incoding takes one
byte. Some (for example, 'à') take several bytes in input string, but
signle byte in GSM7.
2) Extended characters in GSM7 encoding take two bytes.

Otherwise for example sending following SMS fails:

```
 mmcli -m a --messaging-create-sms="text='[wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',number='+XXXXXXXXXXX'"
Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/99
 mmcli --send -s 99
error: couldn't send the SMS: 'GDBus.Error:org.freedesktop.libqmi.Error.Protocol.WmsEncoding: Couldn't write SMS part: QMI protocol error (58): 'WmsEncoding''
```

```
mmcli -m a --messaging-create-sms="text='|àààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà',number='+XXXXXXXXXXX'"
Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/72
mmcli --send -s 72
error: couldn't send the SMS: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.InvalidArgs: Couldn't convert UTF-8 to GSM: input UTF-8 validation failed'
```
2022-09-13 20:49:01 +00:00
Andrey Skvortsov 2ece78c80f charsets: move mm_sms_part_3gpp_util_split_text to mm_charset_util_split_text 2022-09-13 20:49:01 +00:00
Aleksander Morgado 9f5a84f777 sim-mbim: implement loading GID1 and GID2 of active SIM 2022-09-12 08:41:38 +00:00
Aleksander Morgado 6e04142a96 sim-mbim: preload id of active UICC application
This would be the application id that refers to the active SIM card.
2022-09-12 08:41:38 +00:00
Akash Aggarwal af9b6d4f2d mm-bearer-qmi: Add Support for PCO
Get PCO information after the call is established
by using get runtime settings request
Register for Extended IP configuration Indication

If PCO is changed we get the indication and refetch
the pco information from modem

Send the PCO info using 3gpp_update_pco_list
2022-09-09 18:51:26 +05:30
Aleksander Morgado 61e540c8d9 sim-mbim: minor coding style fix 2022-09-08 14:06:31 +00:00
Aleksander Morgado cb676b5964 modem-helpers-mbim: add new MBIM PIN types 2022-09-07 22:35:20 +00:00
Aleksander Morgado 9bbc768666 modem-helpers: rework the +CGEV indication parser
We setup all output variables with g_autofree and then use
g_steal_pointer() to return the needed ones.
2022-09-05 17:37:14 +00:00
Aleksander Morgado 845667c7b3 modem-helpers: rework +CGCONTRDP response parser
We setup all output variables with g_autofree and then use
g_steal_pointer() to return the needed ones.
2022-09-05 17:37:14 +00:00
Aleksander Morgado 74fc5baca2 core: port GRegex/GMatchInfo to use autoptr()
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1
to pcre2. In some cases it was made more strict, which is fine, in
other cases it exposed some change in how it behaves on certain
matches that is not extremely clear whether it's ok or not.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621

Either way, one thing that was assumed was that initializing all
GRegex/GMatchInfo variables to NULL and making sure they're NULL
before they're initialized by glib (especially the GMatchInfo) was a
good and safer approach.

So, whenever possible, g_autoptr() is used to cleanup the allocated
GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used
to ensure that no free/unref is attempted unless the given variable is
not NULL, and also so that the variable is reseted to NULL after being
disposed.
2022-09-05 17:33:11 +00:00
Akash Aggarwal b2a186b5c8 mm-broadband-modem-qmi: fix updating access technology and location
Access technology and location properties are updated if modem is in
registered state.

Cache and update them when processing DSD system status indication.
2022-09-05 13:00:54 +00:00
Aleksander Morgado 51a333cd9a test-modem-helpers: add EOL to strings matched with G_REGEX_NEWLINE_CRLF
Looks like pcre2 (used since glib 2.73.2) requires EOLs to match if
G_REGEX_NEWLINE_CRLF is explicitly used. The tests are updated
accordingly, because the modem responses will anyway have the EOLs
as well.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729#note_1544130

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
2022-09-02 17:23:56 +02:00
Aleksander Morgado 79a5a4eed2 serial-parsers: fix invalid EXZ error parser
Passed undetected when glib2 was using pcre1, it triggers an error now
with pcre2.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729#note_1542038

Reported and fix suggested by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2022-09-01 15:06:04 +02:00
Akash Aggarwal e68cee832b mm-iface-modem-3gpp: fix packet service state updation
Modem could be in 'registered' state if CS is 'attached',
but packet service state might be 'detached'.

Check if packet service state needs to be updated in
update_registration_state(), even if registration state is same.

Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/618
2022-08-26 15:15:41 +02:00
Aleksander Morgado 87ced3dff7 sim-qmi: rework Read Transparent processing to use g_autoptr() 2022-08-25 16:00:37 +00:00
Aleksander Morgado 14d9b2d5d7 sim-qmi: fix leak of the GArray containing the GID
Fixes 3238ccdbb2
2022-08-25 15:53:08 +00:00
Akash Aggarwal b9173176c2 mm-log: hiding personal info while logging for QMI modem 2022-08-25 17:19:57 +02:00
Aleksander Morgado ec50f14807 base-modem: fix double GError free during quick sync
==10719== Invalid free() / delete / delete[] / realloc()
  ==10719==    at 0x4897D88: free (vg_replace_malloc.c:872)
  ==10719==    by 0x52F091B: g_free (gmem.c:220)
  ==10719==    by 0x530C36B: g_slice_free1 (gslice.c:1185)
  ==10719==    by 0x52D632B: g_error_free (gerror.c:872)
  ==10719==    by 0x192DBF: UnknownInlinedFun (glib-autocleanups.h:54)
  ==10719==    by 0x192DBF: UnknownInlinedFun (glib-autocleanups.h:54)
  ==10719==    by 0x192DBF: sync_ready (mm-base-modem.c:671)
  ==10719==    by 0x50A82CB: g_task_return_now (gtask.c:1232)
  ==10719==    by 0x50A854B: UnknownInlinedFun (gtask.c:1301)
  ==10719==    by 0x50A854B: g_task_return (gtask.c:1258)
  ==10719==    by 0x50AAA4F: g_task_return_new_error (gtask.c:1944)
  ==10719==    by 0x1F44E3: iface_modem_sync_ready (mm-broadband-modem.c:12205)
  ==10719==    by 0x50A82CB: g_task_return_now (gtask.c:1232)
  ==10719==    by 0x50A854B: UnknownInlinedFun (gtask.c:1301)
  ==10719==    by 0x50A854B: g_task_return (gtask.c:1258)
  ==10719==    by 0x1AB86B: interface_syncing_step.lto_priv.0 (mm-iface-modem.c:4644)
  ==10719==  Address 0x910bf30 is 0 bytes inside a block of size 16 free'd
  ==10719==    at 0x4897D88: free (vg_replace_malloc.c:872)
  ==10719==    by 0x52F091B: g_free (gmem.c:220)
  ==10719==    by 0x530C36B: g_slice_free1 (gslice.c:1185)
  ==10719==    by 0x52D632B: g_error_free (gerror.c:872)
  ==10719==    by 0x17565F: UnknownInlinedFun (glib-autocleanups.h:54)
  ==10719==    by 0x17565F: UnknownInlinedFun (glib-autocleanups.h:54)
  ==10719==    by 0x17565F: base_modem_sync_ready (mm-base-manager.c:737)
  ==10719==    by 0x50A82CB: g_task_return_now (gtask.c:1232)
  ==10719==    by 0x50A854B: UnknownInlinedFun (gtask.c:1301)
  ==10719==    by 0x50A854B: g_task_return (gtask.c:1258)
  ==10719==    by 0x192DAB: sync_ready (mm-base-modem.c:674)
  ==10719==    by 0x50A82CB: g_task_return_now (gtask.c:1232)
  ==10719==    by 0x50A854B: UnknownInlinedFun (gtask.c:1301)
  ==10719==    by 0x50A854B: g_task_return (gtask.c:1258)
  ==10719==    by 0x50AAA4F: g_task_return_new_error (gtask.c:1944)
  ==10719==    by 0x1F44E3: iface_modem_sync_ready (mm-broadband-modem.c:12205)
  ==10719==  Block was alloc'd at
  ==10719==    at 0x48952CC: malloc (vg_replace_malloc.c:381)
  ==10719==    by 0x52F3EF3: g_malloc (gmem.c:127)
  ==10719==    by 0x530CD27: g_slice_alloc (gslice.c:1074)
  ==10719==    by 0x530D2B7: g_slice_alloc0 (gslice.c:1100)
  ==10719==    by 0x52D5E7B: g_error_allocate (gerror.c:710)
  ==10719==    by 0x52D690F: UnknownInlinedFun (gerror.c:724)
  ==10719==    by 0x52D690F: g_error_new_valist (gerror.c:766)
  ==10719==    by 0x50AAA43: g_task_return_new_error (gtask.c:1941)
  ==10719==    by 0x1F44E3: iface_modem_sync_ready (mm-broadband-modem.c:12205)
  ==10719==    by 0x50A82CB: g_task_return_now (gtask.c:1232)
  ==10719==    by 0x50A854B: UnknownInlinedFun (gtask.c:1301)
  ==10719==    by 0x50A854B: g_task_return (gtask.c:1258)
  ==10719==    by 0x1AB86B: interface_syncing_step.lto_priv.0 (mm-iface-modem.c:4644)
  ==10719==    by 0x1AB9A3: UnknownInlinedFun (mm-iface-modem.c:4543)
  ==10719==    by 0x1AB9A3: interface_syncing_step.lto_priv.0 (mm-iface-modem.c:4639)
2022-08-25 13:36:58 +00:00
Aleksander Morgado 90fb43ff9e broadband-modem-mbim: fix crash on register indication parsing failure
Found during code review.
2022-08-19 22:43:43 +00:00
Akash Aggarwal 20c558546c mm-shared-qmi: Fix current modes
Modem reports 2G+3G+4G+5G current modes, while 2G is not supported.

Consider device capabilities in deciding current modes.
2022-08-20 01:46:58 +05:30
Aleksander Morgado 3238ccdbb2 sim-qmi: implement loading GID1 and GID2 2022-08-19 15:53:43 +00:00