# libgcrypt general protection fault in call from vpnc

## ese002

[A similar but less thorough post from another use appeared in networking almost two months ago without response]

When launching vpnc, I get a segfault.  In /var/log/messages, I see this message:

Oct 26 13:45:16 crab kernel: [24258.663371] vpnc[26678] general protection ip:b775e71f sp:bf874c60 error:0 in libgcrypt.so.11.7.0[b7734000+77000]

vpnc --version

vpnc version 0.5.3

Copyright (C) 2002-2006 Geoffrey Keating, Maurice Massar, others

vpnc comes with NO WARRANTY, to the extent permitted by law.

You may redistribute copies of vpnc under the terms of the GNU General

Public License.  For more information about these matters, see the files

named COPYING.

Built with certificate support.

Supported DH-Groups: nopfs dh1 dh2 dh5

Supported Hash-Methods: md5 sha1

Supported Encryptions: null des 3des aes128 aes192 aes256

Supported Auth-Methods: psk psk+xauth hybrid(rsa)

crab eric # emerge --search libgcrypt

Searching...    

[ Results for search key : libgcrypt ]

[ Applications found : 1 ]

*  dev-libs/libgcrypt

      Latest version available: 1.5.0-r2

      Latest version installed: 1.5.0-r2

      Size of files: 1,404 kB

      Homepage:      http://www.gnupg.org/

      Description:   General purpose crypto library based on the code used in GnuPG

      License:       LGPL-2.1 MIT

I run almost entirely up to the moment stable.

Kernel version is 3.3.8 and has been for a while.

This *was* working about two weeks ago.  Since then, I've recompiled everything and moved from Athlon-XP to Intel i5-3570.   I'm still running 32-bit but with PAE enabled.  Thinking that it might be some AMD binary that I somehow missed, I did an emerge --emptytree net-misc/vpnc

The last bits of the debug output from vpnc follow.

S4.5 AM_packet3

 [2012-10-26 14:25:40]

   size = 140, blksz = 16, padding = 4

 sending: ========================>

   BEGIN_PARSE

   Received Packet Len: 172

   i_cookie: 62f410f7 c003a0dc

   r_cookie: 822ad210 5aebd207

   payload: 08 (ISAKMP_PAYLOAD_HASH)

   isakmp_version: 10

   exchange_type: 04 (ISAKMP_EXCHANGE_AGGRESSIVE)

   flags: 01

   message_id: 00000000

   len: 000000ac

   PARSING PAYLOAD type: 08 (ISAKMP_PAYLOAD_HASH)

   next_type: 0b (ISAKMP_PAYLOAD_N)

   length: 0018

   ke.data:

   84ec20f9 d1080fa6 a5582660 9afbf087 5958e8ba

   DONE PARSING PAYLOAD type: 08 (ISAKMP_PAYLOAD_HASH)

   PARSING PAYLOAD type: 0b (ISAKMP_PAYLOAD_N)

   next_type: 0d (ISAKMP_PAYLOAD_VID)

   length: 001c

   n.doi: 00000001 (ISAKMP_DOI_IPSEC)

   n.protocol: 01 (ISAKMP_IPSEC_PROTO_ISAKMP)

   n.spi_length: 10

   n.type: 6002 (ISAKMP_N_IPSEC_INITIAL_CONTACT)

   n.spi: 62f410f7 c003a0dc 822ad210 5aebd207

   n.data: 

   DONE PARSING PAYLOAD type: 0b (ISAKMP_PAYLOAD_N)

   PARSING PAYLOAD type: 0d (ISAKMP_PAYLOAD_VID)

   next_type: 0d (ISAKMP_PAYLOAD_VID)

   length: 0014

   ke.data: 126e1f57 7291153b 20485f7f 155b4bc8

   (unknown)

   DONE PARSING PAYLOAD type: 0d (ISAKMP_PAYLOAD_VID)

   PARSING PAYLOAD type: 0d (ISAKMP_PAYLOAD_VID)

   next_type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   length: 0014

   ke.data: 12f5f28c 457168a9 702d9fe2 74cc0100

   (Cisco Unity)

   DONE PARSING PAYLOAD type: 0d (ISAKMP_PAYLOAD_VID)

   PARSING PAYLOAD type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   next_type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   length: 0018

   ke.data:

   553c3ef5 a4ef391d f92294fd 700bae30 cc1091a5

   DONE PARSING PAYLOAD type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   PARSING PAYLOAD type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   next_type: 00 (ISAKMP_PAYLOAD_NONE)

   length: 0018

   ke.data:

   676a45a0 4e1e0b4b 7648dd58 1e3cd52e 0cb7a841

   DONE PARSING PAYLOAD type: 82 (ISAKMP_PAYLOAD_NAT_D_OLD)

   PARSING PAYLOAD type: 00 (ISAKMP_PAYLOAD_NONE)

   PARSE_OK

Segmentation fault

----------

## Hu

What does the backtrace show?

----------

## ese002

crab eric # gdb vpnc          

GNU gdb (Gentoo 7.3.1 p2) 7.3.1

Copyright (C) 2011 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 "i686-pc-linux-gnu".

For bug reporting instructions, please see:

<https://bugs.gentoo.org/>...

Reading symbols from /usr/sbin/vpnc...(no debugging symbols found)...done.

(gdb) run

Starting program: /usr/sbin/vpnc 

warning: Could not load shared library symbols for linux-gate.so.1.

Do you need "set solib-search-path" or "set sysroot"?

[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.

0xb7f6771f in ?? () from /usr/lib/libgcrypt.so.11

(gdb) bt

#0  0xb7f6771f in ?? () from /usr/lib/libgcrypt.so.11

#1  0xb7f6813e in ?? () from /usr/lib/libgcrypt.so.11

#2  0xb7f685cc in ?? () from /usr/lib/libgcrypt.so.11

#3  0xb7f68309 in ?? () from /usr/lib/libgcrypt.so.11

#4  0xb7f4d5c6 in ?? () from /usr/lib/libgcrypt.so.11

#5  0xb7f437fb in gcry_cipher_setkey () from /usr/lib/libgcrypt.so.11

#6  0x08052116 in ?? ()

#7  0x08057935 in ?? ()

#8  0x08059dd3 in ?? ()

#9  0xb7d23596 in __libc_start_main () from /lib/libc.so.6

#10 0x0804a791 in ?? ()

Backtrace stopped: Not enough registers or memory available to unwind further

----------

## ese002

Here is a better backtrace with debug symbols:

Program received signal SIGSEGV, Segmentation fault.

0xb7f6770f in do_aesni_enc_aligned (a=0xb7fa1740 "\001K\257\"x\246\235\063\035Q\200\020\066C\351\232", 

    b=0xbfffe7d0 "", ctx=0xbfffe5e4) at rijndael.c:710

710	rijndael.c: No such file or directory.

	in rijndael.c

(gdb) bt

#0  0xb7f6770f in do_aesni_enc_aligned (

    a=0xb7fa1740 "\001K\257\"x\246\235\063\035Q\200\020\066C\351\232", b=0xbfffe7d0 "", ctx=0xbfffe5e4)

    at rijndael.c:710

#1  do_aesni (ctx=0xbfffe5e4, decrypt_flag=<optimized out>, bx=0xbfffe7d0 "", 

    ax=0xb7fa1740 "\001K\257\"x\246\235\063\035Q\200\020\066C\351\232") at rijndael.c:1132

#2  0xb7f6810e in rijndael_encrypt (context=0xbfffe5e4, b=0xbfffe7d0 "", 

    a=0xb7fa1740 "\001K\257\"x\246\235\063\035Q\200\020\066C\351\232") at rijndael.c:1155

#3  0xb7f6859c in selftest_basic_128 () at rijndael.c:1660

#4  0xb7f682d9 in selftest () at rijndael.c:1749

#5  do_setkey (keylen=32, 

    key=0x8075ae0 "\267\250g;\372OQX\230\327\215D,S\370\016\351\245\363\351S\025N\346+,\005\375_6\345\223", ctx=0x8075250) at rijndael.c:209

#6  rijndael_setkey (context=0x8075250, 

    key=0x8075ae0 "\267\250g;\372OQX\230\327\215D,S\370\016\351\245\363\351S\025N\346+,\005\375_6\345\223", keylen=32) at rijndael.c:444

#7  0xb7f4d5c6 in cipher_setkey (c=0x80751d0, key=<optimized out>, keylen=32) at cipher.c:900

#8  0xb7f437fb in gcry_cipher_setkey (hd=0x80751d0, key=0x8075ae0, keylen=32) at visibility.c:521

#9  0x08052116 in isakmp_crypt (s=0xbfffea98, 

    block=0x806c8c0 " \315\201\303\304\253/#\202*\322\020\362\355\344\222\b\020\004\001", blocklen=172, 

    enc=1) at vpnc.c:551

#10 0x08057935 in do_phase1_am_packet3 (s=0xbfffea98) at vpnc.c:2058

#11 do_phase1_am (key_id=<optimized out>, shared_key=<optimized out>, s=0xbfffea98) at vpnc.c:2088

#12 0x08059dd3 in main (argc=1, argv=0xbfffee94) at vpnc.c:3207

----------

## ese002

If I build the libgcrypt sources by hand and install in /usr/local (with LD_LIBRARY_PATH set appropriately) vpnc works fine.  So, whatever the problem is has to do with flags or patches applied in the ebuild.

----------

