From nobody@www.freebsd.org  Fri May 24 15:41:32 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id 3B69737B404
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 24 May 2002 15:41:32 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g4OMfWhG095117
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 24 May 2002 15:41:32 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g4OMfWVD095116;
	Fri, 24 May 2002 15:41:32 -0700 (PDT)
Message-Id: <200205242241.g4OMfWVD095116@www.freebsd.org>
Date: Fri, 24 May 2002 15:41:32 -0700 (PDT)
From: Andreas Gustafsson <gson@nominum.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /dev/random does not obey O_NONBLOCK flag
X-Send-Pr-Version: www-1.0

>Number:         38527
>Category:       kern
>Synopsis:       /dev/random does not obey O_NONBLOCK flag
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 24 15:50:01 PDT 2002
>Closed-Date:    Fri Nov 16 06:59:02 UTC 2007
>Last-Modified:  Fri Nov 16 06:59:02 UTC 2007
>Originator:     Andreas Gustafsson
>Release:        4.5-STABLE
>Organization:
Nominum, Inc
>Environment:
FreeBSD yomiko.engr.nominum.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed May  1 17:12:00 PDT 2002     root@yomiko.engr.nominum.com:/usr/obj/usr/src/sys/YOMIKO  i386
>Description:
In FreeBSD 4.5, reads on /dev/random are nonblocking by default.
This is incompatible with both the NetBSD and the Linux
/dev/random. Reads should be nonblocking if and only if the
O_NONBLOCK flag was passed to open().

>How-To-Repeat:
Type "od -c </dev/random" and note that the od process exits
after printing a few bytes of random data.  Repeat on a NetBSD
or Linux system and note that od blocks until more entropy has
been gathered (e.g., after vigorous movement of the mouse).

>Fix:

>Release-Note:
>Audit-Trail:

From: Nate Lawson <nate@root.org>
To: freebsd-gnats-submit@FreeBSD.org, gson@nominum.com
Cc:  
Subject: Re: kern/38527: /dev/random does not obey O_NONBLOCK flag
Date: Tue, 25 Jun 2002 13:00:04 -0700 (PDT)

 This behavior is intentional and was changed some time ago.  If you want
 to block on /dev/random waiting for bytes to be available, use
 select/poll.
 
 Followup discussion to -current.
 
 -Nate
 

From: gson@nominum.com (Andreas Gustafsson)
To: Nate Lawson <nate@root.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/38527: /dev/random does not obey O_NONBLOCK flag
Date: Fri, 28 Jun 2002 11:02:45 -0700 (PDT)

 Nate Lawson writes:
 > This behavior is intentional and was changed some time ago.  If you want
 > to block on /dev/random waiting for bytes to be available, use
 > select/poll.
 
 You've got to be kidding.  Why would you intentionally implement a
 behaviour that is
 
  a) gratuitously different from every other implementation of
     /dev/random
 
  b) gratuitously different from every other character 
     device in the history of Unix by being nonblocking
     by default,
 
  c) not even correctly nonblocking, because when no data
     is available, read() on a nonblocking device is supposed
     to return -1 with errno=EWOULDBLOCK, but in the case
     of /dev/random, read() returns 0,
 
 and
 
  d) undocumented?
 
 -- 
 Andreas Gustafsson, gson@nominum.com
State-Changed-From-To: open->suspended 
State-Changed-By: njl 
State-Changed-When: Fri Aug 16 01:48:00 PDT 2002 
State-Changed-Why:  
Suspended since we've reached an impasse.  I tend to agree with the 
submitter but consensus is that non-blocking behavior is needed for user 
apps.  Submitter is encouraged to start a discussion on freebsd-hackers if 
he wishes to make a case for the original behavior. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38527 

From: Bob Van Zant <bob@norcalttora.com>
To: freebsd-gnats-submit@FreeBSD.org, gson@nominum.com
Cc:  
Subject: Re: kern/38527: /dev/random does not obey O_NONBLOCK flag
Date: Sun, 17 Oct 2004 11:26:08 -0700

 This bug appears to have been fixed. Or, at a minimum, the repro steps
 fail to reproduce the problem on 5.3-beta5.
 
 A brief code inspection of randomdev.c shows that the read function now
 has logic to handle blocking. It even appears that it will return
 EWOULDBLOCK if you have opened with the non-blocking option and no data
 is available.
 
 Someone else might want to take a brief look at this, verify it and
 close it.
 
 -Bob
 
State-Changed-From-To: suspended->closed 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 06:54:49 UTC 2007 
State-Changed-Why:  

Yarrow returns EWOULDBLOCK and nehemiah appears to not have a need 
for blocking. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38527 
>Unformatted:
