Re: Stack traces in 2.6.9-rc2-mm4

From: Ingo Molnar
Date: Tue Sep 28 2004 - 02:22:33 EST



* J.A. Magallon <jamagallon@xxxxxxx> wrote:

> I got the same on another place...
>
> Sep 28 00:48:51 werewolf kernel: using smp_processor_id() in preemptible
> code: X/4012
> Sep 28 00:48:51 werewolf kernel: [smp_processor_id+135/141]
> smp_processor_id+0x87/0x8d
> Sep 28 00:48:51 werewolf kernel: [add_timer_randomness+314/365]
> add_timer_randomness+0x13a/0x16d
> Sep 28 00:48:51 werewolf kernel: [<b0206733>]
> add_timer_randomness+0x13a/0x16d
> Sep 28 00:48:51 werewolf kernel: [input_event+85/999]
> input_event+0x55/0x3e7

the one below should fix this: a certain codepath in the random driver
relied on vt_ioctl() being under the BKL and implicitly disabling
preemption. The code wasnt buggy upstream but it's slighly unrobust so i
think we want the fix upstream too, independently of the remove-bkl
patch. This change has been in the -VP patchset for some time so it
should work fine.

Ingo

--- linux/drivers/char/random.c.orig
+++ linux/drivers/char/random.c
@@ -807,10 +807,11 @@ static void add_timer_randomness(struct
long delta, delta2, delta3;
int entropy = 0;

+ preempt_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
if ( random_state->entropy_count > trickle_thresh &&
(__get_cpu_var(trickle_count)++ & 0xfff))
- return;
+ goto out;

/*
* Use get_cycles() if implemented, otherwise fall back to
@@ -861,6 +862,8 @@ static void add_timer_randomness(struct
entropy = int_ln_12bits(delta);
}
batch_entropy_store(num, time, entropy);
+out:
+ preempt_enable();
}

void add_keyboard_randomness(unsigned char scancode)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/