lkml.org 
[lkml]   [2014]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] urandom: handle signals immediately
On Sat, Nov 29, 2014 at 10:12:29AM +0100, Heinrich Schuchardt wrote:
> Without the patch device /dev/urandom only considers signals when a
> rescheduling of the thread is requested. This may imply that
> signals will not be handled for time intervals in excess of 30s.

Sorry, I didn't see your e-mail for a while; it got lost in my inbox
due to my being travelling for Thanksgiving weeksend.

I'm not sure where you are getting 30 seconds from, but you're right
that it would be better to check signal_pending() on each loop. That
being said, your patch isn't right.

> + /*
> + * getrandom must not be interrupted by a signal while
> + * reading up to 256 bytes.
> + */
> + if (signal_pending(current) && ret > 256)
> + break;
> + if (need_resched())
> schedule();
> - }

This means that we can reschedule even for small requests, and that's
no good; getrandom *must* be atomic. You also need to return
-ERESTARTSYS if we get interrupted with no bytes. So this needs to be
something like this:

if (ret > 256) {
if (signal_pending(current)) {
if (ret == 0)
ret = -ERESTARTSYS;
break;
}
if (need_resched())
schedule();
}

Cheers,

- Ted


\
 
 \ /
  Last update: 2014-12-19 18:21    [W:0.048 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site