hipconf add hi default fails

Bug #701828 reported by Samu Varjonen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HIPL
Fix Released
Undecided
David Martin

Bug Description

Hipconf add hi default fails complaining about unsupported algorithms (DSA?). After this error the hip_close will result in backtrace due to invalid pointer caused by the unknown algorithm.

Tested with trunk and ecc branches (up-to-date/clean install).

Output from hipconf:
$ sudo tools/hipconf add hi default
Using hostname: wel-36
Using format dsa and file (null)
hit: 2001:0017:14b4:3f28:25a5:eedb:e25c:e015
hi is private rsa/dsa
DSA HIT: 7877:b1bf:ff7f:0000:0700:0000:0000:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
HIP message contained an error.
Sending msg failed.
Failed to send a message to the HIP daemon.
(Check syntax for hipconf. Is hipd running or root privilege needed?)
Error: Cannot configure the HIP daemon.

hipd output:
debug(lib/core/message.c:494@hip_read_user_control_msg): Receiving user message.
debug(lib/core/message.c:514@hip_read_user_control_msg): received user message from local port 1001
debug(hipd/user.c:194@hip_user_run_handles): User message (type: 65) not dynamically handled -> trigger static handling.
debug(hipd/user.c:258@hip_handle_user_msg): User message from port 1001
debug(hipd/user.c:286@hip_handle_user_msg): HIP user message type is: 65
debug(hipd/hidb.c:611@hip_handle_add_local_hi): /* --------- */
debug(hipd/hidb.c:612@hip_handle_add_local_hi): input->hits = : 0000:0000:0000:0000:0000:0000:0000:0000
debug(hipd/hidb.c:613@hip_handle_add_local_hi): input->hitr = : 0000:0000:0000:0000:0000:0000:0000:0000
debug(hipd/hidb.c:626@hip_handle_add_local_hi): host id found in the msg
debug(hipd/hidb.c:373@hip_get_hostid_entry_by_lhi_and_algo): Failed to find a host ID entry, Returning NULL.
debug(hipd/hidb.c:544@hip_add_host_id): Generating a new R1 set.
error(hipd/hidb.c:558@hip_add_host_id): Unsupported algorithms
error(hipd/hidb.c:655@hip_handle_add_local_hi): adding of local host identity failed
debug(hipd/hip_socket.c:145@hip_handle_user_sock): Send response
debug(hipd/hip_socket.c:151@hip_handle_user_sock): Sending message (type=65) response to port 1001
debug(hipd/hip_socket.c:152@hip_handle_user_sock): To address: 0000:0000:0000:0000:0000:0000:0000:0001
debug(hipd/user.c:233@hip_sendto_user): Sending msg type 65
debug(hipd/hip_socket.c:157@hip_handle_user_sock): Response sent ok
debug(hipd/hip_socket.c:285@hip_run_socket_handles): result: 0

Closing output of hipd:
debug(hipd/init.c:1052@hip_close): Starting to close HIP daemon...
error(hipd/hipd.c:410@hipd_main): select() error: Interrupted system call.
debug(hipd/hadb.c:1207@hip_delete_all_sp):
debug(hipd/hadb.c:1209@hip_delete_all_sp): DEBUG: DUMP SPI LISTS
debug(hipd/hadb.c:1211@hip_delete_all_sp): DELETING HA HT
debug(hipd/netdev.c:549@hip_delete_all_addresses): address to be deleted
: 2001:0708:0140:0200:0222:19ff:fe18:8ce2
debug(hipd/netdev.c:549@hip_delete_all_addresses): address to be deleted
: 128.214.114.246
info(hipd/init.c:960@hip_exit): Uninitializing RVS / HIP relay database and whitelist.
info(hipd/init.c:965@hip_exit): hip_raw_sock_input_v6
info(hipd/init.c:970@hip_exit): hip_raw_sock_output_v6
info(hipd/init.c:975@hip_exit): hip_raw_sock_input_v4
info(hipd/init.c:980@hip_exit): hip_raw_sock_output_v4
info(hipd/init.c:985@hip_exit): hip_nat_sock_input_udp
info(hipd/init.c:990@hip_exit): hip_nat_sock_output_udp
error(hipd/hidb.c:301@hip_del_host_id): Cannot free key, because key type is unkown.
*** glibc detected *** hipd/hipd: free(): invalid pointer: 0x00000000018aa500 ***
======= Backtrace: =========
/lib/libc.so.6(+0x775b6)[0x7f3b38f185b6]
/lib/libc.so.6(cfree+0x73)[0x7f3b38f1ee83]
hipd/hipd[0x411f22]
hipd/hipd[0x412162]
hipd/hipd[0x4165c7]
hipd/hipd[0x413dce]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f3b38ebfc4d]
hipd/hipd[0x405c69]

Related branches

Revision history for this message
Henrik Ziegeldorf (henrik-ziegeldorf) wrote :
Download full text (5.8 KiB)

I could not reproduce this bug in trunk.

My output looks like this:

HIPCONF

------------------------------
Using hostname: thesis1
Using format dsa and file (null)
hit: 2001:001f:3851:d3dc:09ac:ed0e:e910:1877
hi is private dsa
DSA HIT: f081:be1a:ff7f:0000:f806:aa76:4d7f:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: thesis1
Using format dsa and file (null)
hit: 2001:0019:fa2a:8d13:c343:7c7e:570e:9e73
hi is private dsa
DSA HIT: 2001:0019:fa2a:8d13:c343:7c7e:570e:9e73
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: thesis1
Using format rsa and file (null)
rsa_to_hip_endpoint called
hit: 2001:001d:f441:14bf:7c87:cb82:1444:d129
hi is private rsa
RSA HIT: 2001:001d:f441:14bf:7c87:cb82:1444:d129
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: thesis1
Using format rsa and file (null)
rsa_to_hip_endpoint called
hit: 2001:0012:9b4a:8ad5:9ffc:a14b:3ebf:3cfc
hi is private rsa
RSA HIT: 2001:0012:9b4a:8ad5:9ffc:a14b:3ebf:3cfc
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
User message was sent successfully to the HIP daemon.
------------------------------

HIPD
------------------------------
debug(hipd/hip_socket.c:129@hip_handle_user_sock): received on: hip_user_sock
debug(lib/core/message.c:501@hip_read_user_control_msg): Receiving user message.
debug(lib/core/message.c:517@hip_read_user_control_msg): received user message from local port 1001
debug(hipd/user.c:194@hip_user_run_handles): User message (type: 65) not dynamically handled -> trigger static handling.
debug(hipd/user.c:256@hip_handle_user_msg): User message from port 1001
debug(hipd/user.c:284@hip_handle_user_msg): HIP user message type is: 65
debug(hipd/hidb.c:552@hip_handle_add_local_hi): /* --------- */
debug(hipd/hidb.c:553@hip_handle_add_local_hi): input->hits = : 0000:0000:0000:0000:0000:0000:0000:0000
debug(hipd/hidb.c:554@hip_handle_add_local_hi): input->hitr = : 0000:0000:0000:0000:0000:0000:0000:0000
debug(hipd/hidb.c:567@hip_handle_add_local_hi): host id found in the msg
error(hipd/hidb.c:468@hip_add_host_id): Trying to add duplicate lhi
error(hipd/hidb.c:591@hip_handle_add_local_hi): Ignoring redundant HI
debug(hipd/hip_socket.c:145@hip_handle_user_sock): Send response
debug(hipd/hip_socket.c:151@hip_handle_user_sock): Sending message (type=65) response to port 1001
debug(hipd/hip_socket.c:152@hip_handle_user_sock): To address: 0000:0000:0000:0000:0000:0000:0000:0001
debug(hipd/user.c:231@hip_sendto_user): Sending msg type 65
debug(hipd/hip_socket.c:157@hip_handle_user_sock): Response sent ok
debug(hipd/hip_socket.c:285@hip_run_socket_handles): result: 0
debug(hipd/hip_socket.c:129@hip_handle_user_sock): received on: hip_user_sock
debug(lib/core/message.c:501@hip_read_user_control_msg): Receiving user message.
debug(lib/core/message.c:517@hip_read_user_control_msg): received user message from local por...

Read more...

Revision history for this message
Henrik Ziegeldorf (henrik-ziegeldorf) wrote :

Same for ecc branch.

Revision history for this message
Miika Komu (miika-iki) wrote :

I get:

mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf add hi default
Using hostname: bling
Using format dsa and file (null)
hit: 2001:001d:b194:9fb4:540d:2332:cef0:3b9f
hi is private dsa
DSA HIT: 6097:bf26:ff7f:0000:f876:263b:d37f:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
HIP message contained an error.
Sending msg failed.
Failed to send a message to the HIP daemon.
(Check syntax for hipconf. Is hipd running or root privilege needed?)
Error: Cannot configure the HIP daemon.

Revision history for this message
Miika Komu (miika-iki) wrote :

And hipd crashes when I press ctrl+c.

Revision history for this message
Miika Komu (miika-iki) wrote :
Download full text (4.0 KiB)

It appears that hipd returns an error when I do:

mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf add hi default
Using hostname: bling
Using format dsa and file (null)
hit: 2001:001d:b194:9fb4:540d:2332:cef0:3b9f
hi is private dsa
DSA HIT: 906c:b49c:ff7f:0000:f866:1ae3:657f:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
HIP message contained an error.
Sending msg failed.
Failed to send a message to the HIP daemon.
(Check syntax for hipconf. Is hipd running or root privilege needed?)
Error: Cannot configure the HIP daemon.

But if I try to obtain the HITs, it seems ok:

mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf get hi all
Sending user message 21 to HIPD on socket 3
Sent 40 bytes
Waiting to receive daemon info.
104 bytes received from HIP daemon
Public RSA 2001:19:11ac:e3af:2367:11a4:1a36:36ec LSI 1.0.0.1
Anonymous Unknown algorithm (0) ::540d:2332:cef0:3b9f LSI 1.0.0.2

Note that adding HIs twice completely crashes hipd (on second time hipconf returns success!):

mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf add hi default
Using hostname: bling
Using format dsa and file (null)
hit: 2001:001f:fa9b:9d02:4873:892c:add3:bcea
hi is private dsa
DSA HIT: 60a3:f348:ff7f:0000:f856:8dd4:957f:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
HIP message contained an error.
Sending msg failed.
Failed to send a message to the HIP daemon.
(Check syntax for hipconf. Is hipd running or root privilege needed?)
Error: Cannot configure the HIP daemon.
mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf add hi default
Using hostname: bling
Using format dsa and file (null)
hit: 2001:001f:fa9b:9d02:4873:892c:add3:bcea
hi is private dsa
DSA HIT: 009e:f67e:ff7f:0000:f8c6:6959:387f:0000
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: bling
Using format dsa and file (null)
hit: 2001:001f:7416:1e7b:0184:72b4:c9d2:fb1d
hi is private dsa
DSA HIT: 2001:001f:7416:1e7b:0184:72b4:c9d2:fb1d
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: bling
Using format rsa and file (null)
rsa_to_hip_endpoint called
hit: 2001:001b:aa73:3268:249a:a38c:c468:7c97
hi is private rsa
RSA HIT: 2001:001b:aa73:3268:249a:a38c:c468:7c97
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
Using hostname: bling
Using format rsa and file (null)
rsa_to_hip_endpoint called
hit: 2001:001e:a853:f362:2927:d0e2:8f41:13b5
hi is private rsa
RSA HIT: 2001:001e:a853:f362:2927:d0e2:8f41:13b5
Sending user message 65 to HIPD on socket 3
Sent 2440 bytes
Waiting to receive daemon info.
2440 bytes received from HIP daemon
User message was sent successfully to the HIP daemon.
mkomu@bling:~/projects/hipl-bzr/hipl$ sudo tools/hipconf get hi all
Sending user message 21 to HIPD on socket 3
Sent 40 bytes
Waiting to receive daemon info.
^C
(...

Read more...

Revision history for this message
Henrik Ziegeldorf (henrik-ziegeldorf) wrote :

Ok, I know what the bug is, but I haven't fixed it yet.

The problem is, that for DSA keys, someone forgot to set the algorithm field (its 0). With the changes inspired by my ecc branch (that's the reason why it fails there too), such a case gets caught in the switch's default case and makes the precreate_r1 function fail (before it was just assumed "if its not RSA its DSA). Now the failing during precreation of the r1 lets hipd's init procedure fail. This then leads to deinitialization, and amongst others, to the deinitialization of the hidb. Now, what happens is nothing new: We deinit something that hasn't been properly initialized (see other recent bugs) and the deinit function is not robust enough and fails gloriously.

A quick and dirty fix is on the way, but it is obvious that a proper solution needs to
a) set the algorithm field properly
b) make the deinit functions more robust

David Martin (martin-lp)
Changed in hipl:
status: New → Confirmed
assignee: nobody → David Martin (martin-lp)
Revision history for this message
David Martin (martin-lp) wrote :

The attached patch doesn't fix the bug but keeps hipd from crashing. I'll have a look at the faulty algorithm field Henrik mentions.

Revision history for this message
Henrik Ziegeldorf (henrik-ziegeldorf) wrote :

I have committed a proper fix in revision 5509 (fixes point a) from my post).
HIPD does not crash any more BEX works with DSA keys. HIPCONF seems to work allright. However, I'm by far no expert on the hipconf part, so could anyone please verify that hipconf does its job?

Changed in hipl:
status: Confirmed → Fix Committed
Changed in hipl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.