From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757275AbbCEPos (ORCPT ); Thu, 5 Mar 2015 10:44:48 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34816 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbbCEPor (ORCPT ); Thu, 5 Mar 2015 10:44:47 -0500 From: Petr Mladek To: Seth Jennings , Josh Poimboeuf , Jiri Kosina , Rusty Russell Cc: Miroslav Benes , Masami Hiramatsu , mingo@kernel.org, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, Petr Mladek Subject: [PATCH v2 0/2] livepatch/module: Avoid races between modules and live patches Date: Thu, 5 Mar 2015 16:45:12 +0100 Message-Id: <1425570314-23675-1-git-send-email-pmladek@suse.cz> X-Mailer: git-send-email 1.8.5.6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a notifier that handles live patches for coming and going modules. It takes klp_mutex lock to avoid races with coming and going patches. Unfortunately, there are some possible races in the current implementation. The problem is that we do not keep the klp_mutex lock all the time when the module is being added or removed. All the problems should get fixed by the two patches. Some of the problems will be visible only after we add a more complex consistency model and start supporting semantics changes in patched functions. But I would like to fix it already now. We will need it anyway. IMHO, the current solution is more elegant than any temporary hacks. The patchset with consistency model will be complex enough. Let's solve some problems even before. Thanks a lot Josh for pointing out that module_ftrace_init() is called in MODULE_STALE_UNFORMED. It inspired me for the other solution of coming modules. Changes in v2: + split fix for coming and going modules + call klp_module_init() directly instead of using a handler + check if mod is not NULL when checking the module state + use the boolean flag only for going handler Petr Mladek (2): livepatch/module: Apply patch when loaded module is unformed livepatch/module: Correctly handle going modules include/linux/livepatch.h | 10 ++++ include/linux/module.h | 4 ++ kernel/livepatch/core.c | 124 +++++++++++++++++++++++++++++++++++----------- kernel/module.c | 9 ++++ 4 files changed, 119 insertions(+), 28 deletions(-) -- 1.8.5.6