remarkable-linux/drivers
Andrew Morton 8b76f46a2d drivers/char/random.c: fix a race which can lead to a bogus BUG()
Fix a bug reported by and diagnosed by Aaron Straus.

This is a regression intruduced into 2.6.26 by

    commit adc782dae6
    Author: Matt Mackall <mpm@selenic.com>
    Date:   Tue Apr 29 01:03:07 2008 -0700

        random: simplify and rename credit_entropy_store

credit_entropy_bits() does:

	spin_lock_irqsave(&r->lock, flags);
	...
	if (r->entropy_count > r->poolinfo->POOLBITS)
		r->entropy_count = r->poolinfo->POOLBITS;

so there is a time window in which this BUG_ON():

static size_t account(struct entropy_store *r, size_t nbytes, int min,
		      int reserved)
{
	unsigned long flags;

	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);

	/* Hold lock while accounting */
	spin_lock_irqsave(&r->lock, flags);

can trigger.

We could fix this by moving the assertion inside the lock, but it seems
safer and saner to revert to the old behaviour wherein
entropy_store.entropy_count at no time exceeds
entropy_store.poolinfo->POOLBITS.

Reported-by: Aaron Straus <aaron@merfinllc.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: <stable@kernel.org>		[2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-09-02 19:21:40 -07:00
..
accessibility
acpi ACPI: Fix typo in "Disable MWAIT via DMI on broken Compal board" 2008-09-02 11:00:23 -07:00
amba
ata [libata] pata_it821x: fix warning 2008-08-22 02:33:23 -04:00
atm removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
auxdisplay
base PM: Remove WARN_ON from device_pm_add 2008-08-21 10:15:37 -07:00
block Revert "pktcdvd: push BKL down into driver" 2008-08-27 13:42:00 -07:00
bluetooth
cdrom cdrom: handle TOC 2008-08-18 21:40:04 +02:00
char drivers/char/random.c: fix a race which can lead to a bogus BUG() 2008-09-02 19:21:40 -07:00
clocksource
connector
cpufreq
cpuidle
crypto
dca
dio
dma
edac removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
eisa
firewire firewire: Kconfig help update 2008-08-19 18:47:56 +02:00
firmware ibft: fix target info parsing in ibft module 2008-09-02 19:21:40 -07:00
gpio
gpu drm/radeon: downgrade debug message from info to debug. 2008-09-01 08:51:52 +10:00
hid
hwmon
i2c i2c: Prevent log spam on some DVB adapters 2008-08-28 08:33:23 +02:00
ide Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6 2008-09-02 11:44:11 -07:00
ieee1394 ieee1394: sbp2: let nodemgr retry node updates during bus reset series 2008-08-19 18:47:56 +02:00
infiniband IB/mlx4: Actually return L_Key and R_Key for fast register MRs 2008-08-27 14:40:38 -07:00
input Blackfin arch: move include/asm-blackfin header files to arch/blackfin 2008-08-27 10:51:02 +08:00
isdn
leds
lguest lguest: update commentry 2008-08-26 00:19:28 +10:00
macintosh
mca
md Fix problem with waiting while holding rcu read lock in md/bitmap.c 2008-09-01 12:48:13 +10:00
media dabusb_fpga_download(): fix a memory leak 2008-09-02 09:29:03 +01:00
memstick
message
mfd removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
misc hp-wmi: add proper hotkey support 2008-09-02 19:21:39 -07:00
mmc mmc: at91_mci: don't use coherent dma buffers 2008-09-02 19:21:38 -07:00
mtd [MTD] mtdchar.c: Fix regression in MEMGETREGIONINFO ioctl() 2008-09-02 09:29:05 +01:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-08-27 17:38:07 -07:00
nubus
of powerpc/ibmebus: Restore "name" sysfs attribute on ibmebus devices 2008-08-20 09:50:21 +10:00
oprofile powerpc/cell/oprofile: Avoid double vfree of profile buffer 2008-08-26 10:24:46 +10:00
parisc
parport
pci PCI: fix reference leak in pci_get_dev_by_id() 2008-08-21 15:22:46 -07:00
pcmcia
pnp
power
ps3
rapidio
regulator
rtc rtc-cmos: wake again from S5 2008-09-02 19:21:40 -07:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-08-27 17:38:07 -07:00
sbus
scsi remove blk_register_filter and blk_unregister_filter in gendisk 2008-08-29 11:47:07 +02:00
serial 8250: improve workaround for UARTs that don't re-assert THRE correctly 2008-09-02 19:21:38 -07:00
sh
sn
spi
ssb
tc
telephony
thermal
uio UIO: generic irq handling for some uio platform devices 2008-08-21 10:15:39 -07:00
usb removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
video tdfxfb: fix frame buffer name overrun 2008-09-02 19:21:39 -07:00
virtio virtio_balloon: fix towards_target when deflating balloon 2008-08-26 00:19:25 +10:00
w1
watchdog [WATCHDOG] removed unused #include <version.h> 2008-08-26 20:32:02 +00:00
xen stop_machine: wean Xen off stop_machine_run 2008-08-26 00:19:27 +10:00
zorro
Kconfig
Makefile