From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751092AbdBCQs4 (ORCPT ); Fri, 3 Feb 2017 11:48:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:47132 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750808AbdBCQsz (ORCPT ); Fri, 3 Feb 2017 11:48:55 -0500 Date: Fri, 3 Feb 2017 17:48:52 +0100 (CET) From: Miroslav Benes To: Josh Poimboeuf cc: Jessica Yu , Jiri Kosina , Petr Mladek , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michael Ellerman , Heiko Carstens , x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Vojtech Pavlik , Jiri Slaby , Chris J Arges , Andy Lutomirski , Ingo Molnar , Peter Zijlstra , Kamalesh Babulal , Balbir Singh Subject: Re: [PATCH v4 15/15] livepatch: allow removal of a disabled patch In-Reply-To: <7b540d5a66243628eae1925e8871dc9678305973.1484839971.git.jpoimboe@redhat.com> Message-ID: References: <7b540d5a66243628eae1925e8871dc9678305973.1484839971.git.jpoimboe@redhat.com> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Jan 2017, Josh Poimboeuf wrote: > From: Miroslav Benes > > Currently we do not allow patch module to unload since there is no > method to determine if a task is still running in the patched code. > > The consistency model gives us the way because when the unpatching > finishes we know that all tasks were marked as safe to call an original > function. Thus every new call to the function calls the original code > and at the same time no task can be somewhere in the patched code, > because it had to leave that code to be marked as safe. > > We can safely let the patch module go after that. > > Completion is used for synchronization between module removal and sysfs > infrastructure in a similar way to commit 942e443127e9 ("module: Fix > mod->mkobj.kobj potentially freed too early"). > > Note that we still do not allow the removal for immediate model, that is > no consistency model. The module refcount may increase in this case if > somebody disables and enables the patch several times. This should not > cause any harm. > > With this change a call to try_module_get() is moved to > __klp_enable_patch from klp_register_patch to make module reference > counting symmetric (module_put() is in a patch disable path) and to > allow to take a new reference to a disabled module when being enabled. > > Finally, we need to be very careful about possible races between > klp_unregister_patch(), kobject_put() functions and operations > on the related sysfs files. > > kobject_put(&patch->kobj) must be called without klp_mutex. Otherwise, > it might be blocked by enabled_store() that needs the mutex as well. > In addition, enabled_store() must check if the patch was not > unregisted in the meantime. > > There is no need to do the same for other kobject_put() callsites > at the moment. Their sysfs operations neiter take the lock nor s/neiter/neither/ Thanks, Miroslav