Commit Graph

2730 Commits

Author SHA1 Message Date
Sergey Matyukevich 7a62b554ab sim: validate IMS private identity
Make sure that IMS private identity is a valid UTF8 string before
setting sim->impi field. Otherwise ofono may crash on dbus assert
when SIM properties are reported via org.ofono.SimManager interface.
2021-01-19 10:05:02 -06:00
Sergey Matyukevich bae8ebe907 simutil: add validate_utf8_tlv
Add helper to validate if TLV value is a valid UTF8 string.
Note that both null-terminated and non null-terminated UTF8
strings are considered valid.
2021-01-19 10:03:05 -06:00
Richard Röjfors 429a5a57da util: Fix implicit enum conversion
GCC10 complains about the following:

src/smsutil.c: In function ‘sms_text_prepare_with_alphabet’:
src/smsutil.c:3594:8: error: implicit conversion from ‘enum sms_alphabet’ to ‘enum gsm_dialect’ [-Werror=enum-conversion]
 3594 |        alphabet, &used_locking,

smsutil and util has an enum each for representing
the same thing; The SMS alphabet. They share the same
values, so an explicit type cast makes GCC happy.
2020-12-22 09:45:05 -06:00
Christophe Ronco 7594a000dd common: APN with a dot in second position are not invalid
APN with a dot in second position (example: "t.est") are wrongly
considered invalid.
2020-09-29 09:11:08 -05:00
JongSeok Won 4f4fcc4944 netmon: added PCI, TAC, SNR value
To support cell type LTE, the value of PCI, TAC, SNR is added
2020-07-31 10:18:53 -05:00
Jimmy Gysens c83d693097 gprs: clean context properly
After a context is detached, the context is not properly cleared. In
addition to releasing the context:

- Reset the context settings (IP, DNS, interface, ...).
- Signal the Active flag as false.
2020-06-25 12:04:54 -05:00
Slava Monich 47b52aab34 lte: Use the right D-Bus interface for property change signal 2020-06-18 15:37:45 -05:00
Slava Monich cf4a4a7bd0 cbs: Allow the last CBS fragment to be truncated
That does happen in real life.
2020-06-18 15:34:20 -05:00
Antara Borwankar d90cfdd71c sim: handling crash in error scenario for SIM PIN query
In case of error in sim_pin_query_cb function. pin_type is set
to -1. This is causing segmentation fault in function
sim_passwd_name due to invalid index pin_type = -1. Fixing this
issue by handling error case before calling sim_passwd_name
function.
2019-12-20 12:46:18 -06:00
Richard Röjfors aa89c19a50 gprs: Update attach state on context deactivation for LTE
To be considered attached on LTE a context should be activated.
But in case the context got deactivated we did not update
the attached state, it remained attached.
That caused the connection manager to try to re-activate the
context manually, but for LTE thats done automatically.
In the case of ublox it returns errors, which is passed
on to the connection manager, which tries again and
again, until we get attached again.

It looked like this:
12:03:18 ofonod[547]: Aux: < \r\n+CIEV: 2,3\r\n
12:03:23 ofonod[547]: Aux: < \r\n+CIEV: 2,2\r\n

Deactivated

12:16:01 ofonod[547]: Aux: < \r\n+CGEV: NW PDN DEACT 4\r\n
12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgev_notify() cid 4, active cid: 4
12:16:01 ofonod[547]: src/gprs.c:ofono_gprs_context_deactivated() 0x1743e50 0x17424a8 4

Connection manager now try to activate, over and over again
because Attached remains TRUE

12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1
12:16:01 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r
12:16:01 ofonod[547]: Aux: < \r\nOK\r\n
12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1
12:16:01 ofonod[547]: Aux: > AT+CGACT=1,1\r
12:16:01 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n
12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0
12:16:01 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0
12:16:01 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service
12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1
12:16:02 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r
12:16:02 ofonod[547]: Aux: < \r\nOK\r\n
12:16:02 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1
12:16:02 ofonod[547]: Aux: > AT+CGACT=1,1\r
12:16:02 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n
12:16:02 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0
12:16:02 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0
12:16:02 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service
.
.
.
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1
12:16:14 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r
12:16:14 ofonod[547]: Aux: < \r\nOK\r\n
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1
12:16:14 ofonod[547]: Aux: > AT+CGACT=1,1\r
12:16:14 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0
12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0
12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1
12:16:14 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r
12:16:14 ofonod[547]: Aux: < \r\nOK\r\n
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1
12:16:14 ofonod[547]: Aux: > AT+CGACT=1,1\r

The context got activated again

12:16:14 ofonod[547]: Aux: < \r\n+CGEV: ME PDN ACT 4\r\n\r\n+CIEV: 9,2\r\n\r\n+CTZE: +04,0,"19/12/11,13:17:58"\r\n
12:16:14 ofonod[547]: drivers/ubloxmodem/network-registration.c:ctze_notify() tz +04 dst 0 time 19/12/11,13:17:58
12:16:14 ofonod[547]: src/network.c:ofono_netreg_time_notify() net time 2019-12-11 13:17:58 utcoff 3600 dst 0
12:16:14 ofonod[547]: Aux: < \r\n+CME ERROR: 100\r\n
12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0
12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0
12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: Unknown error
2019-12-11 15:08:26 -06:00
Richard Röjfors 3b7d8e003e gprs: Don't modify the context if assign fails
There was an issue while running LTE and the connection
manager tried to activate the context with CID 1 while
it got automatically activated at the same time with
CID 4.

When the automatic activation happened ofono_gprs_cid_activated
got called which tried to assign the context, but that failed
since the driver context was considered in use
(by the activation call).
Eventhough it failed, the context was modified,
cid was set to 0 (making cid 1 leak).
Then release_context got called which clear pointers
assigned to the context.

A bit later the activation callback got called, in my case
activation failed. Due to the failure it tries to clean up
by calling context_settings_free, but unfortunately the pointers
where reset above causing ofono to segfault du to null pointer
derefs.

Instead we make sure assign_context does not touch the context
unless it succeeds. Then there is no need to call release_context
if assign fails.
That ensures the context being intact when the activation callback
gets called.

03:23:21 ofonod[545]: Aux: < \r\n+CGEV: ME PDN ACT 4\r\n\r\n+CTZE: +04,0,"19/12/10,04:25:03"\r\n
03:23:21 ofonod[545]: drivers/ubloxmodem/network-registration.c:ctze_notify() tz +04 dst 0 time 19/12/10,04:25:03
03:23:21 ofonod[545]: src/network.c:ofono_netreg_time_notify() net time 2019-12-10 04:25:03 utcoff 3600 dst 0
03:23:22 ofonod[545]: Aux: > AT+CGDCONT?\r
03:23:22 ofonod[545]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1

Connection manager requests activation, will mark the context in use and assign
it cid 1.

03:23:22 ofonod[545]: Aux: < \r\n+CGDCONT: 1,"IP","m2m.tele2.com","",0,0,0,0,0,0\r\n
03:23:22 ofonod[545]: Aux: < +CGDCONT: 4,"IP","m2m.tele2.com.mnc003.mcc248.gprs","100.69.174.133",0,0,0,0,0,0\r\n
03:23:22 ofonod[545]: Aux: < \r\nOK\r\n
03:23:22 ofonod[545]: drivers/atmodem/gprs.c:at_cgdcont_read_cb() ok 1
03:23:22 ofonod[545]: src/gprs.c:ofono_gprs_cid_activated() cid 4
03:23:22 ofonod[545]: Can't assign context to driver for APN.

Since its marked in use above, we fail to assign it cid 4. When that fails
the cid is cleared an all context pointers are set to NULL.

03:23:22 ofonod[545]: Aux: > AT+CGDCONT=1,"IP","m2m.tele2.com"\r
03:23:22 ofonod[545]: Aux: < \r\nOK\r\n
03:23:22 ofonod[545]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1
03:23:22 ofonod[545]: Aux: > AT+CGACT=1,1\r
03:23:22 ofonod[545]: Aux: < \r\n+CME ERROR: 100\r\n
03:23:22 ofonod[545]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0
03:23:22 ofonod[545]: src/gprs.c:pri_activate_callback() 0x853480
03:23:22 ofonod[545]: src/gprs.c:pri_activate_callback() Activating context failed with error: Unknown error

Activation callback, and it failed. Will try to clean up, but the pointers are
NULL'ed...

Dec 10 03:23:22 ofonod[545]: Aborting (signal 11) [/usr/sbin/ofonod]
2019-12-11 14:35:34 -06:00
Denis Kenzior 6cd9a241bd gprs: Remove pointless check
name is declared as an array, so the check will always evaluate to true
2019-11-13 17:01:15 -06:00
Denis Kenzior 9111a1ac53 simutil: Remove pointless check
len is already checked >= 16 above
2019-11-13 17:01:15 -06:00
Denis Kenzior f9204363e0 log: Remove dead code 2019-11-13 17:01:15 -06:00
Denis Kenzior 17b6c6c314 simutil: Fix EF structure bit processing
The intent here was to find the contents of the 3 low order bits
according to Table 11-5 in ETSI 102.221.  However, the mask ended up
only grabbing the contents of the 2 low order bits.
2019-11-13 17:01:15 -06:00
Marcel Holtmann 37be9d1026 call-forwarding: Increase string buffer to avoid overflow 2019-10-31 08:39:18 +01:00
Richard Röjfors 7528a6096d gprs: update attached on netreg updates when running LTE
There was a race condition where a context might be
registered before the netreg status updates to LTE.

The code took for granted the context is activated after
the technology update. With this change, any order is
is accepted.
2019-10-11 12:31:08 -05:00
Martin Hundebøll c96031dda5 gprs: free interface name in gprs_context_remove() 2019-09-26 14:50:27 -05:00
Richard Röjfors 875eb23000 gprs: Do nothing on detached when attaching.
Its incorrect to fiddle with the driver attach state when
attaching. When attaching the state is transitioning,
and the correct state will now always be assigned in
the end of the attach process, regardless of result.
2019-09-24 09:55:38 -05:00
Richard Röjfors da871669a3 gprs: Only release detachable context on de-attach
Currently there is an issue if the attach state changes and
there are active contexts of which the driver does not
implement the detach_shutdown.
In that case we just release the context (clears CID and
active state), but nothing is signalled on D-Bus or towards
the modem.
Ofono is then out of sync with both the connection manager
and the modem, this manifests itself later on if the modem
changes state of the context, then ofono will not find it
since the CID is cleared, and the connection manager won't
be notified.
2019-09-20 10:52:40 -05:00
Richard Röjfors 336a5b4274 gprs: deattach driver when gprs status indicates unregistered
In the same way as we consider the driver attached when the
gprs status indicates we are registered, we should consider
it deattached when the status indicates unregistration.

If we don't, then we would not always recover from the case
when deattaching the driver fails. We would just revert back
the driver attached status to true, and "ignore" if the status
indicates the opposite when we check the registration status
afterwards.
2019-09-20 09:57:15 -05:00
Richard Röjfors 06de0c3067 gprs: Remove prior attaching state logic
Commit 1fd419e5b4 and
0167c3339c introduced logic that
treated ofono_gprs_cid_activated as an 'attaching' state.

Since gprs_attached_update now guarantees that we
will not get attached without having a context activated
in LTE, this is not needed anymore. It also potentially
interferes in case the driver was actually attaching.
2019-08-21 13:27:26 -05:00
Richard Röjfors b50ff27d3f gprs: Check for LTE in gprs_attached_update
Since we have a different condition for the attach state
when running on LTE, we should consider it in gprs_attached_update.
Previously it's done in some instances. But for instance if
the driver got detached from GPRS but now running on LTE with a
context up, we would be deattached.
2019-08-21 13:11:11 -05:00
Richard Röjfors 9a1b490e78 gprs: Ignore activated contexts during init, list them later
There is an issue if an context gets auto activated early,
then provisioning might not have run yet for instance,
so a "new" context is created, which might be duplicated
by a provisioning context later.
So ignore the activated contexts until gprs is ready,
then it calls the driver to list active contexts.
2019-08-13 01:41:16 -05:00
Richard Röjfors 88ee0123ab gprs: Do not detach when running LTE and GPRS is unavailable.
There are cases where the gprs status might updated to for instance
"unknown" while LTE is the bearer.
In that case we should not set the attach state to FALSE,
since then running LTE the conext activation reflects the attached
state.
2019-08-12 15:45:40 -05:00
Richard Röjfors 5752702cbe gprs: Do not leak CID on failure to assign context 2019-08-07 17:10:17 -05:00
Richard Röjfors d4ced627e0 gprs: Use -1 as netreg status during init.
Previously the valid "unknown" netreg status was set
during startup, but its a bit problematic for gprs.
There might be cases where a LTE context is activated
before netreg is finished updating its status.
Resulting in gprs taking faulty actions.
Instead we set the status to -1 until we are updated
with a known value.
During the time the status is -1, gprs postpones actions until
the status is valid (>= 0).
2019-08-07 16:54:25 -05:00
Antara Borwankar 90c312484f netmon: adding get functionality for neighbouring cell information
Handled the get neighbouring cell information function which returns
an array of signal strength of all neighbouring cells.
2019-06-07 11:40:59 -05:00
Denis Kenzior 765c6655f2 treewide: Use L_TFR macro 2019-05-24 11:55:38 -05:00
Denis Kenzior 48e31f9fc3 main: Quiet ld errors with external ell
When oFono is built with --enable-external-ell, the compiler for some
reason does not generate a debug section on some systems.  This is due
to the fact that l_debug is never called.  However, ell also does not
call l_debug, yet when built-in ell is used, the section is created by
the compiler.

For now work around this by adding a no-op l_debug() call in main.c.
The real fix is to migrate all of the oFono logging functionality to use
ell instead.
2019-05-16 15:10:53 -05:00
Denis Kenzior 5d3640397a core: Quiet warning about strncpy use 2019-05-16 15:10:40 -05:00
Antara Borwankar 0c2f2815ca radio-settings: handling of dual mode technology preference
Handled two new dual mode technology preferences
"umts,gsm" and "lte,umts".
2019-05-16 10:40:45 -05:00
Denis Kenzior dc7fb359cb voicecall: Fix possible crash 2019-04-30 11:40:17 -05:00
Denis Kenzior 408d063f85 netmon: Fix logic error 2019-04-30 11:38:36 -05:00
Denis Kenzior 614ffb0761 sim-auth: Use memcpy instead of strncpy
The code is not really copying strings but 2 or 3 character sof the MNC.
Make this clearer.
2019-04-30 11:09:52 -05:00
Denis Kenzior d3625f8e6f message-waiting: Fix logic error 2019-04-29 19:38:12 -05:00
Denis Kenzior ca9d5b73ab gprs: Remove unneeded if conditions
ctx->message_center and ctx->message_proxy are arrays and thus
always evaluate as true
2019-04-29 19:30:22 -05:00
Denis Kenzior c56bd74cb1 gprs: Fix invalid string comparison
The default context created when provisioning fails is simply a context
with an empty APN
2019-04-29 19:27:29 -05:00
Denis Kenzior 91253a1ade gprs: Remove unneeded if statement
if (ctx->message_proxy) always resolves to TRUE
2019-04-29 19:25:57 -05:00
Denis Kenzior 87932a536f stk: Fix potential buffer overrun 2019-04-29 19:24:19 -05:00
Denis Kenzior bdda846134 phonebook: fix invalid sprintf sequence 2019-04-29 19:16:07 -05:00
Denis Kenzior a63988a33f stkutil: Call va_end on failure 2019-04-29 14:34:00 -05:00
Denis Kenzior 999494624b siri: Dereference after validating !NULL 2019-04-29 14:27:54 -05:00
Denis Kenzior 1c940839bb handsfree: Dereference after validating !NULL 2019-04-29 14:26:43 -05:00
Denis Kenzior 4fddd1a6ea sim: Dereference only after validating !NULL 2019-04-29 14:24:48 -05:00
Denis Kenzior 4a93c329b9 log: Fix potential buffer overflow
We pass in the maximum size of the buffer to the read system call.  On
the astronomically unlikely chance that we indeed read the full buffer
full of data, the subsequent assignment will overflow it.  Fix this by
passing sizeof(buf) - 1 to the read system call instead.
2019-04-29 14:16:17 -05:00
Alexander Couzens d604052cef gprs: netreg_status_changed: output the status as human readable string 2019-04-28 10:13:51 -05:00
Alexander Couzens 13181d1a01 network: debug log the network time on update 2019-04-28 10:13:07 -05:00
Alexander Couzens c508574f68 network/ofono_netreg_status_notify: debug log the lac and ci 2019-04-28 10:13:07 -05:00
Richard Röjfors 05aaab72ae gprs: Always store RoamingAllowed as a boolean.
In one instance it was stored as boolean and another as int.
Since its always parsed as a boolean and it is a boolean,
always store it as boolean.
2019-04-16 11:46:00 -05:00