strongswan's charon crashes shortly after authentication

Bug #574664 reported by Dan Kegel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
strongswan (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: strongswan

In ubuntu 10.04, I'm configuring a vpn in strongswan 4.3.2-1.1ubuntu1 by hand (without network manager).
All goes fine... up until it crashes.
Here's part of syslog leading up to the crash:

...
May 3 10:17:36 laptop charon: 01[LIB] loading plugin 'resolv-conf' failed: /usr/lib/ipsec/plugins/libstrongswan-resolv-conf.so: cannot open shared object file: No such file or directory
May 3 10:17:36 laptop charon: 01[DMN] loaded plugins: curl ldap random x509 pubkey openssl xcbc hmac agent gmp kernel-netlink stroke updown eapidentity eapmd5 eapgtc eapaka eapmschapv2
May 3 10:17:36 laptop charon: 01[JOB] spawning 16 worker threads
May 3 10:17:36 laptop charon: 05[CFG] crl caching to /etc/ipsec.d/crls enabled
May 3 10:17:36 laptop charon: 08[CFG] received stroke: add connection 'yyy.yyy.yyy'
May 3 10:17:36 laptop charon: 08[LIB] loaded certificate file '/etc/ipsec.d/certs/host.crt'
May 3 10:17:36 laptop charon: 08[CFG] added configuration 'yyy.yyy.yyy'
May 3 10:17:36 laptop charon: 08[CFG] received stroke: initiate 'yyy.yyy.yyy'
May 3 10:17:36 laptop charon: 08[IKE] initiating IKE_SA yyy.yyy.yyy[1] to xxx.xxx.xxx.254
May 3 10:17:36 laptop charon: 08[ENC] generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) ]
May 3 10:17:36 laptop charon: 08[NET] sending packet: from 192.168.1.189[500] to xxx.xxx.xxx.254[500]
May 3 10:17:36 laptop charon: 14[NET] received packet: from xxx.xxx.xxx.254[500] to 192.168.1.189[500]
May 3 10:17:36 laptop charon: 14[ENC] parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(MULT_AUTH) ]
May 3 10:17:36 laptop charon: 14[IKE] local host is behind NAT, sending keep alives
May 3 10:17:36 laptop charon: 14[IKE] received cert request for "C=xxx ..."
May 3 10:17:36 laptop charon: 14[IKE] sending cert request for "C=xxx ..."
May 3 10:17:36 laptop charon: 14[IKE] authentication of 'C=xxx ...' (myself) with RSA signature successful
May 3 10:17:36 laptop charon: 14[IKE] sending end entity cert "C=xxx ..."
May 3 10:17:36 laptop charon: 14[IKE] establishing CHILD_SA yyy.yyy.yyy
May 3 10:17:36 laptop charon: 14[ENC] generating IKE_AUTH request 1 [ IDi CERT CERTREQ IDr AUTH CP SA TSi TSr N(MOBIKE_SUP) N(NO_ADD_ADDR) N(MULT_AUTH) ]
May 3 10:17:36 laptop charon: 14[NET] sending packet: from 192.168.1.189[4500] to xxx.xxx.xxx.254[4500]
May 3 10:17:36 laptop charon: 16[NET] received packet: from xxx.xxx.xxx.254[4500] to 192.168.1.189[4500]
May 3 10:17:36 laptop charon: 16[ENC] parsed IKE_AUTH response 1 [ IDr CERT AUTH CP SA TSi TSr N(AUTH_LFT) N(MOBIKE_SUP) N(ADD_4_ADDR) N(ADD_4_ADDR) N(ADD_4_ADDR) N(ADD_4_ADDR) N(ADD_4_ADDR) N(ADD_4_ADDR) N(ADD_4_ADDR) ]
May 3 10:17:36 laptop charon: 16[IKE] received end entity cert "C=xxx ..."
May 3 10:17:36 laptop charon: 16[CFG] using certificate "C=xxx ..."
May 3 10:17:36 laptop charon: 16[CFG] using trusted ca certificate "C=xxx ..."
May 3 10:17:36 laptop charon: 16[CFG] checking certificate status of "C=xxx ..."
May 3 10:17:36 laptop charon: 16[CFG] fetching crl from 'http://foo.bar.org/pki/pub/crl/cacrl.crl' ...
May 3 10:17:37 laptop charon: 16[CFG] using trusted certificate "C=xxx ..."
May 3 10:17:37 laptop charon: 16[CFG] crl correctly signed by "C=xxx ..."
May 3 10:17:37 laptop charon: 16[CFG] crl is valid: until May 06 06:32:40 2010
May 3 10:17:37 laptop charon: 16[CFG] certificate status is good
May 3 10:17:37 laptop charon: 16[IKE] authentication of 'C=xxx ...' with RSA signature successful
May 3 10:17:37 laptop charon: 16[DMN] thread 3070172016 received 11
May 3 10:17:37 laptop charon: 03[KNL] creating delete job for ESP CHILD_SA with SPI c42e3cbb and reqid {1}
May 3 10:17:37 laptop charon: 16[DMN] killing ourself, received critical signal

Is there a handy recipe for building charon with debugging symbols and starting it under gdb?

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: strongswan-ikev2 4.3.2-1.1ubuntu1
ProcVersionSignature: Ubuntu 2.6.32-21.32-generic 2.6.32.11+drm33.2
Uname: Linux 2.6.32-21-generic i686
Architecture: i386
Date: Mon May 3 11:10:38 2010
ExecutablePath: /usr/lib/ipsec/charon
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release i386 (20091028.5)
ProcEnviron:
 PATH=(custom, no user)
 LANG=en_US.utf8
 SHELL=/bin/bash
SourcePackage: strongswan

Revision history for this message
Dan Kegel (dank) wrote :
Revision history for this message
Martin Willi (martinwilli) wrote :

To build strongSwan with debug symbols, do:

# apt-get build-dep strongswan
# apt-get install devscripts
# apt-get source strongswan
# cd strongswan-4.3.2
# DEB_BUILD_OPTIONS=nostrip debuild

after installing it, you can invoke strongswan with

# ipsec start --attach-gdb

to attach the debugger.

Revision history for this message
Dan Kegel (dank) wrote :

Sorry, I gave up, went to gentoo. (It hurts to say that.) But I heard a rumor that
 ipsec.conf - cachecrls=no (instead of yes) solves the crash on debian.

Revision history for this message
Georg Müller (georgmueller) wrote :

I have the same problem. When starting "/usr/lib/ipsec/starter --nofork --debug-all" I get the following output :

10[DMN] thread 1005078288 received 11
 dumping 12 stack frame addresses:
  /lib/libpthread.so.0 @ 0x7fbc48d21000 [0x7fbc48d308f0]
    -> ??:0
  /lib/libcrypto.so.0.9.8 @ 0x7fbc47021000 (EVP_CIPHER_CTX_set_key_length+0x7) [0x7fbc470f1c27]
    -> ??:0
  /usr/lib/ipsec/plugins/libstrongswan-openssl.so @ 0x7fbc44b8c000 [0x7fbc44b90352]
    -> ??:0
  /usr/lib/ipsec/plugins/libstrongswan-openssl.so @ 0x7fbc44b8c000 [0x7fbc44b90454]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc49399fb0]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc49396230]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc493ab986]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc493ac34d]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc4939f920]
    -> ??:0
  /usr/lib/ipsec/charon @ 0x7fbc49382000 [0x7fbc493a0dfe]
    -> ??:0

When recompiling strongswan from git (tag 4.3.2) without any changes, I do not get any errors

Revision history for this message
Georg Müller (georgmueller) wrote :

I recompiled the package like suggested in comment #2 (and an additional change to "-O0" and reran the test:

Here is the data:
0x00007ffff5cf2c27 in EVP_CIPHER_CTX_set_key_length () from /lib/libcrypto.so.0.9.8
(gdb) bt
#0 0x00007ffff5cf2c27 in EVP_CIPHER_CTX_set_key_length () from /lib/libcrypto.so.0.9.8
#1 0x00007ffff3789936 in crypt (this=0x7ffff8255110, data=..., iv=..., dst=0x7fffeea76970, enc=1) at openssl_crypter.c:136
#2 0x00007ffff3789ab1 in encrypt (this=0x7ffff8255110, data=..., iv=..., dst=0x7fffeea76970) at openssl_crypter.c:159
#3 0x00007ffff7fa93ce in encrypt (this=0x7ffff8256e90) at encoding/payloads/encryption_payload.c:366
#4 0x00007ffff7fa2ae0 in encrypt_payloads (this=0x7ffff8252430, crypter=0x7ffff8255110, signer=0x7ffff8254cb0) at encoding/message.c:1085
#5 0x00007ffff7fa2df9 in generate (this=0x7ffff8252430, crypter=0x7ffff8255110, signer=0x7ffff8254cb0, packet=0x7ffff82506b0) at encoding/message.c:1142
#6 0x00007ffff7fbb888 in generate_message (this=0x7ffff824fec0, message=0x7ffff8252430, packet=0x7ffff82506b0) at sa/ike_sa.c:900
#7 0x00007ffff7fc409f in build_request (this=0x7ffff8250650) at sa/task_manager.c:446
#8 0x00007ffff7fc4357 in process_response (this=0x7ffff8250650, message=0x7ffff82527e0) at sa/task_manager.c:517
#9 0x00007ffff7fc5158 in process_message (this=0x7ffff8250650, msg=0x7ffff82527e0) at sa/task_manager.c:889
#10 0x00007ffff7fbcce6 in process_message (this=0x7ffff824fec0, message=0x7ffff82527e0) at sa/ike_sa.c:1302
#11 0x00007ffff7fb27a6 in execute (this=0x7ffff8244e70) at processing/jobs/process_message_job.c:78
#12 0x00007ffff7fb4094 in process_jobs (this=0x7ffff8207940) at processing/processor.c:123
#13 0x00007ffff79299ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#14 0x00007ffff71ff6fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

(gdb) p/x *this
$1 = {public = {crypter_interface = {encrypt = 0x7ffff3789a57, decrypt = 0x7ffff37899f6, get_block_size = 0x7ffff3789ab8, get_key_size = 0x7ffff3789acf, set_key = 0x7ffff3789ae1, destroy = 0x7ffff3789b27}}, key = {ptr = 0x7ffff82550b0,
    len = 0x10}, cipher = 0x7ffff5f8c2a0}

Revision history for this message
Georg Müller (georgmueller) wrote :

I installed the debug packages for libssl0.9.8 and added some debugging code.

EVP_CipherInit_ex fails (returns 0)
ctx->cipher is null, which causes the segfault.

(gdb) p *this->cipher
$2 = {nid = 419, block_size = 16, key_len = 16, iv_len = 16, flags = 5122, init = 0x7ffff5cf47b0 <aes_init_key>, do_cipher = 0x7ffff5cf4c90 <aes_128_cbc_cipher>, cleanup = 0, ctx_size = 244, set_asn1_parameters = 0,
  get_asn1_parameters = 0, ctrl = 0, app_data = 0x0}

My cpu supports aesni. This might cause the problem.
I will have a look into the aesni patches in libssl0.9.8

My test with vanilla strongswan 4.3.2 was w/o openssl support, this may be the reason why it worked there

Revision history for this message
Georg Müller (georgmueller) wrote :

I added some ssl debugging code and get these errors:

140737079842576:error:260B9092:engine routines:ENGINE_get_cipher:unimplemented cipher:tb_cipher.c:126:
140737079842576:error:0608C086:digital envelope routines:DO_EVP_ENC_ENGINE:initialization error:enc_min.c:172:

Revision history for this message
Georg Müller (georgmueller) wrote :

updating openssl/libssl with packages from lucid-proposed (see bug #590639) fixes my crashes.

Changed in strongswan (Ubuntu):
status: New → 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.