Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932554AbVJZGNw (ORCPT ); Wed, 26 Oct 2005 02:13:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932557AbVJZGNw (ORCPT ); Wed, 26 Oct 2005 02:13:52 -0400 Received: from omx3-ext.sgi.com ([192.48.171.20]:21408 "EHLO omx3.sgi.com") by vger.kernel.org with ESMTP id S932554AbVJZGNv (ORCPT ); Wed, 26 Oct 2005 02:13:51 -0400 X-Mailer: exmh version 2.6.3_20040314 03/14/2004 with nmh-1.1 From: Keith Owens To: Alan Stern cc: Kernel development list Subject: Re: Notifier chains are unsafe In-reply-to: Your message of "Mon, 24 Oct 2005 16:48:58 -0400." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 26 Oct 2005 16:11:46 +1000 Message-ID: <7908.1130307106@kao2.melbourne.sgi.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1235 Lines: 26 On Mon, 24 Oct 2005 16:48:58 -0400 (EDT), Alan Stern wrote: >Has anyone been bothered by the fact that notifier chains are not safe >with regard to registration and unregistration while the chain is in use? >The notifier_chain_register and notifier_chain_unregister routines have >writelock protections, but the corresponding readlock is never taken! > >It shouldn't be hard to make this work safely, even allowing such things >as notifier routines unregistering themselves as they run. The patch >below contains an example implementation, showing one way to do it. > >But doing this correctly requires knowing how notifier chains are used. > > Are they always called in process context, with interrupts enabled? > > Or do some get called in interrupt context? Register and unregister should only be called from contexts that can sleep, although that may not be documented. notifier_call_chain() can be called in any context, it must not take any locks. - 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/