From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756022AbbLAO2Y (ORCPT ); Tue, 1 Dec 2015 09:28:24 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34816 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755216AbbLAO2X (ORCPT ); Tue, 1 Dec 2015 09:28:23 -0500 Subject: Re: [PATCH] livepatch: fix race between enabled_store() and klp_unregister_patch() To: Petr Mladek References: <1448855677-8392-1-git-send-email-huawei.libin@huawei.com> <20151201011139.GB12513@treble.redhat.com> <565D5F4F.8020807@suse.cz> <20151201141323.GB14230@pathway.suse.cz> Cc: Josh Poimboeuf , 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 From: Jiri Slaby Message-ID: <565DAE83.9020205@suse.cz> Date: Tue, 1 Dec 2015 15:28:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151201141323.GB14230@pathway.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/2015, 03:13 PM, Petr Mladek wrote: > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -612,7 +612,19 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, > > patch = container_of(kobj, struct klp_patch, kobj); > > - mutex_lock(&klp_mutex); > + /* > + * Avoid a deadlock with kobject_put(&patch->kobj) that is > + * called under klp_mutex. Bail out when the patch is not > + * longer registered. > + */ > + if (!mutex_trylock(&klp_mutex)) { This introduces false positives. Deleting/enabling/disabling/other_op_under_klp_mutex of an unrelated patch may now cause enabled_store to fail. Hence I don't like this approach at all. thanks, -- js suse labs