Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753030AbaAGTTj (ORCPT ); Tue, 7 Jan 2014 14:19:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41170 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbaAGTTb (ORCPT ); Tue, 7 Jan 2014 14:19:31 -0500 Date: Tue, 7 Jan 2014 14:19:10 -0500 From: Mike Snitzer To: Mikulas Patocka Cc: Linus Torvalds , Greg Kroah-Hartman , Bart Van Assche , Jeff Mahoney , Linux Kernel Mailing List , device-mapper development , Thomas Gleixner , Paul McKenney , Ingo Molnar Subject: Re: kobject: provide kobject_put_wait to fix module unload race Message-ID: <20140107191910.GA8884@redhat.com> References: <52C98BCC.9040900@acm.org> <20140105182640.GA2522@kroah.com> <20140106213111.GA2536@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 07 2014 at 1:00pm -0500, Mikulas Patocka wrote: > > > On Tue, 7 Jan 2014, Linus Torvalds wrote: > > > This looks completely broken to me. You do a "kobject_put()" and then > > after you've dropped that last use, you wait for the completion of > > something that may already have been free'd. > > > > Wtf? Am I missing something? > > > > Linus > > It is correct. The release method dm_kobject_release doesn't free the > kobject. It just signals the completion and returns. > > This is the sequence of operations: > * call kobject_put > * wait until all users stop using the kobject, when it happens the release > method is called > * the release method signals the completion and returns > * the unload code that waits on the completion continues > * the unload code frees the mapped_device structure that contains the > kobject > > Using kobject this way avoids the module unload race that was mentioned at > the beginning of this thread. I've staged your patch in linux-next for 3.14, see: http://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=af7b1e5c767fc895788c971c8f4686402ac8344f -- 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/