Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Thu, 5 Dec 2002 16:30:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Thu, 5 Dec 2002 16:27:57 -0500 Received: from ares.cs.Virginia.EDU ([128.143.137.19]:27614 "EHLO ares.cs.Virginia.EDU") by vger.kernel.org with ESMTP id ; Thu, 5 Dec 2002 16:27:47 -0500 Date: Thu, 5 Dec 2002 16:36:09 -0500 (EST) From: Ronghua Zhang To: kernelnewbies@nl.linux.org cc: netdev@oss.sgi.com, , Subject: synchronization between net_bh and user-context Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1378 Lines: 35 I am reading the TCP/IP code of kernel 2.2.15 and doing some development based on it(yes, I know it's an old version, but I have to). I got a little confused about the synchronization between net_bh and user-context, and hope someone can help me out. Specifically, why the following is impossible? destroy_sock is called on CPU1, and a little bit later net_bh() is executed on CPU2, which will grab the pointer to the socket just before it's destroyed, and its later access becomes invalid. CPU 1 CPU2 destroy_sock() lock_sock() sk->sock_readers++ synchronize_bh(), no bh is running now net_bh() get called =>tcp_v4_rcv() sk = __tcp_v4_lookup(...) sk has not been destroyed tcp_v4_destroy_sock() kill_sk_now() free sk now sk has been destroyed if (!atomic_read(&sk->sock_readers)) <-- sk become invalid ronghua - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/