From: Aaron Straus <aaron@merfinllc.com>
To: mpm@selenic.com
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: drivers/char/random.c line 728 BUG
Date: Thu, 28 Aug 2008 15:59:24 -0700 [thread overview]
Message-ID: <20080828225924.GD6432@merfinllc.com> (raw)
In-Reply-To: <20080826225918.GC5452@merfinllc.com>
Hi,
On Aug 26 03:59 PM, Aaron Straus wrote:
> kernel BUG at drivers/char/random.c:728!
OK so that's (outside spinlock):
BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
in credit_entropy_bits we do (inside spinlock):
r->entropy_count += nbits;
if (r->entropy_count < 0) {
DEBUG_ENT("negative entropy/overflow\n");
r->entropy_count = 0;
} else if (r->entropy_count > r->poolinfo->POOLBITS)
r->entropy_count = r->poolinfo->POOLBITS;
I wonder if we got unlucky and did the:
r->entropy_count += nbits
- overflowed the entropy_count THEN
- another thread hits the BUG before this thread reaches
r->entropy_count = r->poolinfo->POOLBITS;
--
I notice before this commit:
commit adc782dae6c4c0f6fb679a48a544cfbcd79ae3dc
Author: Matt Mackall <mpm@selenic.com>
Date: Tue Apr 29 01:03:07 2008 -0700
random: simplify and rename credit_entropy_store
The credit_entropy_store function looks like this:
spin_lock_irqsave(&r->lock, flags);
if (r->entropy_count + nbits < 0) {
DEBUG_ENT("negative entropy/overflow (%d+%d)\n",
r->entropy_count, nbits);
r->entropy_count = 0;
} else if (r->entropy_count + nbits > r->poolinfo->POOLBITS) {
r->entropy_count = r->poolinfo->POOLBITS;
} else {
r->entropy_count += nbits;
if (nbits)
DEBUG_ENT("added %d entropy credits to %s\n",
nbits, r->name);
}
Notice the old version is careful not to overflow r->entropy_count at
any point (even within the spinlock). So perhaps that's why we didn't
hit this BUG() in the past?
Thanks!
=a=
--
===================
Aaron Straus
aaron@merfinllc.com
next prev parent reply other threads:[~2008-08-28 22:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-26 22:59 drivers/char/random.c line 728 BUG Aaron Straus
2008-08-28 22:59 ` Aaron Straus [this message]
2008-08-29 19:48 ` Andrew Morton
2008-08-29 19:54 ` Andrew Morton
2008-08-29 22:31 ` Aaron Straus
2008-08-29 22:42 ` Andrew Morton
2008-09-03 18:18 ` Matt Mackall
2008-09-03 18:28 ` Aaron Straus
2008-09-03 22:12 ` Matt Mackall
2008-09-03 22:32 ` Andrew Morton
2008-09-03 22:51 ` Matt Mackall
2008-09-03 23:12 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080828225924.GD6432@merfinllc.com \
--to=aaron@merfinllc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.