From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Miroslav Benes <mbenes@suse.cz>
Cc: Jiri Kosina <jikos@kernel.org>, Jessica Yu <jeyu@redhat.com>,
linux-kernel@vger.kernel.org, live-patching@vger.kernel.org,
Vojtech Pavlik <vojtech@suse.com>
Subject: Re: [RFC PATCH v1.9 00/14] livepatch: hybrid consistency model
Date: Mon, 4 Apr 2016 12:03:10 -0500 [thread overview]
Message-ID: <20160404170310.bpbb5uhaz423hd6f@treble.redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1603311434430.23131@pobox.suse.cz>
On Thu, Mar 31, 2016 at 02:54:26PM +0200, Miroslav Benes wrote:
>
> Hi,
>
> this is a great work. I'll have to review it properly (especially 13/14,
> probably several times as it is a heavy stuff), but I've gathered some
> notes so there they are.
>
> On Fri, 25 Mar 2016, Josh Poimboeuf wrote:
>
> > These patches are still a work in progress, but Jiri asked that I share
> > them before I go on vacation next week. Based on origin/master because
> > it has CONFIG_STACK_VALIDATION.
> >
> > This has two consistency models: the immediate model (like in today's
> > code) and the new kpatch/kgraft hybrid model.
> >
> > The default is the hybrid model: kgraft's per-task consistency and
> > syscall barrier switching combined with kpatch's stack trace switching.
> > There are also a number of fallback options which make it pretty
> > flexible, yet the code is still quite simple.
> >
> > Patches are applied on a per-task basis, when the task is deemed safe to
> > switch over. It uses a tiered approach to determine when a task is safe
> > and can be switched.
> >
> > The first wave of attack is stack checking of sleeping tasks. If no
> > affected functions are on the stack of a given task, the task is
> > switched. In most cases this will patch most or all of the tasks on the
> > first try. Otherwise it'll keep trying periodically. This option is
> > only available if the architecture has reliable stacks
> > (CONFIG_RELIABLE_STACKTRACE and CONFIG_STACK_VALIDATION).
>
> I think we could allow periodic checking even for
> !CONFIG_RELIABLE_STACKTRACE situations. The problematic task could migrate
> by itself after some time (meaning it woke up meanwhile and sleeps
> somewhere else now, or it went through a syscall boundary). So we can
> gain something, especially when combined with a fake signal approach. More
> on that below and in my 13/14 mail.
Good idea, agreed.
> > The next line of attack, if needed, is syscall/IRQ switching. A task is
> > switched when it returns from a system call or a user space IRQ. This
> > approach is less than ideal because it usually requires signaling tasks
> > to get them to switch. It also doesn't work for kthreads. But it's
> > still useful in some cases when user tasks get stuck sleeping on an
> > affected function.
> >
> > For architectures which don't have reliable stacks, users have two
> > options:
> >
> > a) use the hybrid fallback option of using only the syscall/IRQ
> > switching (which is the default);
> >
> > b) or they can use the immediate model (which is the model we already
> > have today) by setting the patch->immediate flag.
> >
> > There's also a func->immediate flag which allows users to specify that
> > certain functions in the patch can be applied without per-task
> > consistency. This might be useful if you want to patch a common
> > function like schedule(), and the function change doesn't need
> > consistency but the rest of the patch does.
> >
> > Still have a lot of TODOs, some of them are listed here. If you see
> > something objectionable, it might be a good idea to make sure it's not
> > already on the TODO list :-)
> >
> > TODO:
> > - actually test it
> > - don't use TIP_KLP_NEED_UPDATE in arch-independent code
> > - figure out new API to keep the use of task_rq_lock() in the sched code
>
> Hm, no idea how to do it so that everyone is satisfied. I still remember
> Peter's protests.
Yeah, I'll loop in Peter and Ingo on v2 so we can get their input.
> > - cleaner way to detect preemption on the stack
> > - allow patch modules to be removed. still needs more discussion and
> > thought. maybe something like Miroslav's patch would be good:
> > https://lkml.kernel.org/r/alpine.LNX.2.00.1512150857510.24899@pobox.suse.cz
>
> Yup, that could be part of the patch set. The second option (to rework
> klp_unregister_patch and move kobject_put out of mutex protected parts) is
> maybe a way to go. The mutex_trylock approach works as well, but it is not
> clean and nice enough I guess. However the patch is there :).
>
> Anyway the module removal should be prohibited when one uses immmediate
> flag set to true. Without consistency model we cannot say if it is safe to
> remove the module. Some process could still be in its code.
Good point.
>
> > - come up with a better name than universe? KLP_STATE_PREV/NEXT?
> > KLP_UNPATCHED/PATCHED? there were some objections to the name in v1.
> > - update documentation for sysfs, proc, livepatch
> > - need atomic accesses or READ_ONCE/WRITE_ONCE anywhere?
> > - ability to force a patch to the goal universe
>
> This could be made by a call to klp_update_task_universe for all tasks,
> couldn't it? We have something similar in kgraft.
Yeah, I think so.
> > - try ftrace handler switching idea from v1 cover letter
> > - split up the patches better
> > - cc all the right people
>
> I'd add a fake signal facility for sleeping non-migrated tasks. This
> would accelerate a migration to a new universe. We have it in kgraft for
> quite some time and it worked out great. See
> lkml.kernel.org/r/1430739625-4658-9-git-send-email-jslaby@suse.cz which
> went with Jiri's kgraft-on-klp patch set. See also Oleg's reply as it is
> important (I changed kgraft implementation according to that).
Ok, I'll look into sending a fake signal to remaining tasks.
--
Josh
next prev parent reply other threads:[~2016-04-04 17:03 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-25 19:34 Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 01/14] x86/asm/head: cleanup initial stack variable Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 02/14] x86/asm/head: use a common function for starting CPUs Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 03/14] x86/asm/head: standardize the bottom of the stack for idle tasks Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 04/14] x86: move _stext marker before head code Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 05/14] sched: horrible way to detect whether a task has been preempted Josh Poimboeuf
2016-04-06 13:06 ` Petr Mladek
2016-04-06 16:33 ` Josh Poimboeuf
2016-04-07 9:47 ` Petr Mladek
2016-04-07 14:34 ` Josh Poimboeuf
2016-04-08 8:07 ` Petr Mladek
2016-04-08 14:34 ` Josh Poimboeuf
2016-04-07 21:15 ` Jessica Yu
2016-04-07 21:37 ` Jiri Kosina
2016-04-07 22:35 ` Josh Poimboeuf
2016-04-07 22:53 ` Jiri Kosina
2016-04-07 23:15 ` Jessica Yu
2016-04-08 7:05 ` Jiri Kosina
2016-04-08 8:03 ` Petr Mladek
2016-04-08 14:31 ` Josh Poimboeuf
2016-04-11 8:38 ` Petr Mladek
2016-03-25 19:34 ` [RFC PATCH v1.9 06/14] x86: add error handling to dump_trace() Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 07/14] x86/stacktrace: add function for detecting reliable stack traces Josh Poimboeuf
2016-03-31 13:03 ` Miroslav Benes
2016-04-04 17:54 ` Josh Poimboeuf
2016-04-11 14:16 ` Jiri Slaby
2016-04-12 15:56 ` Josh Poimboeuf
2016-06-09 8:31 ` Jiri Slaby
2016-06-13 21:58 ` Josh Poimboeuf
2016-12-01 20:28 ` Jiri Slaby
2016-12-01 20:59 ` Josh Poimboeuf
2017-01-17 13:08 ` Jiri Slaby
2016-04-04 15:55 ` Petr Mladek
2016-04-04 17:58 ` Josh Poimboeuf
2016-04-07 11:55 ` Petr Mladek
2016-04-07 14:46 ` Josh Poimboeuf
2016-04-08 8:24 ` Petr Mladek
2016-04-11 3:29 ` Jessica Yu
2016-03-25 19:34 ` [RFC PATCH v1.9 08/14] livepatch: separate enabled and patched states Josh Poimboeuf
2016-04-11 3:31 ` Jessica Yu
2016-04-12 14:44 ` [RFC PATCH v1.9 08/14] " Chris J Arges
2016-04-12 17:16 ` Josh Poimboeuf
2016-04-12 17:35 ` Chris J Arges
2016-04-12 18:25 ` Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 09/14] livepatch: remove unnecessary object loaded check Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 10/14] livepatch: move patching functions into patch.c Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 11/14] livepatch: store function sizes Josh Poimboeuf
2016-03-25 19:34 ` [RFC PATCH v1.9 12/14] livepatch: create per-task consistency model Josh Poimboeuf
2016-03-31 13:12 ` Miroslav Benes
2016-04-04 18:21 ` Josh Poimboeuf
2016-04-04 18:27 ` Vojtech Pavlik
2016-04-04 18:33 ` Josh Poimboeuf
2016-04-05 11:36 ` Vojtech Pavlik
2016-04-05 13:53 ` Josh Poimboeuf
2016-04-05 17:32 ` Minfei Huang
2016-04-05 21:17 ` Josh Poimboeuf
2016-04-14 9:25 ` Miroslav Benes
2016-04-14 16:39 ` Josh Poimboeuf
2016-04-15 9:17 ` Miroslav Benes
2016-03-25 19:35 ` [RFC PATCH v1.9 13/14] livepatch: add /proc/<pid>/patch_status Josh Poimboeuf
2016-03-31 9:33 ` Jiri Slaby
2016-03-31 9:40 ` Jiri Slaby
2016-04-04 16:56 ` Josh Poimboeuf
2016-03-25 19:35 ` [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel Josh Poimboeuf
2016-04-14 8:47 ` Miroslav Benes
2016-04-14 8:50 ` Miroslav Benes
2016-04-14 13:39 ` Josh Poimboeuf
2016-04-18 15:01 ` [RFC PATCH 0/2] s390/klp: s390 support Miroslav Benes
2016-04-18 15:01 ` [RFC PATCH 1/2] s390: livepatch, reorganize TIF bits Miroslav Benes
2016-04-18 15:01 ` [RFC PATCH 2/2] s390/klp: update task universe when exiting kernel Miroslav Benes
2016-04-18 15:17 ` [RFC PATCH 0/2] s390/klp: s390 support Josh Poimboeuf
2016-04-14 13:23 ` [RFC PATCH v1.9 14/14] livepatch: update task universe when exiting kernel Josh Poimboeuf
2016-03-31 12:54 ` [RFC PATCH v1.9 00/14] livepatch: hybrid consistency model Miroslav Benes
2016-04-04 17:03 ` Josh Poimboeuf [this message]
2016-04-05 14:24 ` Miroslav Benes
2016-04-05 14:34 ` Josh Poimboeuf
2016-04-05 14:53 ` Miroslav Benes
2016-04-01 13:34 ` Miroslav Benes
2016-04-01 13:39 ` Petr Mladek
2016-04-01 15:38 ` Petr Mladek
2016-04-05 13:44 ` Josh Poimboeuf
2016-04-06 8:15 ` Petr Mladek
2016-04-28 18:53 ` Josh Poimboeuf
2016-06-09 14:20 ` Petr Mladek
2016-04-07 12:10 ` Petr Mladek
2016-04-07 15:08 ` Josh Poimboeuf
2016-04-07 15:47 ` Jiri Kosina
2016-04-07 18:03 ` Josh Poimboeuf
2016-04-07 18:33 ` Jiri Kosina
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=20160404170310.bpbb5uhaz423hd6f@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=vojtech@suse.com \
/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
all inboxes | Powered by JetHome®