public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
@ 2015-02-20 16:53 ` redi at gcc dot gnu.org
  2015-02-20 16:58 ` redi at gcc dot gnu.org
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-02-20 16:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-20
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
  2015-02-20 16:53 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code redi at gcc dot gnu.org
@ 2015-02-20 16:58 ` redi at gcc dot gnu.org
  2015-09-11 13:30 ` redi at gcc dot gnu.org
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-02-20 16:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We should do the same, [rand.device] says:

Throws: A value of an implementation-defined type derived from exception if a
random number could not be obtained.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
  2015-02-20 16:53 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code redi at gcc dot gnu.org
  2015-02-20 16:58 ` redi at gcc dot gnu.org
@ 2015-09-11 13:30 ` redi at gcc dot gnu.org
  2015-09-11 13:44 ` redi at gcc dot gnu.org
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-11 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2015-09-11 13:30 ` redi at gcc dot gnu.org
@ 2015-09-11 13:44 ` redi at gcc dot gnu.org
  2015-09-11 13:45 ` redi at gcc dot gnu.org
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-11 13:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.3

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2015-09-11 13:44 ` redi at gcc dot gnu.org
@ 2015-09-11 13:45 ` redi at gcc dot gnu.org
  2015-09-14 14:47 ` fweimer at redhat dot com
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-11 13:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Fri Sep 11 13:44:26 2015
New Revision: 227687

URL: https://gcc.gnu.org/viewcvs?rev=227687&root=gcc&view=rev
Log:
Check read() result in std::random_device.

        PR libstdc++/65142
        * src/c++11/random.cc (random_device::_M_getval()): Check read result.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/src/c++11/random.cc


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2015-09-11 13:45 ` redi at gcc dot gnu.org
@ 2015-09-14 14:47 ` fweimer at redhat dot com
  2015-09-14 15:03 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: fweimer at redhat dot com @ 2015-09-14 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #5 from Florian Weimer <fweimer at redhat dot com> ---
The fix is incomplete because short reads can happen in practice for
/dev/random at least.

The usual retry loop is needed.  It is not clear what to do on EINTR.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2015-09-14 14:47 ` fweimer at redhat dot com
@ 2015-09-14 15:03 ` redi at gcc dot gnu.org
  2015-09-15 10:39 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-14 15:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And the check is wrong in the fread() case as it will only ever return 0 or 1.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2015-09-14 15:03 ` redi at gcc dot gnu.org
@ 2015-09-15 10:39 ` rguenth at gcc dot gnu.org
  2015-09-15 11:44 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-09-15 10:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
If the user controls how the random file is opened (non-blocking or blocking)
then the behavior (whether to re-try on EINTR or short reads) should be
controlled by that choice.  Starting to throw on users that don't expect that
would be bad.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2015-09-15 10:39 ` rguenth at gcc dot gnu.org
@ 2015-09-15 11:44 ` redi at gcc dot gnu.org
  2015-09-15 11:50 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 11:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> If the user controls how the random file is opened (non-blocking or blocking)

They don't.

> then the behavior (whether to re-try on EINTR or short reads) should be
> controlled by that choice.  Starting to throw on users that don't expect that
> would be bad.

The function is specified to throw on error by the standard.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2015-09-15 11:44 ` redi at gcc dot gnu.org
@ 2015-09-15 11:50 ` redi at gcc dot gnu.org
  2015-09-15 12:12 ` rguenther at suse dot de
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-15 11:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #8)
> (In reply to Richard Biener from comment #7)
> > If the user controls how the random file is opened (non-blocking or blocking)
> 
> They don't.

To be clear, it's always opened blocking with std::fopen(fname, "rb")

New proposed patch at https://gcc.gnu.org/ml/gcc-patches/2015-09/msg01050.html


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2015-09-15 11:50 ` redi at gcc dot gnu.org
@ 2015-09-15 12:12 ` rguenther at suse dot de
  2015-09-17 15:07 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276) redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: rguenther at suse dot de @ 2015-09-15 12:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 15 Sep 2015, redi at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142
> 
> --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #7)
> > If the user controls how the random file is opened (non-blocking or blocking)
> 
> They don't.
> 
> > then the behavior (whether to re-try on EINTR or short reads) should be
> > controlled by that choice.  Starting to throw on users that don't expect that
> > would be bad.
> 
> The function is specified to throw on error by the standard.

Well, the question is what is an "error" then.  The need to wait
(as you say we open blocking) isn't in my view.  Getting EINTRed
while waiting neither.  Getting a fatal error from the read yes.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2015-09-15 12:12 ` rguenther at suse dot de
@ 2015-09-17 15:07 ` redi at gcc dot gnu.org
  2015-10-02 13:00 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-17 15:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Sep 17 15:06:42 2015
New Revision: 227872

URL: https://gcc.gnu.org/viewcvs?rev=227872&root=gcc&view=rev
Log:
Make std::random_device retry after short reads

        PR libstdc++/65142
        * src/c++11/random.cc (random_device::_M_getval()): Retry after short
        reads.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/src/c++11/random.cc


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2015-09-17 15:07 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276) redi at gcc dot gnu.org
@ 2015-10-02 13:00 ` rguenth at gcc dot gnu.org
  2015-10-02 20:08 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-02 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
Can you please backport if the solution is the final one?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2015-10-02 13:00 ` rguenth at gcc dot gnu.org
@ 2015-10-02 20:08 ` redi at gcc dot gnu.org
  2015-10-02 20:11 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-02 20:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Fri Oct  2 20:08:04 2015
New Revision: 228419

URL: https://gcc.gnu.org/viewcvs?rev=228419&root=gcc&view=rev
Log:
Backport PR libstdc++/65142 fix from mainline

        PR libstdc++/65142
        * src/c++11/random.cc (random_device::_M_getval()): Check read result
        and retry after short reads.

Modified:
    branches/gcc-5-branch/libstdc++-v3/ChangeLog
    branches/gcc-5-branch/libstdc++-v3/src/c++11/random.cc


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2015-10-02 20:08 ` redi at gcc dot gnu.org
@ 2015-10-02 20:11 ` redi at gcc dot gnu.org
  2015-10-02 20:15 ` fw at gcc dot gnu.org
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-02 20:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Do we want this on gcc-4_9-branch too?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (14 preceding siblings ...)
  2015-10-02 20:11 ` redi at gcc dot gnu.org
@ 2015-10-02 20:15 ` fw at gcc dot gnu.org
  2015-10-02 20:52 ` redi at gcc dot gnu.org
  2015-10-02 20:53 ` redi at gcc dot gnu.org
  17 siblings, 0 replies; 18+ messages in thread
From: fw at gcc dot gnu.org @ 2015-10-02 20:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #15 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #14)
> Do we want this on gcc-4_9-branch too?

Yes, I think so.  It's non-invasive, and it's not in templates/inline
functions, so those who use dynamic linking would actually benefit from it.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (15 preceding siblings ...)
  2015-10-02 20:15 ` fw at gcc dot gnu.org
@ 2015-10-02 20:52 ` redi at gcc dot gnu.org
  2015-10-02 20:53 ` redi at gcc dot gnu.org
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-02 20:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Fri Oct  2 20:51:34 2015
New Revision: 228424

URL: https://gcc.gnu.org/viewcvs?rev=228424&root=gcc&view=rev
Log:
Backport PR libstdc++/65142 fix from mainline

        PR libstdc++/65142
        * src/c++11/random.cc (random_device::_M_getval()): Check read result
        and retry after short reads.

Modified:
    branches/gcc-4_9-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_9-branch/libstdc++-v3/src/c++11/random.cc


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276)
       [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
                   ` (16 preceding siblings ...)
  2015-10-02 20:52 ` redi at gcc dot gnu.org
@ 2015-10-02 20:53 ` redi at gcc dot gnu.org
  17 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-10-02 20:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65142

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|5.3                         |4.9.4

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 4.9.4 and 5.3 then.


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-10-02 20:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-65142-4@http.gcc.gnu.org/bugzilla/>
2015-02-20 16:53 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code redi at gcc dot gnu.org
2015-02-20 16:58 ` redi at gcc dot gnu.org
2015-09-11 13:30 ` redi at gcc dot gnu.org
2015-09-11 13:44 ` redi at gcc dot gnu.org
2015-09-11 13:45 ` redi at gcc dot gnu.org
2015-09-14 14:47 ` fweimer at redhat dot com
2015-09-14 15:03 ` redi at gcc dot gnu.org
2015-09-15 10:39 ` rguenth at gcc dot gnu.org
2015-09-15 11:44 ` redi at gcc dot gnu.org
2015-09-15 11:50 ` redi at gcc dot gnu.org
2015-09-15 12:12 ` rguenther at suse dot de
2015-09-17 15:07 ` [Bug libstdc++/65142] std::random_device Ignores Read Return Code (CVE-2015-5276) redi at gcc dot gnu.org
2015-10-02 13:00 ` rguenth at gcc dot gnu.org
2015-10-02 20:08 ` redi at gcc dot gnu.org
2015-10-02 20:11 ` redi at gcc dot gnu.org
2015-10-02 20:15 ` fw at gcc dot gnu.org
2015-10-02 20:52 ` redi at gcc dot gnu.org
2015-10-02 20:53 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).