Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754474AbbLAPxl (ORCPT ); Tue, 1 Dec 2015 10:53:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34884 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751324AbbLAPxj (ORCPT ); Tue, 1 Dec 2015 10:53:39 -0500 Date: Tue, 1 Dec 2015 09:53:37 -0600 From: Josh Poimboeuf To: Jiri Slaby Cc: Li Bin , sjenning@redhat.com, jikos@kernel.org, vojtech@suse.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, guohanjun@huawei.com, dingtianhong@huawei.com, xiexiuqi@huawei.com, zhouchengming1@huawei.com, Miroslav Benes Subject: Re: [PATCH] livepatch: fix race between enabled_store() and klp_unregister_patch() Message-ID: <20151201155337.GD12513@treble.redhat.com> References: <1448855677-8392-1-git-send-email-huawei.libin@huawei.com> <20151201011139.GB12513@treble.redhat.com> <565D5F4F.8020807@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <565D5F4F.8020807@suse.cz> 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: 1395 Lines: 32 On Tue, Dec 01, 2015 at 09:50:23AM +0100, Jiri Slaby wrote: > On 12/01/2015, 02:11 AM, Josh Poimboeuf wrote: > > When I try to recreate something similar by putting a delay in > > enabled_store(), klp_free_patch() just sleeps on its call to > > kobject_put() until enabled_store() returns. The unregister stack looks > > like: > > > > [] __kernfs_remove+0x1fb/0x380 > > [] kernfs_remove+0x23/0x40 > > [] sysfs_remove_dir+0x51/0x80 > > [] kobject_del+0x18/0x50 > > [] kobject_release+0x5a/0x190 > > [] kobject_put+0x27/0x50 > > What about _put outside of klp_mutex in klp_unregister_patch (and maybe > the other _put's as well)? Plus Li Bin's patch. This approach sounds the best to me. I think all _put's for the patch kobj need to be outside the mutex. There's also a _put for the patch kobj in the klp_init_patch() error path which needs to be moved out. I think the rest of the _put's (for object and func kobjs) are fine as they are, because they don't have corresponding sysfs functions which get the mutex. -- 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/