Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755314AbbBMVA5 (ORCPT ); Fri, 13 Feb 2015 16:00:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41560 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753135AbbBMUta (ORCPT ); Fri, 13 Feb 2015 15:49:30 -0500 Date: Fri, 13 Feb 2015 14:49:24 -0600 From: Josh Poimboeuf To: Miroslav Benes Cc: Jiri Slaby , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Masami Hiramatsu , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed Message-ID: <20150213204924.GH27180@treble.redhat.com> References: <5a1f98566264a40895704d553e9acf8cfda0659c.1423499826.git.jpoimboe@redhat.com> <54DA55CA.3080408@suse.cz> <20150213160441.GG27180@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1820 Lines: 46 On Fri, Feb 13, 2015 at 05:17:10PM +0100, Miroslav Benes wrote: > On Fri, 13 Feb 2015, Josh Poimboeuf wrote: > > Hm, even with Jiri Slaby's suggested fix to add the completion to the > > unregister path, I still get a lockdep warning. This looks more insidious, > > related to the locking order of a kernfs lock and the klp lock. I'll need to > > look at this some more... > > Yes, I was afraid of this. Lockdep warning is a separate bug. It is caused > by taking klp_mutex in enabled_store. During rmmod klp_unregister_patch > takes klp_mutex and destroys the sysfs structure. If somebody writes to > enabled just after unregister takes the mutex and before the sysfs > removal, he would cause the deadlock, because enabled_store takes the > "sysfs lock" and then klp_mutex. That is exactly what the lockdep tells us > below. > > We can look for inspiration elsewhere. Grep for s_active through git log > of the mainline offers several commits which dealt exactly with this. Will > browse through that... Thanks Miroslav, please let me know what you find. It wouldn't surprise me if this were a very common problem. One option would be to move the enabled_store() work out to a workqueue or something. > > > > To recreate: > > > > insmod livepatch-sample.ko > > > > # wait for patching to complete > > > > ~/a.out & <-- simple program which opens the "enabled" file in the background > > I didn't even need such a program. Lockdep warned me with sole insmod, > echo and rmmod. It is magically clever. Ah, even easier... lockdep is awesome. -- Josh -- 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/