linux/drivers/char
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
..
agp agp: fix SIS 5591/5592 wrong PCI id 2008-08-12 10:13:38 +10:00
hw_random crypto: padlock - fix VIA PadLock instruction usage with irq_ts_save/restore() 2008-08-13 22:02:26 +10:00
ip2 ip2: push BKL down for the firmware interface 2008-07-25 10:53:43 -07:00
ipmi drivers/char/ipmi/ipmi_si_intf.c:default_find_bmc(): fix leak 2008-08-20 15:40:31 -07:00
mwave mwave: ioctl BKL pushdown 2008-07-25 10:53:43 -07:00
pcmcia removed unused #include <version.h> 2008-08-16 17:21:58 -07:00
rio rio: push down the BKL into the firmware ioctl handler 2008-07-25 10:53:43 -07:00
tpm tpm: Use correct data types for sizes in tpm_write() and tpm_read() 2008-07-26 12:00:04 -07:00
xilinx_hwicap removed unused #include <linux/version.h>'s 2008-08-23 12:14:12 -07:00
.gitignore
ChangeLog
Kconfig powerpc/iseries: remove the old viocons driver 2008-08-07 18:07:10 -07:00
Makefile powerpc/iseries: remove the old viocons driver 2008-08-07 18:07:10 -07:00
amiserial.c m68k/amiserial: fix fallout of tty break handling rework 2008-08-06 13:24:41 -07:00
apm-emulation.c
applicom.c
applicom.h
bfin-otp.c
briq_panel.c
bsr.c
cd1865.h
consolemap.c
cp437.uni
cs5535_gpio.c
cyclades.c
defkeymap.c_shipped
defkeymap.map
digi1.h
digiFep1.h
digiPCI.h
ds1286.c
ds1302.c ds1302: push down the BKL into the driver ioctl code 2008-07-25 10:53:43 -07:00
ds1620.c [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
dsp56k.c dsp56k: Fix BKL pushdown 2008-07-26 13:22:56 -07:00
dtlk.c
efirtc.c drivers/char/efirtc.c: removed duplicated #include 2008-08-04 16:59:56 -07:00
epca.c
epca.h
epcaconfig.h
esp.c
generic_nvram.c
generic_serial.c
genrtc.c
hangcheck-timer.c
hpet.c #if 0 hpet_unregister() 2008-07-25 10:53:43 -07:00
hvc_beat.c
hvc_console.c fix spinlock recursion in hvc_console 2008-08-12 17:52:55 +10:00
hvc_console.h powerpc: Move include files to arch/powerpc/include/asm 2008-08-04 12:02:00 +10:00
hvc_irq.c hvc_console: rework setup to replace irq functions with callbacks 2008-07-25 12:06:06 +10:00
hvc_iseries.c hvc_console: rework setup to replace irq functions with callbacks 2008-07-25 12:06:06 +10:00
hvc_rtas.c
hvc_vio.c hvc_console: rework setup to replace irq functions with callbacks 2008-07-25 12:06:06 +10:00
hvc_xen.c hvc_console: rework setup to replace irq functions with callbacks 2008-07-25 12:06:06 +10:00
hvcs.c powerpc: Move include files to arch/powerpc/include/asm 2008-08-04 12:02:00 +10:00
hvsi.c
i8k.c
ip27-rtc.c
isicom.c
istallion.c
keyboard.c
lp.c
mbcs.c
mbcs.h
mem.c
misc.c
mmtimer.c
moxa.c
moxa.h
mspec.c
mxser.c Char: mxser, ratelimit ioctl warning 2008-07-30 09:41:45 -07:00
mxser.h
n_hdlc.c
n_r3964.c
n_tty.c
nozomi.c
nsc_gpio.c
nvram.c
nwbutton.c
nwbutton.h
nwflash.c [ARM] fix nwflash.c: 6ee8928d94 2008-07-26 16:29:24 +01:00
pc8736x_gpio.c
ppdev.c ppdev: wrap ioctl handler in driver and push lock down 2008-07-25 10:53:43 -07:00
ps3flash.c
pty.c
random.c drivers/char/random.c: fix a race which can lead to a bogus BUG() 2008-09-02 19:21:40 -07:00
raw.c
riscom8.c
riscom8.h
riscom8_reg.h
rocket.c
rocket.h
rocket_int.h
rtc.c drivers/char/rtc.c: removed duplicated include 2008-08-12 16:07:30 -07:00
scc.h
scx200_gpio.c
selection.c
ser_a2232.c m68k: gs: use tty_port fixes 2008-07-26 20:29:03 -07:00
ser_a2232.h
ser_a2232fw.ax
ser_a2232fw.h
serial167.c
snsc.c
snsc.h
snsc_event.c
sonypi.c
specialix.c
specialix_io8.h
stallion.c
sx.c sx: push BKL down into the firmware ioctl handler 2008-07-25 10:53:43 -07:00
sx.h
sxboards.h
sxwindow.h
synclink.c Merge branch 'for-jeff' of git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6 into tmp 2008-08-07 04:05:46 -04:00
synclink_gt.c removed unused #include <version.h> 2008-08-16 17:21:58 -07:00
synclinkmp.c Merge branch 'for-jeff' of git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6 into tmp 2008-08-07 04:05:46 -04:00
sysrq.c
tb0219.c
tlclk.c
toshiba.c
tty_audit.c
tty_io.c tty: Fix termios tty window resize race with pty/tty pair 2008-08-27 14:37:09 -07:00
tty_ioctl.c tty: TIOCGSOFTCAR/SSOFTCAR on pty is wron 2008-08-27 14:37:09 -07:00
tty_ldisc.c try harder to load tty ldisc driver 2008-08-01 12:50:15 -07:00
vc_screen.c
viotape.c
virtio_console.c virtio_console: use virtqueue notification for hvc_console 2008-07-25 12:06:06 +10:00
vme_scc.c m68k: gs: use tty_port fixes 2008-07-26 20:29:03 -07:00
vr41xx_giu.c
vt.c tty: remove resize window special case 2008-08-15 10:34:07 -07:00
vt_ioctl.c tty: remove resize window special case 2008-08-15 10:34:07 -07:00