17 Jan, 2012

1 commit

  • If there is an architecture-specific random number generator (such as
    RDRAND for Intel architectures), use it to initialize /dev/random's
    entropy stores. Even in the worst case, if RDRAND is something like
    AES(NSA_KEY, counter++), it won't hurt, and it will definitely help
    against any other adversaries.

    Signed-off-by: "Theodore Ts'o"
    Link: http://lkml.kernel.org/r/1324589281-31931-1-git-send-email-tytso@mit.edu
    Signed-off-by: H. Peter Anvin

    Theodore Ts'o
     

30 Dec, 2011

1 commit

  • We still don't use rdrand in /dev/random, which just seems stupid. We
    accept the *cycle*counter* as a random input, but we don't accept
    rdrand? That's just broken.

    Sure, people can do things in user space (write to /dev/random, use
    rdrand in addition to /dev/random themselves etc etc), but that
    *still* seems to be a particularly stupid reason for saying "we
    shouldn't bother to try to do better in /dev/random".

    And even if somebody really doesn't trust rdrand as a source of random
    bytes, it seems singularly stupid to trust the cycle counter *more*.

    So I'd suggest the attached patch. I'm not going to even bother
    arguing that we should add more bits to the entropy estimate, because
    that's not the point - I don't care if /dev/random fills up slowly or
    not, I think it's just stupid to not use the bits we can get from
    rdrand and mix them into the strong randomness pool.

    Link: http://lkml.kernel.org/r/CA%2B55aFwn59N1=m651QAyTy-1gO1noGbK18zwKDwvwqnravA84A@mail.gmail.com
    Acked-by: "David S. Miller"
    Acked-by: "Theodore Ts'o"
    Acked-by: Herbert Xu
    Cc: Matt Mackall
    Cc: Tony Luck
    Cc: Eric Dumazet
    Signed-off-by: H. Peter Anvin

    Linus Torvalds
     

17 Nov, 2011

1 commit

  • If there is an architecture-specific random number generator we use it
    to acquire randomness one "long" at a time. We should put these random
    words into consecutive words in the result buffer - not just overwrite
    the first word again and again.

    Signed-off-by: Tony Luck
    Acked-by: H. Peter Anvin
    Acked-by: Thomas Gleixner
    Signed-off-by: Linus Torvalds

    Luck, Tony
     

28 Oct, 2011

1 commit

  • * 'x86-rdrand-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86, random: Verify RDRAND functionality and allow it to be disabled
    x86, random: Architectural inlines to get random integers with RDRAND
    random: Add support for architectural random hooks

    Fix up trivial conflicts in drivers/char/random.c: the architectural
    random hooks touched "get_random_int()" that was simplified to use MD5
    and not do the keyptr thing any more (see commit 6e5714eaf77d: "net:
    Compute protocol sequence numbers and fragment IDs using MD5").

    Linus Torvalds
     

07 Aug, 2011

1 commit

  • Computers have become a lot faster since we compromised on the
    partial MD4 hash which we use currently for performance reasons.

    MD5 is a much safer choice, and is inline with both RFC1948 and
    other ISS generators (OpenBSD, Solaris, etc.)

    Furthermore, only having 24-bits of the sequence number be truly
    unpredictable is a very serious limitation. So the periodic
    regeneration and 8-bit counter have been removed. We compute and
    use a full 32-bit sequence number.

    For ipv6, DCCP was found to use a 32-bit truncated initial sequence
    number (it needs 43-bits) and that is fixed here as well.

    Reported-by: Dan Kaminsky
    Tested-by: Willy Tarreau
    Signed-off-by: David S. Miller

    David S. Miller
     

01 Aug, 2011

1 commit

  • Add support for architecture-specific hooks into the kernel-directed
    random number generator interfaces. This patchset does not use the
    architecture random number generator interfaces for the
    userspace-directed interfaces (/dev/random and /dev/urandom), thus
    eliminating the need to distinguish between them based on a pool
    pointer.

    Changes in version 3:
    - Moved the hooks from extract_entropy() to get_random_bytes().
    - Changes the hooks to inlines.

    Signed-off-by: H. Peter Anvin
    Cc: Fenghua Yu
    Cc: Matt Mackall
    Cc: Herbert Xu
    Cc: "Theodore Ts'o"

    H. Peter Anvin
     

22 Jul, 2011

1 commit

  • IPv6 fragment identification generation is way beyond what we use for
    IPv4 : It uses a single generator. Its not scalable and allows DOS
    attacks.

    Now inetpeer is IPv6 aware, we can use it to provide a more secure and
    scalable frag ident generator (per destination, instead of system wide)

    This patch :
    1) defines a new secure_ipv6_id() helper
    2) extends inet_getid() to provide 32bit results
    3) extends ipv6_select_ident() with a new dest parameter

    Reported-by: Fernando Gont
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

31 Mar, 2011

1 commit


21 Feb, 2011

1 commit

  • At present, the comment header in random.c makes no mention of
    add_disk_randomness, and instead, suggests that disk activity adds to the
    random pool by way of add_interrupt_randomness, which appears to not have
    been the case since sometime prior to the existence of git, and even prior
    to bitkeeper. Didn't look any further back. At least, as far as I can
    tell, there are no storage drivers setting IRQF_SAMPLE_RANDOM, which is a
    requirement for add_interrupt_randomness to trigger, so the only way for a
    disk to contribute entropy is by way of add_disk_randomness. Update
    comments accordingly, complete with special mention about solid state
    drives being a crappy source of entropy (see e2e1a148bc for reference).

    Signed-off-by: Jarod Wilson
    Acked-by: Matt Mackall
    Signed-off-by: Herbert Xu

    Jarod Wilson
     

17 Dec, 2010

1 commit


15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

31 Jul, 2010

1 commit


20 May, 2010

1 commit


04 Feb, 2010

1 commit


02 Feb, 2010

2 commits

  • The previous changeset left behind an unused inode variable.
    This patch removes it.

    Reported-by: Stephen Rothwell
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • No other driver does anything remotely like this that I know of except
    for the tty drivers, and I can't see any reason for random/urandom to do
    it. In fact, it's a (trivial, harmless) timing information leak. And
    obviously, it generates power- and flash-cycle wasting I/O, especially
    if combined with something like hwrngd. Also, it breaks ubifs's
    expectations.

    Signed-off-by: Matt Mackall
    Signed-off-by: Herbert Xu

    Matt Mackall
     

16 Dec, 2009

1 commit


19 Nov, 2009

1 commit


12 Nov, 2009

1 commit

  • Now that sys_sysctl is a wrapper around /proc/sys all of
    the binary sysctl support elsewhere in the tree is
    dead code.

    Cc: Jens Axboe
    Cc: Corey Minyard
    Cc: Greg Kroah-Hartman
    Cc: Matt Mackall
    Cc: Herbert Xu
    Cc: Neil Brown
    Cc: "James E.J. Bottomley"
    Acked-by: Clemens Ladisch for drivers/char/hpet.c
    Signed-off-by: Eric W. Biederman

    Eric W. Biederman
     

24 Sep, 2009

1 commit

  • It's unused.

    It isn't needed -- read or write flag is already passed and sysctl
    shouldn't care about the rest.

    It _was_ used in two places at arch/frv for some reason.

    Signed-off-by: Alexey Dobriyan
    Cc: David Howells
    Cc: "Eric W. Biederman"
    Cc: Al Viro
    Cc: Ralf Baechle
    Cc: Martin Schwidefsky
    Cc: Ingo Molnar
    Cc: "David S. Miller"
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

18 Jun, 2009

1 commit

  • FIPS-140 requires that all random number generators implement continuous self
    tests in which each extracted block of data is compared against the last block
    for repetition. The ansi_cprng implements such a test, but it would be nice if
    the hw rng's did the same thing. Obviously its not something thats always
    needed, but it seems like it would be a nice feature to have on occasion. I've
    written the below patch which allows individual entropy stores to be flagged as
    desiring a continuous test to be run on them as is extracted. By default this
    option is off, but is enabled in the event that fips mode is selected during
    bootup.

    Signed-off-by: Neil Horman
    Acked-by: Matt Mackall
    Signed-off-by: Herbert Xu

    Neil Horman
     

20 May, 2009

1 commit

  • Martin Knoblauch reports that trying to build 2.6.30-rc6-git3 with
    RHEL4.3 userspace (gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)) causes an
    internal compiler error (ICE):

    drivers/char/random.c: In function `get_random_int':
    drivers/char/random.c:1672: error: unrecognizable insn:
    (insn 202 148 150 0 /scratch/build/linux-2.6.30-rc6-git3/arch/x86/include/asm/tsc.h:23 (set (reg:SI 0 ax [91])
    (subreg:SI (plus:DI (plus:DI (reg:DI 0 ax [88])
    (subreg:DI (reg:SI 6 bp) 0))
    (const_int -4 [0xfffffffffffffffc])) 0)) -1 (nil)
    (nil))
    drivers/char/random.c:1672: internal compiler error: in extract_insn, at recog.c:2083

    and after some debugging it turns out that it's due to the code trying
    to figure out the rough value of the current stack pointer by taking an
    address of an uninitialized variable and casting that to an integer.

    This is clearly a compiler bug, but it's not worth fighting - while the
    current stack kernel pointer might be somewhat hard to predict in user
    space, it's also not generally going to change for a lot of the call
    chains for a particular process.

    So just drop it, and mumble some incoherent curses at the compiler.

    Tested-by: Martin Knoblauch
    Cc: Matt Mackall
    Cc: Ingo Molnar
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

08 May, 2009

1 commit

  • It's a really simple patch that basically just open-codes the current
    "secure_ip_id()" call, but when open-coding it we now use a _static_
    hashing area, so that it gets updated every time.

    And to make sure somebody can't just start from the same original seed of
    all-zeroes, and then do the "half_md4_transform()" over and over until
    they get the same sequence as the kernel has, each iteration also mixes in
    the same old "current->pid + jiffies" we used - so we should now have a
    regular strong pseudo-number generator, but we also have one that doesn't
    have a single seed.

    Note: the "pid + jiffies" is just meant to be a tiny tiny bit of noise. It
    has no real meaning. It could be anything. I just picked the previous
    seed, it's just that now we keep the state in between calls and that will
    feed into the next result, and that should make all the difference.

    I made that hash be a per-cpu data just to avoid cache-line ping-pong:
    having multiple CPU's write to the same data would be fine for randomness,
    and add yet another layer of chaos to it, but since get_random_int() is
    supposed to be a fast interface I did it that way instead. I considered
    using "__raw_get_cpu_var()" to avoid any preemption overhead while still
    getting the hash be _mostly_ ping-pong free, but in the end good taste won
    out.

    Signed-off-by: Ingo Molnar
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

03 Apr, 2009

1 commit


11 Jan, 2009

2 commits

  • Ingo Molnar wrote:
    >
    > tip/kernel/fork.c: In function 'copy_signal':
    > tip/kernel/fork.c:825: warning: unused variable 'ret'
    > tip/drivers/char/random.c: In function 'get_timer_rand_state':
    > tip/drivers/char/random.c:584: error: dereferencing pointer to incomplete type
    > tip/drivers/char/random.c: In function 'set_timer_rand_state':
    > tip/drivers/char/random.c:594: error: dereferencing pointer to incomplete type
    > make[3]: *** [drivers/char/random.o] Error 1

    irq_desc is defined in linux/irq.h, so include it in the genirq case.

    Signed-off-by: Yinghai Lu
    Signed-off-by: Ingo Molnar

    Yinghai Lu
     
  • Impact: clean up sparseirq fallout on random.c

    Ingo suggested to change some ifdef from SPARSE_IRQ to GENERIC_HARDIRQS
    so we could some #ifdef later if all arch support genirq

    Signed-off-by: Yinghai Lu
    Acked-by: Matt Mackall
    Signed-off-by: Ingo Molnar

    Yinghai Lu
     

07 Jan, 2009

1 commit

  • As a non-atomic value, it's only safe to look at entropy_count when the
    pool lock is held, so we move the BUG_ON inside the lock for correctness.

    Also remove the spurious comment. It's ok for entropy_count to
    temporarily exceed POOLBITS so long as it's left in a consistent state
    when the lock is released.

    This is a more correct, simple, and idiomatic fix for the bug in
    8b76f46a2db. I've left the reorderings introduced by that patch in place
    as they're harmless, even though they don't properly deal with potential
    atomicity issues.

    Signed-off-by: Matt Mackall
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matt Mackall
     

04 Jan, 2009

1 commit


08 Dec, 2008

1 commit

  • Impact: new feature

    Problem on distro kernels: irq_desc[NR_IRQS] takes megabytes of RAM with
    NR_CPUS set to large values. The goal is to be able to scale up to much
    larger NR_IRQS value without impacting the (important) common case.

    To solve this, we generalize irq_desc[NR_IRQS] to an (optional) array of
    irq_desc pointers.

    When CONFIG_SPARSE_IRQ=y is used, we use kzalloc_node to get irq_desc,
    this also makes the IRQ descriptors NUMA-local (to the site that calls
    request_irq()).

    This gets rid of the irq_cfg[] static array on x86 as well: irq_cfg now
    uses desc->chip_data for x86 to store irq_cfg.

    Signed-off-by: Yinghai Lu
    Signed-off-by: Ingo Molnar

    Yinghai Lu
     

02 Nov, 2008

1 commit

  • As it is, all instances of ->release() for files that have ->fasync()
    need to remember to evict file from fasync lists; forgetting that
    creates a hole and we actually have a bunch that *does* forget.

    So let's keep our lives simple - let __fput() check FASYNC in
    file->f_flags and call ->fasync() there if it's been set. And lose that
    crap in ->release() instances - leaving it there is still valid, but we
    don't have to bother anymore.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

21 Oct, 2008

1 commit

  • …/git/tip/linux-2.6-tip

    This merges branches irq/genirq, irq/sparseirq-v4, timers/hpet-percpu
    and x86/uv.

    The sparseirq branch is just preliminary groundwork: no sparse IRQs are
    actually implemented by this tree anymore - just the new APIs are added
    while keeping the old way intact as well (the new APIs map 1:1 to
    irq_desc[]). The 'real' sparse IRQ support will then be a relatively
    small patch ontop of this - with a v2.6.29 merge target.

    * 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (178 commits)
    genirq: improve include files
    intr_remapping: fix typo
    io_apic: make irq_mis_count available on 64-bit too
    genirq: fix name space collisions of nr_irqs in arch/*
    genirq: fix name space collision of nr_irqs in autoprobe.c
    genirq: use iterators for irq_desc loops
    proc: fixup irq iterator
    genirq: add reverse iterator for irq_desc
    x86: move ack_bad_irq() to irq.c
    x86: unify show_interrupts() and proc helpers
    x86: cleanup show_interrupts
    genirq: cleanup the sparseirq modifications
    genirq: remove artifacts from sparseirq removal
    genirq: revert dynarray
    genirq: remove irq_to_desc_alloc
    genirq: remove sparse irq code
    genirq: use inline function for irq_to_desc
    genirq: consolidate nr_irqs and for_each_irq_desc()
    x86: remove sparse irq from Kconfig
    genirq: define nr_irqs for architectures with GENERIC_HARDIRQS=n
    ...

    Linus Torvalds
     

17 Oct, 2008

1 commit

  • name and nlen parameters passed to ->strategy hook are unused, remove
    them. In general ->strategy hook should know what it's doing, and don't
    do something tricky for which, say, pointer to original userspace array
    may be needed (name).

    Signed-off-by: Alexey Dobriyan
    Acked-by: David S. Miller [ networking bits ]
    Cc: Ralf Baechle
    Cc: David Howells
    Cc: Matt Mackall
    Cc: "Eric W. Biederman"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

16 Oct, 2008

5 commits


09 Oct, 2008

1 commit

  • * Implement disk_devt() and part_devt() and use them to directly
    access devt instead of computing it from ->major and ->first_minor.

    Note that all references to ->major and ->first_minor outside of
    block layer is used to determine devt of the disk (the part0) and as
    ->major and ->first_minor will continue to represent devt for the
    disk, converting these users aren't strictly necessary. However,
    convert them for consistency.

    * Implement disk_max_parts() to avoid directly deferencing
    genhd->minors.

    * Update bdget_disk() such that it doesn't assume consecutive minor
    space.

    * Move devt computation from register_disk() to add_disk() and make it
    the only one (all other usages use the initially determined value).

    These changes clean up the code and will help disk->part dereference
    fix and extended block device numbers.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     

03 Sep, 2008

1 commit

  • Fix a bug reported by and diagnosed by Aaron Straus.

    This is a regression intruduced into 2.6.26 by

    commit adc782dae6c4c0f6fb679a48a544cfbcd79ae3dc
    Author: Matt Mackall
    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
    Cc: Matt Mackall
    Cc: Theodore Ts'o
    Cc: [2.6.26.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

19 Aug, 2008

1 commit