Commit Graph
5387 Commits
Author SHA1 Message Date
shuihan-001 efe507c240 qmi-shared: fix crash when passing a wrong log object
The patch resolves a coredump caused by using 'client' instead of 'self'
in mm_obj_warn() call when failing to register tracking events.

Signed-off-by: shuihan-001 <xing1989093@outlook.com>
2026-08-30 10:13:59 -05:00
Семён Марьясин a879fb717f Sierra Wireless EM7305: support ICCID response without !
On my modem, AT!ICCID? command gives response without a preceding `!`:

```
AT!ICCID?
ICCID: 8970162010103256136

OK
```

Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
2026-08-30 09:54:17 -05:00
Semyon Maryasin 6a14658a42 broadband-modem-mbim: initialize autofreed string to NULL
device_caps_query_ready() declares caps_custom_data_class_str as
g_autofree without an initializer. On every early error return
(command failure such as a transaction timeout or NotOpened, or a
response parse failure) the variable is never assigned, so the
autofree cleanup runs g_free() on uninitialized stack garbage,
crashing ModemManager with a glibc "invalid free" abort (or SIGSEGV)
whenever the device caps query fails during modem initialization.

Fixes: 19c817cfe9 ("broadband-modem-mbim: consistently handle custom data classes")
Closes: #1094

Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
2026-08-30 09:49:13 -05:00
Nikolay Savchenko d446e495eb altair: add ALT3100 USB product ID
Signed-off-by: Nikolay Savchenko <n.savchenko@axioma.lv>
2026-08-03 02:13:16 +03:00
Andrey Skvortsov 893ca6bdb0 mm-shared-qmi: fix error message for xtra data injection timeout
Most likely it was copied from set supl server code.

Signed-off-by: Andrey Skortsov <andrej.skvortzov@gmail.com>
2026-07-21 12:02:41 +02:00
Aleksander Morgado 5bb7ece8b4 cinterion: fix heap double-free during GPS location disablement
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1077

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-13 11:22:25 +00:00
Aleksander Morgado 9642ed9ab5 ublox: fix UAF in custom init ready URC handler
Clear the unsolicited message handler in ready_received() before
completing the task. Otherwise, if the modem sends subsequent READY
URCs, the handler would fire again using the freed GTask pointer.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1074

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado db72a182c1 port-serial-at: fix crash if URC handler is cleared mid-dispatch
Update parse_unsolicited() to re-check handler->callback on each
iteration of the match dispatch loop. If a URC handler callback clears
itself during dispatch (e.g. to stop listening), subsequent matches in
the same buffer would attempt to call the NULL pointer, causing a crash.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1074

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado c3e7ffaae0 plugins: fix GError double-frees when returning errors from tasks
Use g_steal_pointer() when passing g_autoptr(GError) to
g_task_return_error() to prevent double-free by the automatic cleanup.

GTask takes ownership of the passed GError. If we use g_autoptr(GError)
locally, it will also call g_error_free() when the function returns,
causing a double-free / heap corruption. Stealing the pointer clears the
local variable and prevents the automatic cleanup.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1073

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado 166d6c5bc8 quectel: fix UAF in RDY URC handler
Defer the validity change (which triggers modem reprobe/removal) to an
idle callback in rdy_handler().

Calling mm_base_modem_set_valid(FALSE) synchronously from the URC
handler triggers the immediate destruction of the modem object while the
serial port is still iterating the unsolicited message handlers. Deferring
the operation to an idle callback and taking a reference to the modem
ensures the modem object is kept alive until parse_unsolicited() has
returned.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1072

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado 46a91399ca shared-qmi: fix UAF on duplicate list-configs indications
Disconnect the 'list-configs' indication handler immediately inside the
callback. If the modem sends a duplicate indication before the whole
config load sequence completes, it could overwrite the stored
'get-config-info' signal handler ID, orphaning the old handler and
leading to a Use-After-Free when the GTask is completed and the
orphaned handler eventually fires.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1071

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado 2b1aaca4a0 ifaces: fix UAFs in signal handlers when hot-unplugging
Use g_signal_connect_object() to connect to child list/object signals
in the 3GPP, Messaging, Voice, and Cell Broadcast interfaces.

Passing the raw D-Bus skeleton pointer as user_data to these signals
can lead to a Use-After-Free if the skeleton is disposed of (e.g. on
hot-unplug) while the parent object or child list survives. By using
g_signal_connect_object(), the signal handlers are automatically
disconnected when the D-Bus skeleton is destroyed.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1068

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado 0280bbae3b time: fix GSource leak and UAF in timezone poll
Introduce a timezone poll session ID to validate timezone load
results. This ensures that when a pending timezone load completes, we
discard the result if a new poll session has been started (e.g. due to
registration state changes) or if polling has been stopped.

This prevents leaking GSource timeout sources and a subsequent
Use-After-Free if the modem is hot-unplugged while a poll is pending.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1067

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 15:00:07 +02:00
Aleksander Morgado 6b3682ed65 voice: validate outgoing and deflect call numbers
Validate the number parameter in Voice.CreateCall and Call.Deflect
D-Bus methods to ensure they do not contain control characters or
semicolons. This prevents AT command injection when the number is
later spliced into ATD or +CTFR commands.

Introduce a common helper mm_utils_is_valid_dial_number() to validate
dial numbers, and add unit tests for it.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1067

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Aleksander Morgado 3291e7dd1c sim: validate preferred networks operator codes
Validate preferred network operator codes in the SIM D-Bus interface
handler to ensure they are numeric. This prevents injecting AT
command delimiters (like CR) into this field, which is later spliced
into AT commands (+CPOL).

This change also plugs the network list leak, that was a problem on
its own.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1065

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Aleksander Morgado 50202ad76a sim: validate PIN and PUK codes
Validate PIN and PUK codes in the SIM D-Bus interface handlers to
ensure they are numeric. This prevents injecting AT command
delimiters (like CR) into these fields, which are later spliced
into AT commands (+CPWD, +CLCK, +CPIN).

Introduce a common helper mm_utils_is_numeric() to check if a string
contains only digits, and add unit tests for it.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1065

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Aleksander Morgado dd54145d71 ussd: quote USSD command to prevent AT injection
When sending an unencoded USSD command, the user-supplied string was
spliced directly into the +CUSD AT command. If the string contained
CR or semicolons, it could lead to AT command injection.

Use mm_at_quote_string() to properly quote and escape the USSD
command before sending it.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1064

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Aleksander Morgado a39d46c637 location: validate SUPL host as FQDN or IP
When parsing a SUPL address, if the host is not a valid IPv4 address,
validate it as a FQDN (allowing only alphanumeric characters, dots,
and hyphens). This prevents injecting AT command delimiters (like CR
or semicolon) into the host string, which is later spliced into
modem-specific AT commands (+XLCSSLP).

Introduce a common helper mm_utils_is_valid_fqdn() to validate FQDNs,
and add unit tests for it.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1063

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Aleksander Morgado 1ee3a443b1 sms: sanitize decoded alphanumeric SMS addresses
Alphanumeric SMS addresses decoded from GSM-7 could contain control
characters (like CR/LF), which could lead to AT command injection
if the address is later spliced into an AT+CMGS command during
stored SMS send fallback.

Sanitize the decoded address by removing all control characters.

Introduce a common helper mm_utils_remove_control_characters() to
remove control characters from a string in-place, and add unit
tests for it.

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/work_items/1062

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-07-10 13:43:48 +02:00
Daniele Palmas 97c24d68e2 telit: add support for ME310M1
ME310M1 supports band format as ME910G1.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-07-07 10:55:13 -05:00
Daniele Palmas 3ca0cba220 telit: add ME910G1 to models
ME910G1 supports decimal format for 4G bands and has also an empty
tdscdma slot between 4G and 4G extended bands commands/responses.

Change shared code and helpers to deal with these differences.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-07-07 10:55:13 -05:00
Daniele Palmas 846048caa5 telit: fix band setting function to properly support multi-tech modems
The assumption that if a modem supports a given access tech, the band
settings for that specific tech should be always given is wrong for
4g, since the 4g bands can be disabled setting the value to 0 in
multi-tech modems like ME310M1.

For example, a 3g + 4g modem could have a setting in which all
the 4g bands are unset and only 3g bands are there: this scenario is
not supported by the current code, but it's legitimate.

Remove this limitation and adapt the code to support bands setting
for multi-tech modems.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-07-07 10:55:13 -05:00
Daniele Palmas 069212e43e telit: add suffix HEX to 4G extended bands regex macro name
In preparation to support regex for 4G extended bands decimal values.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-07-07 10:55:13 -05:00
Daniele Palmas e292401beb telit: tests: fix LN920 current bands configuration
Fix LN920 current bands test configuration by setting
modem_has_hex_format_4g_bands to TRUE.

The current wrong setting does not cause the test failure since the modem
supports also extended settings and function telit_get_ext_4g_mm_bands
considers both standard and extended bands as hex without checking
the flag, since decimal format for extended bands is not supported.

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-07-07 10:55:13 -05:00
Lukas Voegl 3dbdc0704d quectel: add RM520N Sahara/Firehose support
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
2026-07-03 14:12:48 +02:00
Dan Williams a94dd40a2a intel: XMM7360: convert remaining asserts to error checks
Return useful errors rather than asserting on unexpected responses.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams fd98a809af sierra: enable XMM7160-based devices like Comneon HL7588
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams a486776a44 intel: XMM7360: better handle negative ASN integers from modem
The original code for xmm7360_byte_array_read_asn_int() returned
signed integers both from the function and from the returned
Xmm7360RpcMsgArg, but didn't handle sign extension on the
value returned from the function. That would lead to different
values between the function return and the Xmm7360RpcMsgArg
value, which seems wrong.

Make those two correspond and add checks in various places that
shouldn't ever see negative ints.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams d6fe0722c9 intel: XMM7360: add xmmrpc protocol test infrastructure
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams 64d8053413 intel: XMM7360: move Xmm7360RpcMsgArgType UNKNOWN value first in enum
That way UNKNOWN is the zero'd value instead of BYTE; it's easier
to test for and less error-prone if not explicitly set to the right
value.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams 4fead86d24 intel: XMM7360: better handling of silly ASN int sizes
xmm7360_byte_array_read_asn_int() would keep bit-shifting a gint into
oblivion if the int's size was > 32-bit. It also didn't handle size 0
ints at all, and while size 24 ints would get stuffed into a 32-bit
variable those probably aren't a thing and if they actually are they
should get specifically handled.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams 3f7b39075c intel: XMM7360: move standalone protocol functions to their own file
So we can unit-test all the parsing and building code more easily
without having to link to a bunch of serial port stuff.

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams 07dc7e7304 intel: XMM7360: return a GError from parse_response_xmm7360()
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Dan Williams 1565e3ada7 intel: XMM7360: convert message parsing g_assert()s to GErrors (#1034)
We shouldn't be g_asserting (and thus crashing) on untrusted input code;
should instead check validity and return an error that upper layers
can reasonbly log and handle.

Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/1034

Signed-off-by: Dan Williams <dan@ioncontrol.co>
2026-05-24 08:33:48 -05:00
Barnabás Pőcze 62cc4de68e broadband-modem-mtk-legacy: fix GError memory leak
If the error matches, then a `+CIMI` command is sent to the device and
processing continues. However, the current error (for the `+CPIN?` command)
is not freed or propagated, fix that.

Fixes: 5c1fcbfe4a ("mtk-legacy: read IMSI if CPIN response is an error")
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
2026-05-24 08:12:41 -05:00
Alexander Couzens 31cbf9c1be ModemManager: handle QMI_DMS_OPERATING_MODE_SHUTTING_DOWN similar as OFFLINE
Found and tested on Oneplus 6T with postmarketOS.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
2026-05-12 12:44:49 -05:00
Wenbin f6676cc5f3 plugin,rolling: Add udev rules for RW135R modules.
The Rolling needs to add the udev rules for supporting RW135R modules.

Signed-off-by: Wenbin <ywbjob@163.com>
2026-05-12 12:30:53 -05:00
Aleksander Morgado 44330936c6 rolling: fix single plugin build
The MTK specific modem object should be included in the 'mtk' shared
utils, so that they're available to other plugins.

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-04-22 14:27:38 +00:00
xuhongxing b10139f96b Rolling: Add modifications related to the rw350-usb project
1.Modify rule files for the 33f8/0802 MI interface
2.Modify the rolling plugin code to share and reuse code from the mtk plugin

T: Bus=02 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 5 Spd=5000 MxCh= 0
D: Ver= 3.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs= 1
P: Vendor=33f8 ProdID=0802 Rev=00.01
S: Manufacturer=Rolling Wireless S.a.r.l.
S: Product=USB DATA CARD
C: #Ifs=10 Cfg#= 1 Atr=a0 MxPwr=896mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=32ms
I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
E: Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=83(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=85(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs
E: Ad=05(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=06(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=87(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 7 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=07(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=88(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 8 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=08(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=89(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I: If#= 9 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
E: Ad=09(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E: Ad=8a(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms

Signed-off-by: xuhongxing <James.Xu@fibocom.com>
2026-04-22 18:26:57 +08:00
Aleksander Morgado b6d53915a6 port-qmi: add missing QMI_DATA_ENDPOINT_TYPE_ETHERNET
Fixes build with latest libqmi.

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-04-15 12:54:09 +00:00
Aleksander Morgado c34b326709 modem-helpers-qmi: add missing QMI_WDS_PDP_TYPE_NON_IP check
Fixes build with latest libqmi.

Signed-off-by: Aleksander Morgado <aleksandermj@google.com>
2026-04-15 12:46:28 +00:00
Guido Günther b59e0acb08 mm-cbm-part: Try harder to convert message text
Current cell broadcast messages from missile warnings in Israel
have an addition `00` at the end to pad for an even byte number.

This breaks conversion making the whole message fail conversion. As this
is a 15 part message in 3 languages the whole notification is lost in
this case.

Try harder to convert the message and recover even partial bits.

Closes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/1042
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2026-03-24 20:53:23 -05:00
Lorenzo Medici 49fb75cd94 cinterion: add USB interface number 0x05 for TX62 modem
Signed-off-by: Lorenzo Medici <lorenzo.medici@canonical.com>
2026-03-20 16:24:04 +02:00
Wenbin 387c41cb04 rolling: update RW101 port type hints
The port type hints for the RW101-cat6 and RW101-cat12 have been
updated, with USB interface #2 now designated as both the AT primary
port and fastboot port.

Signed-off-by: Wenbin <ywbjob@163.com>
2026-02-03 11:49:42 +01:00
Daniele Palmas aa2aa54748 telit: add port hints for FN990B40 rmnet and MBIM compositions
Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-01-30 16:09:01 +01:00
Daniele Palmas 6131303fb2 telit: add port hints for FE910C04 rmnet and MBIM compositions
Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-01-30 16:08:37 +01:00
Daniele Palmas c1386905f3 telit: add port hints for FE990B40 rmnet and MBIM compositions
Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-01-30 16:08:12 +01:00
Daniele Palmas 8f4e8bd24c telit: add port hints for FN920C04 rmnet and MBIM compositions
Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2026-01-30 16:07:52 +01:00
Andrey Skvortsov c0f0c02ac1 tests: add tests for location-cache
only GGA NMEA sentences are supported by current implementation of
MMLocationGpsRaw. RMC and GLL messages are added, but currently test
are negative.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov 8b6116fe6c shared-qmi: handle inject position requests from the modem
To be able to have quick position fix GNSS engine needs to know
 - predicted orbits data,
 - current time,
 - approximate position.
Modem sends indications with requests, when it needs corresponding
information. Predicted orbits can be injected using
'mmcli -m any --location-inject-assistance-data=<file>'. But to
accelerate time to first fix after cold start extra information is
needed like time and coarse position.

Inject position requests are received, when GPS session is initiated
using QMI_LOC_START. In inject position request modem sends
information about its last known position. If last known position is
zero, when this is a cold start and inject position is needed to
improve TTFF.
Last position from the modem is cached in ModemManager and is injected
next time, when modem requests it. For example, if modem is restarted.

When timestamp on injected position is too old, than position is
ignored and location engine does cold start. Therefore current time is
used for injected position.

When injected position is far away the actual one (for example, after
flight), after some time location engine falls back to cold start.

Tested on Quectel EG25-G.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00