From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810AbdHPNPz (ORCPT ); Wed, 16 Aug 2017 09:15:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:48189 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751580AbdHPNPy (ORCPT ); Wed, 16 Aug 2017 09:15:54 -0400 Date: Wed, 16 Aug 2017 15:15:52 +0200 From: Petr Mladek To: Miroslav Benes Cc: jpoimboe@redhat.com, jeyu@kernel.org, jikos@kernel.org, lpechacek@suse.cz, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] livepatch: Add force sysfs attribute Message-ID: <20170816131552.GA601@pathway.suse.cz> References: <20170810104815.14727-1-mbenes@suse.cz> <20170810104815.14727-2-mbenes@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170810104815.14727-2-mbenes@suse.cz> 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 Thu 2017-08-10 12:48:13, Miroslav Benes wrote: > Add read-write force attribute to livepatch sysfs infrastructure. We can > use it later to force couple of events during a live patching process. > Be it a sending of a fake signal or forcing of the tasks' successful > conversion. > > It does not make sense to use the force facility when there is no > transaction running (although there is no harm doing that). Therefore we > limit it only to situations when klp_transition_patch variable is set. > Normally, klp_mutex lock should be acquired, because the variable is > shared. However that would hold the action back unnecessarily because of > waiting for the lock, so we omit the lock here. The resulting race > window is harmless (using force when there is no transaction running). > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > index b9628e43c78f..79022b7eca2c 100644 > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -954,6 +990,13 @@ static int __init klp_init(void) > if (!klp_root_kobj) > return -ENOMEM; > > + ret = sysfs_create_group(klp_root_kobj, &klp_sysfs_group); > + if (ret) { > + pr_err("cannot create livepatch attributes in sysfs\n"); > + kobject_put(klp_root_kobj); We need to set klp_root_kobj = NULL here. Or we need to set the global klp_root_kobj only when the attributes are created. Otherwise, klp_initialized() would return true and registering a patch would push the system out of a safe road. Note that this actually opens a small race window when the livepatching core pretends to be initialized even when the initialization still might fail. It is rather theoretical but it would be nice to avoid it if it can be done an easy way, e.g. by setting klp_root_kobj later. Best Regards, Petr