[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1405456150.25863.16.camel@localhost>
Date: Tue, 15 Jul 2014 22:29:10 +0200
From: Hannes Frederic Sowa <hannes@...essinduktion.org>
To: Dave Jones <davej@...hat.com>
Cc: Linux Kernel <linux-kernel@...r.kernel.org>,
Theodore Ts'o <tytso@....edu>,
Peter Zijlstra <peterz@...radead.org>,
"H. Peter Anvin" <hpa@...ux.intel.com>,
Sasha Levin <sasha.levin@...cle.com>,
Ingo Molnar <mingo@...nel.org>, acme@...stprotocols.net,
Thomas Gleixner <tglx@...utronix.de>, price@....edu
Subject: Re: BUG_ON drivers/char/random.c:986
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@....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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists