lkml.org 
[lkml]   [2014]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: BUG_ON drivers/char/random.c:986
From
Date
On Di, 2014-07-15 at 00:36 -0400, Dave Jones wrote:
> On Fri, May 16, 2014 at 10:18:40PM -0400, Theodore Ts'o wrote:
> > On Fri, May 16, 2014 at 05:46:22PM -0700, Hannes Frederic Sowa wrote:
> > > This should do the trick:
> > > dd if=/dev/urandom of=/dev/zero bs=67108707
> > >
> > > I suspect ee1de406ba6eb1 ("random: simplify accounting logic") as the
> > > culprit.
> >
> > Yep, that it's it. Thanks for noticing this so quickly! I'll push
> > the following patch to Linus.
> >
> > - Ted
> >
> > commit 29fb0ca5b3922288fba3f4c975a55032a51df0f0
> > Author: Theodore Ts'o <tytso@mit.edu>
> > Date: Fri May 16 21:40:41 2014 -0400
> >
> > random: fix BUG_ON caused by accounting simplification
>
> I just hit this bug again on 3.16rc5, which has this patch, so
> there's still some corner case that isn't happy..
>
> (old thread is here for reference: https://lkml.org/lkml/2014/5/16/724)

Looks like an overflow introduced by e33ba5fa7afce1a ("random: fix nasty
entropy accounting bug"). Ted, what do you think about the following
fix?

Bye,
Hannes

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0a7ac0a..72511e8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -999,7 +999,9 @@ retry:
}
if (ibytes < min)
ibytes = 0;
- if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0)
+
+ if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0 ||
+ entropy_count > orig)
entropy_count = 0;

if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)



\
 
 \ /
  Last update: 2014-07-15 23:41    [W:0.150 / U:0.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site