2002-12-04 01:45:42

by Mike Phillips

[permalink] [raw]
Subject: [PATCH]tr.c lockup when accessing /proc/net/tr_rif under heavy load

All,

Here's a small patch that fixes a lock and potential oops when accessing
/proc/net/tr_rif is the token ring interface is under heavy load.

The patch also applies to 2.5.50 with a couple of lines offset.

Mike Phillips


diff -urN -x /home/phillim/dev/dontdiff linux-2.4.20.vanilla/net/802/tr.c linux-2.4.20/net/802/tr.c
--- linux-2.4.20.vanilla/net/802/tr.c 2002-08-02 20:39:46.000000000 -0400
+++ linux-2.4.20/net/802/tr.c 2002-12-03 20:28:35.000000000 -0500
@@ -468,6 +468,7 @@
off_t pos=0;
int size,i,j,rcf_len,segment,brdgnmb;
unsigned long now=jiffies;
+ unsigned long flags;

rif_cache entry;

@@ -476,7 +477,7 @@
pos+=size;
len+=size;

- spin_lock_bh(&rif_lock);
+ spin_lock_irqsave(&rif_lock,flags);
for(i=0;i < RIF_TABLE_SIZE;i++)
{
for(entry=rif_table[i];entry;entry=entry->next) {
@@ -525,7 +526,7 @@
if(pos>offset+length)
break;
}
- spin_unlock_bh(&rif_lock);
+ spin_unlock_irqrestore(&rif_lock,flags);

*start=buffer+(offset-begin); /* Start of wanted data */
len-=(offset-begin); /* Start slop */