From: Petr Mladek <pmladek@suse.com>
To: Miroslav Benes <mbenes@suse.cz>
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
Date: Mon, 2 Oct 2017 13:05:47 +0200 [thread overview]
Message-ID: <20171002110547.GD8637@pathway.suse.cz> (raw)
In-Reply-To: <alpine.LSU.2.20.1708281655000.7244@pobox.suse.cz>
On Mon 2017-08-28 16:58:40, Miroslav Benes wrote:
> On Wed, 16 Aug 2017, Petr Mladek wrote:
>
> > 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.
>
> Oh, right!
>
> > 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.
>
> Hm, klp_initialized() uses klp_root_kobj because it was a simple way of
> detection. Maybe it is time to introduce proper klp_initialized
> global variable. I'd like it more than setting klp_root_kobj later just
> for the sake of correctness.
>
> What do you think?
The global klp_initialized variable sounds fine to me. The current use
of klp_root_kobj is error prone as we see in this patch.
Best Regards,
Petr
next prev parent reply other threads:[~2017-10-02 11:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 10:48 [PATCH v2 0/3] livepatch: Introduce force sysfs attribute Miroslav Benes
2017-08-10 10:48 ` [PATCH v2 1/3] livepatch: Add " Miroslav Benes
2017-08-11 21:13 ` Josh Poimboeuf
2017-08-14 14:03 ` Miroslav Benes
2017-08-16 13:15 ` Petr Mladek
2017-08-28 14:58 ` Miroslav Benes
2017-10-02 11:05 ` Petr Mladek [this message]
2017-08-10 10:48 ` [PATCH v2 2/3] livepatch: send a fake signal to all blocking tasks Miroslav Benes
2017-08-11 21:30 ` Josh Poimboeuf
2017-08-12 20:03 ` Jiri Kosina
2017-08-14 14:29 ` Miroslav Benes
2017-08-16 14:37 ` Petr Mladek
2017-08-10 10:48 ` [PATCH v2 3/3] livepatch: force transition process to finish Miroslav Benes
2017-08-30 7:24 ` Pavel Machek
2017-08-30 12:48 ` Miroslav Benes
2017-08-30 15:29 ` Josh Poimboeuf
2017-08-11 21:11 ` [PATCH v2 0/3] livepatch: Introduce force sysfs attribute Josh Poimboeuf
2017-08-14 8:49 ` Miroslav Benes
2017-08-16 14:50 ` Petr Mladek
2017-08-16 15:26 ` Josh Poimboeuf
2017-08-30 12:51 ` Miroslav Benes
2017-10-02 11:18 ` Petr Mladek
2017-08-16 13:31 ` Petr Mladek
2017-08-30 12:52 ` Miroslav Benes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171002110547.GD8637@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=jeyu@kernel.org \
--cc=jikos@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=lpechacek@suse.cz \
--cc=mbenes@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox