Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 37039 - Apache2 apparent hang due to mod_auth_digest entropy starvation
Summary: Apache2 apparent hang due to mod_auth_digest entropy starvation
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Apache Team - Bugzilla Reports
URL:
Whiteboard:
Keywords:
: 37981 45527 (view as bug list)
Depends on: 29932
Blocks:
  Show dependency tree
 
Reported: 2004-01-02 11:13 UTC by Stefan Riemer
Modified: 2005-11-15 14:15 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Riemer 2004-01-02 11:13:06 UTC
There is a problem with /dev/random and mod_auth_digest that makes apache hanging on manual restart.

If you restart apache2 by hand doing /etc/init.d/apache2 restart or /usr/sbin/apache2 -k restart then it starts just one process an in the error logfile the line:
[Mon Nov 24 10:59:06 2003] [notice] Digest: generating secret for digest authentication ...
appears and nothing else happens.
It can be solved by disabling mod_auth_digest, but the reason for this is an empty /dev/random-device, so the apache2-startprocess is just waiting for randomness.

Solution for me (without disabling mod_auth_digest):

MY_BUILTINS="--with-devrandom=/dev/urandom" emerge apache

This makes /dev/urandom the source for randomness on startup and all is fine..

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 FieldySnuts 2004-01-02 11:15:50 UTC
I saw this problem myself today. I disabled that module, but obviously this is unreasonable for people who need it.

Comment 2 Donny Davies (RETIRED) gentoo-dev 2004-01-02 13:12:16 UTC
du -h /usr and your machine's disk will spin, and apache will start much quicker.

Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-03 20:22:27 UTC
This isn't a bug for us, and using /dev/urandom is insecure. you need to make more entropy for your machine. lots of other things will exhibit the same problem for lack of real random data (appearing to hang).
Comment 4 Stefan Riemer 2004-01-04 00:40:36 UTC
The bug is imho that there is no way for the not so experienced user for knowing what is happen.. Look at the forum, there are many questions about this. The startup-script returns as usual with [ok], but this isn't true. There shoul'd be a check, if apache has spawned the workers. If this doesn't happened, then maybe an action like 'du -s /path/to/apache' for gathering randomness and a retry.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-04 01:21:34 UTC
impairing everybody to do a 'du -h /path/to/apache' is not a reasonable answer. look at alternate routes for more entropy data. possible routes include hardware RNG (see recent kernels), net-dev-randomness patches (in gentoo kernels i believe), or any other routes, look in up in the linux kernel mailing list archive. audio-entropyd is one possible route if you have an idle soundcard.
Comment 6 Stefan Riemer 2004-01-04 03:29:16 UTC
I'm not sure for this, but is net-dev-randomness secure? Or at least more secure as /dev/urandom? The possible solutions are ok, but I think there should be a check in the startup script if apache comes up with the workers or is just waiting.. Is there a way for doing a check of /dev/random?
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-04 15:18:48 UTC
Look in /proc/sys/kernel/random/

The way I see it with netdev-random, is since it uses the timing between network IRQs (not the data itself), the only way it can be seriously subverted is if an attacker has total control over your ethernet cable, in which case you have more serious problems anyway.

/dev/urandom uses an SHA hash to cycle itself.

I've added an interesting rng package to the tree, clrngd.

see bug 26071 for the netdev-random waiting for gentoo-sources.
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-12 20:33:10 UTC
*** Bug 37981 has been marked as a duplicate of this bug. ***
Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-12 20:36:56 UTC
note to self: mod_auth_digest needs 20 bytes of raw entropy to start.
need to write some stuff for init.d that checks if enough entropy is available, and display warning otherwise.
Comment 10 Martin Mokrejš 2004-02-28 14:52:19 UTC
Hi,
  I agree something has to happen with the ebuild. I went to reinstall openssl,
but that didn't help. Using strace on openssl I see it uses /dev/urandom.
Why isn't egd and prngd available on gentoo. They are both used to generate
said to be fairly good random data. Actually, the egd guy said that prngd is crap.
That would affect openssl has to rebuilt to use the socket file. Please stick to teh default location and don't invent new place for it. I think it's /var/tmp/egd-pool or something similar.
Comment 11 Jeroen Roos 2004-03-29 01:15:50 UTC
It seems the folks at Redhat faced this problem previously and have solved it by changing /dev/random to /dev/urandom: http://bugzilla.redhat.com/bugzilla/long_list.cgi?buglist=103049
Comment 12 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-03-29 03:07:26 UTC
security: while i don't like the idea of using psuedo-random bits (/dev/urandom instead of /dev/random) for this, you're better qualified to tell me if it's safe to do this in this case.
Comment 13 solar (RETIRED) gentoo-dev 2004-03-29 13:07:29 UTC
Re #5
The hardened-dev-sources support netdev-random. Our patches are broken
out so any other kernel could include them rather trivially.  Note:
netdev-random does not work with pcmcia devices.

Another kernel patch we are about to start reviewing.
http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5-rc2/2.6.5-rc2-mm4/broken-out/urandom-scalability-fix.patch
---
Re: not secuirty@ just my own thoughts.
I would not want to use the /dev/random device for apache..  random is a
blocking device where urandom is not.  Your free do do what you want..
But I/me would also prefer urandom over random in this case.

Note:
You can raise the entropy pool size by simply doing (this helps)
 sysctl -w kernel.random.poolsize=8192

And to see the current amount of random data.
 sysctl kernel.random.entropy_avail
Comment 14 Randy Snow 2004-03-31 09:24:36 UTC
*** Bug 45527 has been marked as a duplicate of this bug. ***
Comment 15 Chuck Short (RETIRED) gentoo-dev 2004-04-15 06:49:44 UTC
This should be fixed in 2.0.49-r1. Please test.
Comment 16 Andriy Rozeluk 2005-11-15 08:53:03 UTC
I, for one, am still seeing this happen on my boxes. Is there a regression?
Comment 17 Michael Stewart (vericgar) (RETIRED) gentoo-dev 2005-11-15 14:15:23 UTC
This should be fixed, though the fix is still in ~arch and not arch. Please see
bug 102587 for details of the fix and how to activate it on your system