Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTLS mode crashes #594

Open
jonathanpallant opened this issue Apr 22, 2021 · 7 comments
Open

DTLS mode crashes #594

jonathanpallant opened this issue Apr 22, 2021 · 7 comments

Comments

@jonathanpallant
Copy link

jonathanpallant commented Apr 22, 2021

I was testing wakaama, specifically the example/client binary. If I enable DTLS mode, I get a segmentation fault:

jonathan@DAMOGRAN:~/LocalDocs/wakaama/examples/client/build$ cmake .. -DDTLS=ON -DCMAKE_BUILD_TYPE=Debug
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jonathan/LocalDocs/wakaama/examples/client/build
jonathan@DAMOGRAN:~/LocalDocs/wakaama/examples/client/build$ make
Scanning dependencies of target lwm2mclient
[  2%] Building C object CMakeFiles/lwm2mclient.dir/lwm2mclient.c.o
[  4%] Linking C executable lwm2mclient
[100%] Built target lwm2mclient
jonathan@DAMOGRAN:~/LocalDocs/wakaama/examples/client/build$ gdb --args ./lwm2mclient -4 -n my_test_host -h leshan.eclipseprojects.io -p 5684 -i test-key -s 00112233 -c
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./lwm2mclient...
(gdb) run
Starting program: /home/jonathan/LocalDocs/wakaama/examples/client/build/lwm2mclient -4 -n my_test_host -h leshan.eclipseprojects.io -p 5684 -i test-key -s 00112233 -c
Trying to bind LWM2M Client to port 56830
[lwm2m_init:65] Entering
[lwm2m_configure:272] endpointName: "my_test_host", msisdn: "", altPath: "", numObject: 9
LWM2M Client "my_test_host" started on port 56830
> [lwm2m_stringToUri:227] buffer_len: 6, buffer: "/3/0/9"
[lwm2m_stringToUri:283] Parsed characters: 6
[lwm2m_stringToUri:284] /3/0/9
New Battery Level: 96
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_nstring:277] length: 2, string: "96"
[lwm2m_data_encode_opaque:251] length: 2
[lwm2m_data_decode_int:299] Entering
[lwm2m_data_decode_int:362] result: 1, value: 96
value changed!
[lwm2m_resource_value_changed:474] /3/0/9
[lwm2m_data_free:178] size: 1
[lwm2m_step:381] timeoutP: 5
[lwm2m_step:386] State: STATE_INITIAL
[object_getServers:1040] Entering
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_bool:519] value: false
[lwm2m_data_decode_bool:529] Entering
[lwm2m_data_decode_bool:580] result: 1, value: false
[lwm2m_data_free:178] size: 1
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_int:289] value: 123
[lwm2m_data_decode_int:299] Entering
[lwm2m_data_decode_int:362] result: 1, value: 123
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_int:289] value: 123
[lwm2m_data_decode_int:299] Entering
[lwm2m_data_decode_int:362] result: 1, value: 123
[lwm2m_data_free:178] size: 1
[lwm2m_data_new:160] size: 2
[lwm2m_data_encode_int:289] value: 300
[lwm2m_data_encode_string:214] "U"
[lwm2m_data_decode_int:299] Entering
[lwm2m_data_decode_int:362] result: 1, value: 300
[lwm2m_data_free:178] size: 2
[lwm2m_data_free:178] size: 1
[registration_start:1016] State: STATE_REGISTER_REQUIRED
[lwm2m_data_new:160] size: 1
[lwm2m_data_free:178] size: 1
[lwm2m_data_new:160] size: 1
[lwm2m_data_free:178] size: 1
[observe_step:521] Entering
[registration_step:2045] State: STATE_REGISTERING
[object_getRegisterPayloadBufferLength:788] Entering
[object_getRegisterPayload:886] Entering
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_string:214] "coaps://leshan.eclipseprojects.io:5684"
[lwm2m_data_free:178] size: 1
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_int:289] value: 0
[lwm2m_data_decode_int:299] Entering
[lwm2m_data_decode_int:362] result: 1, value: 0
[lwm2m_data_free:178] size: 1
[transaction_new:156] method: 2, altPath: "", mID: 63960, token_len: 4
[transaction_new:158] NULL
[transaction_new:238] Exiting on success. new transac=0x8052520
[transaction_send:359] Entering: transaction=0x8052520
Sending 67 bytes to [23.97.187.154]:5684
16 FE FD 00  00 00 00 00  00 00 00 00  36 01 00 00   ............6...
2A 00 00 00  00 00 00 00  2A FE FD 00  00 00 00 5E   *.......*......^
76 00 D5 93  73 65 20 A9  F9 50 FE E0  F5 35 57 B9   v...se ..P...5W.
9E A7 5F A1  98 5E 9A 50  9D 04 5E 00  00 00 02 C0   .._..^.P..^.....
A8 01 00                                             ...
[transaction_step:446] Entering
[lwm2m_step:488] Final timeoutP: 2
[lwm2m_step:490] Final state: STATE_REGISTERING
 -> State: STATE_REGISTERING
60 bytes received from [23.97.187.154]:5684
16 FE FD 00  00 00 00 00  00 00 00 00  2F 03 00 00   ............/...
23 00 00 00  00 00 00 00  23 FE FD 20  14 D4 56 C7   #.......#.. ..V.
28 85 7B 09  51 66 D4 79  01 FE 93 32  77 79 4E 42   (.{.Qf.y...2wyNB
1C 80 F6 91  41 D5 58 EB  30 CF 2D 04                ....A.X.0.-.
Sending 99 bytes to [23.97.187.154]:5684
16 FE FD 00  00 00 00 00  00 00 01 00  56 01 00 00   ............V...
4A 00 01 00  00 00 00 00  4A FE FD 00  00 00 00 5E   J.......J......^
76 00 D5 93  73 65 20 A9  F9 50 FE E0  F5 35 57 B9   v...se ..P...5W.
9E A7 5F A1  98 5E 9A 50  9D 04 5E 00  20 14 D4 56   .._..^.P..^. ..V
C7 28 85 7B  09 51 66 D4  79 01 FE 93  32 77 79 4E   .(.{.Qf.y...2wyN
42 1C 80 F6  91 41 D5 58  EB 30 CF 2D  04 00 02 C0   B....A.X.0.-....
A8 01 00                                             ...
[lwm2m_step:381] timeoutP: 5
[lwm2m_step:386] State: STATE_REGISTERING
[registration_getStatus:1082] State: STATE_REGISTERING
[registration_getStatus:1089] 123 status: STATE_REG_PENDING
[registration_getStatus:1113] reg_status: STATE_REG_PENDING
[observe_step:521] Entering
[registration_step:2045] State: STATE_REGISTERING
[transaction_step:446] Entering
[lwm2m_step:488] Final timeoutP: 2
[lwm2m_step:490] Final state: STATE_REGISTERING
 -> State: STATE_REGISTERING
120 bytes received from [23.97.187.154]:5684
16 FE FD 00  00 00 00 00  00 00 01 00  52 02 00 00   ............R...
46 00 01 00  00 00 00 00  46 FE FD 60  81 9D 3E 16   F.......F..`..>.
D1 9E 32 E4  EF F0 34 1A  88 95 7B 22  D4 A1 6C 4B   ..2...4...{"..lK
6D 63 91 99  91 1A 84 72  82 70 D6 20  B9 DB 88 C0   mc.....r.p. ....
30 2C 36 DE  42 88 0A AF  79 3F BD DC  B5 E8 14 29   0,6.B...y?.....)
86 D8 CC E0  C6 8D 74 25  3F 0C 6E 79  C0 A8 00 16   ......t%?.ny....
FE FD 00 00  00 00 00 00  00 02 00 0C  0E 00 00 00   ................
00 02 00 00  00 00 00 00                             ........
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_opaque:251] length: 8
[lwm2m_data_free:178] size: 1
Sending 35 bytes to [23.97.187.154]:5684
16 FE FD 00  00 00 00 00  00 00 02 00  16 10 00 00   ................
0A 00 02 00  00 00 00 00  0A 00 08 74  65 73 74 2D   ...........test-
6B 65 79                                             key
[lwm2m_data_new:160] size: 1
[lwm2m_data_encode_opaque:251] length: 4
[lwm2m_data_free:178] size: 1
Sending 14 bytes to [23.97.187.154]:5684
14 FE FD 00  00 00 00 00  00 00 03 00  01 01  ..............
Sending 53 bytes to [23.97.187.154]:5684
16 FE FD 00  01 00 00 00  00 00 00 00  28 00 01 00   ............(...
00 00 00 00  00 DA 08 4D  C6 6F 51 24  D4 1E B3 4F   .......M.oQ$...O
CD D0 13 FD  DA 75 78 77  E8 83 B9 19  9A 80 CE CC   .....uxw........
2F D1 8E AC  4D                                      /...M
[lwm2m_step:381] timeoutP: 5
[lwm2m_step:386] State: STATE_REGISTERING
[registration_getStatus:1082] State: STATE_REGISTERING
[registration_getStatus:1089] 123 status: STATE_REG_PENDING
[registration_getStatus:1113] reg_status: STATE_REG_PENDING
[observe_step:521] Entering
[registration_step:2045] State: STATE_REGISTERING
[transaction_step:446] Entering
[lwm2m_step:488] Final timeoutP: 2
[lwm2m_step:490] Final state: STATE_REGISTERING
 -> State: STATE_REGISTERING
67 bytes received from [23.97.187.154]:5684
14 FE FD 00  00 00 00 00  00 00 03 00  01 01 16 FE   ................
FD 00 01 00  00 00 00 00  00 00 28 00  01 00 00 00   ..........(.....
00 00 00 49  9E 61 F1 4B  46 66 6A 48  DC BD 6A 31   ...I.a.KFfjH..j1
52 5D D8 CE  51 D3 52 BE  6B D0 0D 27  28 B3 27 E1   R]..Q.R.k..'(.'.
25 F5 E6                                             %..
decrypt_verify(): found 24 bytes cleartext
[lwm2m_step:381] timeoutP: 5
[lwm2m_step:386] State: STATE_REGISTERING
[registration_getStatus:1082] State: STATE_REGISTERING
[registration_getStatus:1089] 123 status: STATE_REG_PENDING
[registration_getStatus:1113] reg_status: STATE_REG_PENDING
[observe_step:521] Entering
[registration_step:2045] State: STATE_REGISTERING
[transaction_step:446] Entering
[lwm2m_step:488] Final timeoutP: 2
[lwm2m_step:490] Final state: STATE_REGISTERING
 -> State: STATE_REGISTERING
[lwm2m_step:381] timeoutP: 5
[lwm2m_step:386] State: STATE_REGISTERING
[registration_getStatus:1082] State: STATE_REGISTERING
[registration_getStatus:1089] 123 status: STATE_REG_PENDING
[registration_getStatus:1113] reg_status: STATE_REG_PENDING
[observe_step:521] Entering
[registration_step:2045] State: STATE_REGISTERING
[transaction_step:446] Entering
[transaction_send:359] Entering: transaction=0x8052520
Sending 211 bytes to [23.97.187.154]:5684
17 FE FD 00  01 00 00 00  00 00 01 00  C6 00 01 00   ................
00 00 00 00  01 8E A0 12  62 47 3D BA  9B 1C ED BA   ........bG=.....
50 9F 37 8B  0D 40 09 EA  7E 46 CD 84  2D 72 A8 C6   P.7..@..~F..-r..
2E 0C 1F 7C  C6 1F 7E 5A  7C 4D AB F4  0A 53 C5 9F   ...|..~Z|M...S..
37 2E DE D6  D8 38 DF A9  A3 19 ED BA  16 AA 7E E0   7....8........~.
66 72 FA 80  AD 1E 36 66  2E 8E C6 DB  90 2F 90 20   fr....6f...../. 
AC 84 76 F5  7D 3F 12 15  25 84 C7 DB  80 8F CE EC   ..v.}?..%.......
AA 45 0F 74  9F 80 07 BA  C1 B9 55 DF  7B 66 4B 9E   .E.t......U.{fK.
07 2E C8 88  33 9A 4A F4  86 6F 23 29  44 0D C2 72   ....3.J..o#)D..r
DD D3 79 1A  D1 C0 14 04  EC 5E D2 CC  1D 35 FB 6B   ..y......^...5.k
D6 DB 69 CD  0A 57 65 77  B4 E0 DD 17  AA 93 D8 3A   ..i..Wew.......:
EF 44 DE 0B  B9 A5 57 EF  43 B5 88 03  FE 9C DA 79   .D....W.C......y
B6 D3 5F DC  69 29 5D C9  CF 0F 03 5F  FA B2 E7 C1   .._.i)]...._....
2A 6D 84                                             *m.
[lwm2m_step:488] Final timeoutP: 4
[lwm2m_step:490] Final state: STATE_REGISTERING
 -> State: STATE_REGISTERING
40 bytes received from [23.97.187.154]:5684
17 FE FD 00  01 00 00 00  00 00 01 00  1B 00 01 00   ................
00 00 00 00  01 A6 FB FC  16 6A 4C 0D  8E 94 B9 4F   .........jL....O
1F B5 9E 2F  65 67 5E B9                             .../eg^.
decrypt_verify(): found 11 bytes cleartext
[lwm2m_handle_packet:444] Entering
[lwm2m_handle_packet:448] Parsed: ver 1, type 2, tkl 4, code 2.31, mid 63960, Content type: 0
[lwm2m_handle_packet:450] Payload: 

Program received signal SIGSEGV, Segmentation fault.
0x0000000008014cd9 in prv_get_transaction (contextP=0x0, sessionH=0x8054220, mid=63960) at /home/jonathan/LocalDocs/wakaama/core/packet.c:195
195         transaction = contextP->transactionList;
(gdb) 

As you can see contextP is null. The issue is that data.lwm2mH at the top level is set to NULL in DTLS mode when it should be set to the lwm2m handle.

Edit: patch removed

@rettichschnidi
Copy link
Contributor

Welcome and thanks for your contribution!

However, we can not take contributions this way as we need to ensure that each contributor has agreed on the Eclipse Contributor Agreement.

Can you please create a PR using this patch?

@tuve
Copy link
Contributor

tuve commented Apr 22, 2021

Welcome @jonathanpallant as @rettichschnidi mentioned we need a signed ECA.

Since we are lacking any decent "how to contribute" documentation, here is the quick crash course on how to contribute:

1, Sign the ECA
2, When you commit the patch to your forked repository, don't forget to sign the commit, all commits in a pull request mist be signed.
git commit --signoff --message "commit message" or git commit -s -m "commit message"

If you have any questions please let us know

@rettichschnidi
Copy link
Contributor

2, When you commit the patch to your forked repository, don't forget to sign the commit, all commits in a pull request mist be signed.
git commit --signoff --message "commit message" or git commit -s -m "commit message"

As learned via PR #590: The Signed-off-by is not longer required by eclipse foundation.

@tuve
Copy link
Contributor

tuve commented Apr 22, 2021

I missed that, then even simpler

@sbernard31
Copy link
Contributor

(I added a comment about contribution guide to dedicated issue : #491 (comment))

rettichschnidi added a commit to rettichschnidi/wakaama that referenced this issue Jan 30, 2022
This seems to be the easiest fix that also works for the non-DTLS
client binary.
rettichschnidi added a commit to husqvarnagroup/wakaama that referenced this issue Jan 30, 2022
This seems to be the easiest fix that also works for the non-DTLS
client binary.

Tested by successfully connecting to leshan.eclipseprojects.io
rettichschnidi added a commit to husqvarnagroup/wakaama that referenced this issue Jan 30, 2022
This seems to be the easiest fix that also works for the non-DTLS
client binary.
@rettichschnidi
Copy link
Contributor

@jonathanpallant This should be resolved by #647. Any chance you could give it a try?

@jonathanpallant
Copy link
Author

Sorry, I haven't looked at wakaama in ages - I don't even work for the same company any more.

rettichschnidi added a commit that referenced this issue Feb 4, 2022
This seems to be the easiest fix that also works for the non-DTLS
client binary.

Tested by successfully connecting to leshan.eclipseprojects.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants