Re: [PATCH] [1/4] /dev/random: Fix latency in rekeying sequence number

Jens Maurer
2004-08-22T21:31:12Z

Lee Revell wrote:
> This patch does not actually fix the problem, as 3-700usecs is still
> spent in the spinlocked region, this just causes it to be done out of a
> workqueue.

May I suggest that get_random_bytes() be called *outside* of the
spinlocked region on a temporary buffer, assuming that the SHA
algorithm is the problem here?

Something like this (untested):

u32 tmp[sizeof(keyptr->secret)/4]; /* on stack */
get_random_bytes(tmp, sizeof(tmp));
spin_lock_bh(&ip_lock);
memcpy(keyptr->secret, tmp, sizeof(keyptr->secret));
/* ... other housekeeping ... */
spin_unlock_bh(&ip_lock);

Jens Maurer