Skip to contentSkip to conversation

2.1_rc13 & rc15 Segfault when client connects

Openvpn-devel Daniel Johnson 2 participants 2 messages Dec 12, 2008 – Dec 14, 2008 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pardon the lack of debug information, but the issue stopped and I have not been able to make it repeat. I hope to have packet captures and better debugging the next time it happens.

We operate two main OpenVPN servers, Mercury and Gemini. Both are Slackware 12.1, kernel 2.6.25.3. When this began yesterday afternoon both were running v2.1_rc13. Our systems randomly pick the server to connect to.

Due to a configuration mistake, Mercury had not started OpenVPN after a recent reboot. I was testing a laptop and could not connect at all. This led me to discover Mercury's problem and correct it. Gemini's processes had segfaulted a few minutes before, and my OpenVPN-checking cron job was about to fix it.

I still couldn't connect. Found that the UDP process had segfaulted on Mercury just after I walked away, and Gemini had died seconds after the cronjob kicked it. I observed this several times on both servers. An example syslog message:

Mercury kernel: openvpn[3247]: segfault at 0 ip b7e211a3 sp

                   bfbc1a5c error 4 in libc-2.7.so[b7daf000+146000]

The 'ip' is consistently in the form b7???1a3, 'sp' is bf?????c. The hex string in brackets is consistent right of the '+'.

Upgraded Gemini to v2.1_rc15, no effect. Set one of the servers to "verb 4" instead of the usual "verb 3", but didn't see anything interesting. Eventually it occurred to me to see if a particular PC was triggering this, and found that "S1550" was shown connecting immediately before each segfault. I removed S1550 from the list of allowed certificates on Mercury and the crashes stopped. Before I could test re-allowing it, the user turned his computer off for the night.

This morning I confirmed he was running v2.1_rc9. I had it connect and everything was normal. I upgraded him to v2.1_rc13 and went on with the day. A few minutes later I noticed that a /different/ machine had just caused both servers to segfault (but only one time). I don't know if the user gave up or what, but he later connected OK. He is also running v2.1_rc9.

I've been slowly installing the client on computers, and have a half dozen or so volunteer guinea pigs. Until last night my greatest problem was an occasional processes hang, which my cron script fixes. Having both servers go down (nearly) simultaneously is distressing when I'm basically ready for full deployment.

One (possibly) odd thing about my configuration is using the auth-pam plugin and Samba to authenticate against our MS Active Directory domain. I can post complete config information if you'd like.

Daniel Johnson
[email protected]...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFJQs6N6vGcUBY+ge8RApPmAJ9ETfs1lOPBmZdv4+ejiQxkVKlYngCg0dSH bucRds/dfwPjO7N5tsXZ/3E=
=Im34
-----END PGP SIGNATURE-----

#3 lore raw
In reply to a message not in the archive
Quoted 5 lines · Daniel Johnson
Quoted 3 lines · David Sommerseth

I am willing to believe that this issue might be caused by the plugin, somehow. I see you posted a auth-pam.c patch, and it might be you have already fixed this issue by now.

Quoted 7 lines

To my understanding, the segfault is indeed occurring when the plugin could to be evaluating the username and password, but until I can engineer another round of crashes I can't confirm it. My patch merely improves the substitution of "USERNAME" and "PASSWORD", and has been in use since my tests began around mid-August. It could still be the source of my occasional crashes, but even then something has changed to magnify the effect.

Well, what I struggled with was that I was using the srand() function. I did not detect any memory leaks, but I got some pointers which might have become wild. I replaced my functions to use OpenSSL rand-functions, and since that time, OpenVPN has been stable. A stray memory pointer is all you need to make it crash.

Quoted 10 lines
Quoted 4 lines

One thing to do, to grab more debug info, is to run openvpn server via gdb. Another approach can be to run it via valgrind (but that chokes performance, noticeably). That way you will be able to get a backtrace on more where concretely things goes wrong.

I'll look into using gdb on Monday. If these were physical machines I'd think that valgrind wouldn't hurt too badly, we've only got a 3mbps internet connecting in the first place. But since these are VMs....well, do you think valgrind might be an additional burden to the host computers?

Valgrind will not give any extra load on the servers, it will just slow down OpenVPN ... and it easily goes down to 20-25 times slower, so with slow, I really mean reeeeaaaaally sloooooow. In small "file" transfers, and especially if not time critical, you might not notice it so much. But I guarantee you that you will notice it if you try to stream media over such a link or do bigger file transfers.

Anyway, valgrind with --leak-check=full gives a good overview. If run with --show-reachable=yes, it will provide even more info, but might not reveal too much in this phase. And be aware, it might show up a lot of false positives as well. Many of them seems to be connected to OpenSSL (BIO calls, among others)

Quoted 6 lines
Quoted 5 lines

The main reason I am guessing it is the plugin, is that I've been writing a plugin myself and struggled with a very unstable OpenVPN solution until I found some NULL pointers and string functions, which caused SEGV. After those things were sorted out and fixed, the plugin and OpenVPN have been rock solid again.

Quoted 7 lines
Quoted 3 lines

Please confirm my suspicion or send a backtrace from gdb. To do that in a good way, OpenVPN must have debug information, ie. compiled with '-g'.

I'll go ahead and compile with -g on both servers, but I think I'll wait to upgrade Mercury to v2.1_rc15 until I look at gdb. Perhaps it will be helpful to have one crash in rc13 and one in rc15?

Probably will not make a big difference, if the assumption is correct that the instability is caused by the plug-in. Btw. I'm running v2.1_rc15 on the server side with my plug-in
(http://www.eurephia.net/ - also an authentication plug-in, with iptables integration) without any such issues at all.

Both valgrind and gdb will give an idea of where things crashes. gdb will be more precise, but valgrind can often confirm or give a very good indication as well. If you set ulimit -c unlimited, you should get a core file as well, which can be used with gdb afterwards.

kind regards,

David Sommerseth