In article <[EMAIL PROTECTED]>,
Steve Shah <[EMAIL PROTECTED]> writes:
> Hello,
> When using /proc/net/tcp in the following manner:
> while true
> do
> cat /proc/net/tcp
> sleep 3
> done
> I can regularly get the kernel to hard lock in 2.1.121. (2.1.125
> doesn't show any changes in proc.c related to the function
> that takes care of this). I can see that Alexey commented in
> the code that he also got his machine to hard lock but I cannot
> tell from his context whether it was because of using lock_sock
> or the current version which uses SOCKHASH_LOCK() (which
> translates into a start_bh_atomic()).
This patch should be even better, It fixes another crash bug and tidies up
the comments. Please test.
Index: linux/net/ipv4/proc.c
===================================================================
RCS file: /vger/u4/cvs/linux/net/ipv4/proc.c,v
retrieving revision 1.32
diff -u -r1.32 proc.c
--- proc.c 1998/10/03 09:37:42 1.32
+++ proc.c 1998/10/15 10:39:59
@@ -26,6 +26,7 @@
* Andi Kleen : Add support for open_requests and
* split functions for more readibility.
* Andi Kleen : Add support for /proc/net/netstat
+ * Andi Kleen : Fix open_request printing.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -172,23 +173,13 @@
" sl local_address rem_address st tx_queue "
"rx_queue tr tm->when retrnsmt uid timeout inode");
pos = 128;
-/*
- * This was very pretty but didn't work when a socket is destroyed
- * at the wrong moment (eg a syn recv socket getting a reset), or
- * a memory timer destroy. Instead of playing with timers we just
- * concede defeat and do a start_bh_atomic().
- * Why not just use lock_sock()? As far as I can see all timer routines
- * check for sock_readers before doing anything. -AK
- * [Disabled for now again, because it hard-locked my machine, and there
- * is an theoretical situation then, where an user could prevent
- * sockets from being destroyed by constantly reading /proc/net/tcp.]
- */
SOCKHASH_LOCK();
sp = pro->sklist_next;
while(sp != (struct sock *)pro) {
if (format == 0 && sp->state == TCP_LISTEN) {
struct open_request *req;
+ lock_sock(sp);
for (req = sp->tp_pinfo.af_tcp.syn_wait_queue; req;
i++, req = req->dl_next) {
pos += 128;
@@ -196,9 +187,12 @@
continue;
get__openreq(sp, req, tmpbuf, i);
len += sprintf(buffer+len, "%-127s\n", tmpbuf);
- if(len >= length)
- break;
+ if(len >= length) {
+ release_sock(sp);
+ goto out;
+ }
}
+ release_sock(sp);
}
pos += 128;
@@ -215,6 +209,7 @@
sp = next;
i++;
}
+out:
SOCKHASH_UNLOCK();
begin = len - (pos - offset);
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]