Re: Problem with __check_and_rekey
From: David S. Miller <hidden>
Date: 2003-08-12 13:53:46
On Tue, 12 Aug 2003 22:55:27 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@ [off-list ref] wrote:
quoted
+ local_bh_disable(); tp->write_seq = secure_tcp_sequence_number(sk->saddr, sk->daddr, sk->sport, usin->sin_port); + local_bh_enable();You must forgot braces. But anyway, I can't find these lines in linux-2.4.21 (or even in 2.6.x). Are you sure you're working on the vanilla kernel?
It doesn't matter, a proper fix was put into drivers/char/random.c already. # This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1019.3.9 -> 1.1019.3.10 # drivers/char/random.c 1.17 -> 1.18 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/07/28 olof@austin.ibm.com 1.1019.3.10 # [RANDOM]: Fix SMP deadlock in __check_and_rekey(). # -------------------------------------------- # diff -Nru a/drivers/char/random.c b/drivers/char/random.c
--- a/drivers/char/random.c Tue Aug 12 06:56:52 2003
+++ b/drivers/char/random.c Tue Aug 12 06:56:52 2003@@ -251,6 +251,8 @@ #include <linux/random.h> #include <linux/poll.h> #include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/spinlock.h> #include <asm/processor.h> #include <asm/uaccess.h>
@@ -2069,7 +2071,7 @@ static struct keydata *__check_and_rekey(time_t time) { struct keydata *keyptr; - spin_lock(&ip_lock); + spin_lock_bh(&ip_lock); keyptr = &ip_keydata[ip_cnt&1]; if (!keyptr->rekey_time || (time - keyptr->rekey_time) > REKEY_INTERVAL) { keyptr = &ip_keydata[1^(ip_cnt&1)];
@@ -2079,7 +2081,7 @@ mb(); ip_cnt++; } - spin_unlock(&ip_lock); + spin_unlock_bh(&ip_lock); return keyptr; }