Re: [PATCH 2/2] livepatch: disable/enable_patch manners for interdependent patches

2015-01-22 Thread Josh Poimboeuf
On Thu, Jan 22, 2015 at 05:54:23PM +0800, Li Bin wrote: On 2015/1/22 16:39, Li Bin wrote: On 2015/1/22 11:51, Josh Poimboeuf wrote: On Thu, Jan 22, 2015 at 08:42:29AM +0800, Li Bin wrote: On 2015/1/21 22:08, Jiri Kosina wrote: On Wed, 21 Jan 2015, Li Bin wrote: By this you limit

[PATCH] livepatch: add missing newline to error message

2015-02-06 Thread Josh Poimboeuf
Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 9adf86b..ff7f47d 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -211,7

[PATCH] livepatch: rename config to CONFIG_LIVEPATCH

2015-02-03 Thread Josh Poimboeuf
Rename CONFIG_LIVE_PATCHING to CONFIG_LIVEPATCH to make the naming of the config and the code more consistent. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- arch/x86/Kconfig | 2 +- arch/x86/include/asm/livepatch.h | 4 ++-- arch/x86/kernel/Makefile | 2

Re: [PATCH] livepatch: change ARCH_HAVE_LIVE_PATCHING to HAVE_LIVE_PATCHING

2015-01-20 Thread Josh Poimboeuf
Acked-by: Josh Poimboeuf jpoim...@redhat.com --- arch/x86/Kconfig | 2 +- kernel/livepatch/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 460b31b..29b0952 100644 --- a/arch/x86/Kconfig +++ b/arch/x86

Re: [PATCH] livepatch: support for repatching a function

2015-01-20 Thread Josh Poimboeuf
On Tue, Jan 20, 2015 at 10:56:33AM +0100, Miroslav Benes wrote: On Fri, 9 Jan 2015, Josh Poimboeuf wrote: +struct klp_ops { + struct list_head node; + struct list_head func_stack; + struct ftrace_ops fops; +}; I think it would be useful to add some comments for this structure

[PATCH v2 2/2] livepatch: support for repatching a function

2015-01-20 Thread Josh Poimboeuf
between function versions to happen instantaneously by updating the klp_ops struct's func_stack list. The winner is the klp_func at the top of the func_stack (front of the list). Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- include/linux/livepatch.h | 4 +- kernel/livepatch/core.c

[PATCH v2 0/2] support for stacked patches

2015-01-20 Thread Josh Poimboeuf
Add support for properly stacking patches. This includes enforcing patch stack semantics and allowing functions to be repatched. v2 changes: - add enforce stacking semantics patch - add documentation comments for new klp_ops struct Josh Poimboeuf (2): livepatch: enforce patch stacking

[PATCH v2 1/2] livepatch: enforce patch stacking semantics

2015-01-20 Thread Josh Poimboeuf
Only allow the topmost patch on the stack to be enabled or disabled, so that patches can't be removed or added in an arbitrary order. Suggested-by: Jiri Kosina jkos...@suse.cz Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/core.c | 10 ++ 1 file changed, 10

Re: [PATCH v2 2/2] livepatch: support for repatching a function

2015-01-20 Thread Josh Poimboeuf
On Tue, Jan 20, 2015 at 04:37:59PM +0100, Jiri Slaby wrote: On 01/20/2015, 04:26 PM, Josh Poimboeuf wrote: Add support for patching a function multiple times. If multiple patches affect a function, the function in the most recently enabled patch wins. This enables a cumulative patch

[PATCH] livepatch: fix uninitialized return value

2015-01-20 Thread Josh Poimboeuf
Fix a potentially uninitialized return value. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index bc05d39..9adf86b 100644 --- a/kernel/livepatch

Re: [PATCH 2/2] livepatch: disable/enable_patch manners for interdependent patches

2015-01-21 Thread Josh Poimboeuf
On Thu, Jan 22, 2015 at 08:42:29AM +0800, Li Bin wrote: On 2015/1/21 22:08, Jiri Kosina wrote: On Wed, 21 Jan 2015, Li Bin wrote: By this you limit the definition of the patch inter-dependency to just symbols. But that's not the only way how patches can depend on it other -- the

Re: [PATCH] livepatch: support for repatching a function

2015-01-19 Thread Josh Poimboeuf
On Fri, Jan 16, 2015 at 05:51:11PM +0100, Jiri Kosina wrote: One thing that makes me worried here is we basically apply patches in a 'stackable' manner, but then this allows them to be removed (disabled) in an arbitrary order. Is this really the semantics we want? The scenario I am

Re: [PATCH] livepatch: support for repatching a function

2015-01-19 Thread Josh Poimboeuf
On Mon, Jan 19, 2015 at 08:48:42PM +0100, Jiri Kosina wrote: On Mon, 19 Jan 2015, Josh Poimboeuf wrote: If this is implemented really in a fully stackable manner (i.e. you basically would be able to disable only the function that is currently active, i.e. on top of the stack

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-11 Thread Josh Poimboeuf
On Wed, Feb 11, 2015 at 11:55:05AM +0100, Jiri Slaby wrote: On 02/10/2015, 08:57 PM, Josh Poimboeuf wrote: On Tue, Feb 10, 2015 at 08:02:34PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c

Re: [RFC PATCH 5/9] sched: move task rq locking functions to sched.h

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 07:48:17PM +0900, Masami Hiramatsu wrote: (2015/02/10 2:31), Josh Poimboeuf wrote: Move task_rq_lock/unlock() to sched.h so they can be used elsewhere. The livepatch code needs to lock each task's rq in order to safely examine its stack and switch it to a new patch

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 07:58:30PM +0900, Masami Hiramatsu wrote: (2015/02/10 2:31), Josh Poimboeuf wrote: +/* + * Try to safely transition a task to the universe goal. If the task is + * currently running or is sleeping on a to-be-patched or to-be-unpatched + * function, return false

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 09:57:44AM +0100, Jiri Kosina wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: 2) As mentioned above, kthreads which are always sleeping on a patched function will never transition to the new universe. This is really a minor issue (less than 1% of patches

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 08:16:59PM +0900, Masami Hiramatsu wrote: (2015/02/10 2:31), Josh Poimboeuf wrote: This patch set implements a livepatch consistency model, targeted for 3.21. Now that we have a solid livepatch code base, this is the biggest remaining missing piece. This code

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-11 Thread Josh Poimboeuf
On Wed, Feb 11, 2015 at 05:28:13PM +0100, Miroslav Benes wrote: On Tue, 10 Feb 2015, Josh Poimboeuf wrote: On Tue, Feb 10, 2015 at 04:59:17PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: Add a basic per-task consistency model. This is the foundation

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-11 Thread Josh Poimboeuf
On Wed, Feb 11, 2015 at 11:21:51AM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: [...] @@ -38,14 +39,34 @@ static void notrace klp_ftrace_handler(unsigned long ip, ops = container_of(fops, struct klp_ops, fops); rcu_read_lock(); + func

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 04:59:17PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: Add a basic per-task consistency model. This is the foundation which will eventually enable us to patch those ~10% of security patches which change function prototypes and/or data

Re: [RFC PATCH 2/9] livepatch: separate enabled and patched states

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 05:44:30PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: Once we have a consistency model, patches and their objects will be enabled and disabled at different times. For example, when a patch is disabled, its loaded objects' funcs can

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 09:59:58AM -0600, Josh Poimboeuf wrote: On Tue, Feb 10, 2015 at 08:16:59PM +0900, Masami Hiramatsu wrote: (2015/02/10 2:31), Josh Poimboeuf wrote: This patch set implements a livepatch consistency model, targeted for 3.21. Now that we have a solid livepatch

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-11 Thread Josh Poimboeuf
is examined, to decide whether it can be safely switched to the new patching universe. For more details see klp_transition_task() in the patch below. Using task_rq_lock() is the most straightforward way I could find to achieve that. On Mon, Feb 09, 2015 at 11:31:18AM -0600, Josh Poimboeuf wrote: Add

[PATCH 3/3] proc: fix /proc/pid/stack for running tasks

2015-02-16 Thread Josh Poimboeuf
Reading /proc/pid/stack for a running task can show garbage. Use the new safe version of the stack saving interface. For running tasks (other than current) it won't show anything. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- fs/proc/base.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH 2/3] stacktrace: add save_stack_trace_tsk_safe()

2015-02-16 Thread Josh Poimboeuf
Kosina jkos...@suse.cz Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- include/linux/stacktrace.h | 2 ++ kernel/stacktrace.c| 22 ++ 2 files changed, 24 insertions(+) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index 669045a..898f0fc 100644

[PATCH 1/3] sched: add sched_task_call()

2015-02-16 Thread Josh Poimboeuf
Add a sched_task_call() to allow a callback function to be called with the task's rq locked. It guarantees that a task remains either active or inactive during the function call, without having to expose rq locking details outside of the scheduler. Signed-off-by: Josh Poimboeuf jpoim

[PATCH 0/3] prevent /proc/pid/stack garbage for running tasks

2015-02-16 Thread Josh Poimboeuf
task. The new sched_task_call() function will also be useful for future live patching code which will need to atomically examine a task's stack before patching it. Josh Poimboeuf (3): sched: add sched_task_call() stacktrace: add save_stack_trace_tsk_safe() proc: fix /proc/pid/stack

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-18 Thread Josh Poimboeuf
On Wed, Feb 18, 2015 at 04:21:00PM +0100, Peter Zijlstra wrote: On Tue, Feb 17, 2015 at 03:25:32PM -0600, Josh Poimboeuf wrote: And I'm assuming you're hard relying on CONFIG_FRAMEPOINTER here, because otherwise x86 stacks are a mess too. Yeah, it'll rely on CONFIG_FRAME_POINTER. IIUC

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-17 Thread Josh Poimboeuf
On Tue, Feb 17, 2015 at 04:48:39PM +0100, Miroslav Benes wrote: On Tue, 17 Feb 2015, Josh Poimboeuf wrote: On Mon, Feb 16, 2015 at 03:19:10PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: [...] + +void klp_unpatch_objects(struct klp_patch *patch

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-17 Thread Josh Poimboeuf
On Sat, Feb 14, 2015 at 12:40:01PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: Add a basic per-task consistency model. This is the foundation which will eventually enable us to patch those ~10% of security patches which change function prototypes and/or data

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-17 Thread Josh Poimboeuf
On Mon, Feb 16, 2015 at 05:06:15PM +0100, Miroslav Benes wrote: On Fri, 13 Feb 2015, Josh Poimboeuf wrote: On Fri, Feb 13, 2015 at 05:17:10PM +0100, Miroslav Benes wrote: On Fri, 13 Feb 2015, Josh Poimboeuf wrote: Hm, even with Jiri Slaby's suggested fix to add the completion

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-17 Thread Josh Poimboeuf
On Mon, Feb 16, 2015 at 03:19:10PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: Add a basic per-task consistency model. This is the foundation which will eventually enable us to patch those ~10% of security patches which change function prototypes and/or data

Re: [RFC PATCH 9/9] livepatch: update task universe when exiting kernel

2015-02-17 Thread Josh Poimboeuf
On Mon, Feb 16, 2015 at 11:16:11AM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: Update a tasks's universe when returning from a system call or user space interrupt, or after handling a signal. This greatly increases the chances of a patch operation succeeding

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-17 Thread Josh Poimboeuf
On Tue, Feb 17, 2015 at 10:24:50AM +0100, Peter Zijlstra wrote: On Mon, Feb 16, 2015 at 04:05:05PM -0600, Josh Poimboeuf wrote: Yeah, I can understand that. I definitely want to avoid touching the scheduler code. Basically I'm trying to find a way to atomically do the following

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-16 Thread Josh Poimboeuf
On Mon, Feb 16, 2015 at 09:44:36PM +0100, Peter Zijlstra wrote: On Mon, Feb 16, 2015 at 12:52:34PM -0600, Josh Poimboeuf wrote: +++ b/kernel/sched/core.c @@ -1338,6 +1338,23 @@ void kick_process(struct task_struct *p) EXPORT_SYMBOL_GPL(kick_process); #endif /* CONFIG_SMP

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-17 Thread Josh Poimboeuf
On Tue, Feb 17, 2015 at 07:15:41PM +0100, Peter Zijlstra wrote: On Tue, Feb 17, 2015 at 08:12:11AM -0600, Josh Poimboeuf wrote: On Tue, Feb 17, 2015 at 10:24:50AM +0100, Peter Zijlstra wrote: So far stack unwinding has basically been a best effort debug output kind of thing, you're

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-18 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 01:20:58AM +0100, Peter Zijlstra wrote: On Wed, Feb 18, 2015 at 11:12:56AM -0600, Josh Poimboeuf wrote: So uhm, what happens if your target task is running? When will you retry? The problem I see is that if you do a sample approach you might never hit an opportune

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-19 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 09:40:36PM +0100, Vojtech Pavlik wrote: On Thu, Feb 19, 2015 at 11:32:55AM -0600, Josh Poimboeuf wrote: On Thu, Feb 19, 2015 at 06:19:29PM +0100, Vojtech Pavlik wrote: On Thu, Feb 19, 2015 at 11:03:53AM -0600, Josh Poimboeuf wrote: On Thu, Feb 19, 2015 at 05:33

Re: [PATCH] livepatch: remove extern specifier from header files

2015-02-18 Thread Josh Poimboeuf
Acked-by: Josh Poimboeuf jpoim...@redhat.com --- arch/x86/include/asm/livepatch.h | 4 ++-- include/linux/livepatch.h| 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/livepatch.h b/arch/x86/include/asm/livepatch.h index a455a53

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-18 Thread Josh Poimboeuf
On Wed, Feb 18, 2015 at 01:42:56PM +0100, Miroslav Benes wrote: On Tue, 17 Feb 2015, Josh Poimboeuf wrote: On Tue, Feb 17, 2015 at 04:48:39PM +0100, Miroslav Benes wrote: On Tue, 17 Feb 2015, Josh Poimboeuf wrote: On Mon, Feb 16, 2015 at 03:19:10PM +0100, Miroslav Benes wrote

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-19 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 11:16:07AM +0100, Peter Zijlstra wrote: On Wed, Feb 18, 2015 at 10:17:53PM -0600, Josh Poimboeuf wrote: On Thu, Feb 19, 2015 at 01:20:58AM +0100, Peter Zijlstra wrote: On Wed, Feb 18, 2015 at 11:12:56AM -0600, Josh Poimboeuf wrote: The next line of attack

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-19 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 06:19:29PM +0100, Vojtech Pavlik wrote: On Thu, Feb 19, 2015 at 11:03:53AM -0600, Josh Poimboeuf wrote: On Thu, Feb 19, 2015 at 05:33:59PM +0100, Vojtech Pavlik wrote: On Thu, Feb 19, 2015 at 10:24:29AM -0600, Josh Poimboeuf wrote: No, these tasks

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-19 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 05:33:59PM +0100, Vojtech Pavlik wrote: On Thu, Feb 19, 2015 at 10:24:29AM -0600, Josh Poimboeuf wrote: No, these tasks will _never_ make syscalls. So you need to guarantee they don't accidentally enter the kernel while you flip them. Something like so should do

[PATCH] ktest: restore tty settings after closing console

2015-01-27 Thread Josh Poimboeuf
, but the output is much more legible overall, and the terminal works just fine after ktest exits. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- tools/testing/ktest/ktest.pl | 7 +++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index

Re: [PATCH] ktest: restore tty settings after closing console

2015-01-28 Thread Josh Poimboeuf
On Wed, Jan 28, 2015 at 10:08:31AM -0500, Steven Rostedt wrote: On Wed, 28 Jan 2015 08:59:23 -0600 Josh Poimboeuf jpoim...@redhat.com wrote: On Tue, Jan 27, 2015 at 05:01:29PM -0500, Steven Rostedt wrote: On Tue, 27 Jan 2015 12:10:04 -0600 Josh Poimboeuf jpoim...@redhat.com wrote

[PATCH v2 1/2] ktest: give console process a dedicated tty

2015-01-28 Thread Josh Poimboeuf
Create a pseudoterminal (pty pair) to give the console a dedicated tty so it doesn't mess with ktest's terminal settings. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- tools/testing/ktest/ktest.pl | 66 ++-- 1 file changed, 57 insertions(+), 9

Re: [PATCH] ktest: restore tty settings after closing console

2015-01-28 Thread Josh Poimboeuf
On Tue, Jan 27, 2015 at 05:01:29PM -0500, Steven Rostedt wrote: On Tue, 27 Jan 2015 12:10:04 -0600 Josh Poimboeuf jpoim...@redhat.com wrote: When ktest runs the console program as a child process, the parent and child share the same tty for stdin and stderr. This is problematic when

[PATCH v2 2/2] ktest: enable user input to the console

2015-01-28 Thread Josh Poimboeuf
Allow the user to send input to the console by putting the terminal in cbreak mode (to allow reading stdin one character at a time) and copying all stdin data to the console's pty. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- tools/testing/ktest/ktest.pl | 51

[PATCH v2 0/2] ktest: console pty support

2015-01-28 Thread Josh Poimboeuf
to enable user input to the console Josh Poimboeuf (2): ktest: give console process a dedicated tty ktest: enable user input to the console tools/testing/ktest/ktest.pl | 117 ++- 1 file changed, 93 insertions(+), 24 deletions(-) -- 2.1.0

Re: [PATCH linux-next] livepatch: kconfig: use bool instead of boolean

2015-01-06 Thread Josh Poimboeuf
://lkml.kernel.org/r/1419108071-11607-1-git-send-email...@linux.com Signed-off-by: Christoph Jaeger c...@linux.com Acked-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/livepatch/Kconfig b/kernel

[PATCH] livepatch: fix deferred module patching order

2015-01-09 Thread Josh Poimboeuf
' $ modprobe nfsd [ 52.888922] livepatch: applying patch 'patch2' to loading module 'nfsd' [ 52.899847] livepatch: applying patch 'patch1' to loading module 'nfsd' Fix the loading order by storing the klp_patches list in queue order. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel

[PATCH] livepatch: support for repatching a function

2015-01-09 Thread Josh Poimboeuf
between function versions to happen instantaneously by updating the klp_ops struct's func_stack list. The winner is the klp_func at the top of the func_stack (front of the list). Signed-off-by: Josh Poimboeuf jpoim...@redhat.com Acked-by: Seth Jennings sjenn...@redhat.com --- include/linux

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-09 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 12:15:21AM +0100, Jiri Kosina wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: This patch set implements a livepatch consistency model, targeted for 3.21. Now that we have a solid livepatch code base, this is the biggest remaining missing piece. Hi Josh, first

[RFC PATCH 4/9] livepatch: get function sizes

2015-02-09 Thread Josh Poimboeuf
For the consistency model we'll need to know the sizes of the old and new functions to determine if they're on any task stacks. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- include/linux/livepatch.h | 3 +++ kernel/livepatch/core.c | 19 ++- 2 files changed, 21

[RFC PATCH 9/9] livepatch: update task universe when exiting kernel

2015-02-09 Thread Josh Poimboeuf
switch universes when returning from an interrupt. If a task is sleeping on a to-be-patched function, the user can send SIGSTOP and SIGCONT to force it to switch. Since the idle swapper tasks don't ever exit the kernel, they're updated from within the idle loop. Signed-off-by: Josh Poimboeuf

[RFC PATCH 5/9] sched: move task rq locking functions to sched.h

2015-02-09 Thread Josh Poimboeuf
Move task_rq_lock/unlock() to sched.h so they can be used elsewhere. The livepatch code needs to lock each task's rq in order to safely examine its stack and switch it to a new patch universe. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/sched/core.c | 32

[RFC PATCH 7/9] proc: add /proc/pid/universe to show livepatch status

2015-02-09 Thread Josh Poimboeuf
Expose the per-task klp_universe value so users can determine which tasks are holding up completion of a patching operation. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- fs/proc/base.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index

[RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-09 Thread Josh Poimboeuf
Now that we have a consistency model we can detect when unpatching is complete and the patch module can be safely removed. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/core.c | 25 - kernel/livepatch/transition.c | 3 +++ 2 files changed

[RFC PATCH 0/9] livepatch: consistency model

2015-02-09 Thread Josh Poimboeuf
the high-level thread_fn itself). But then how do you make the kthread wake up? As far as I can tell, wake_up_process() doesn't seem to work on a kthread (unless I messed up my testing somehow). What does kGraft do in this case? [1] https://lkml.org/lkml/2014/11/7/354 Josh Poimboeuf (9

[RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-09 Thread Josh Poimboeuf
in the previous universe. A transition can be reversed and effectively canceled by writing the opposite value to the /sys/kernel/livepatch/patch/enabled file while the transition is in progress. Then all the tasks will attempt to converge back to the original universe. Signed-off-by: Josh Poimboeuf

[RFC PATCH 1/9] livepatch: simplify disable error path

2015-02-09 Thread Josh Poimboeuf
If registering the function with ftrace has previously succeeded, unregistering will almost never fail. Even if it does, it's not a fatal error. We can still carry on and disable the klp_func from being used by removing it from the klp_ops func stack. Signed-off-by: Josh Poimboeuf jpoim

[RFC PATCH 3/9] livepatch: move patching functions into patch.c

2015-02-09 Thread Josh Poimboeuf
Move functions related to the actual patching of functions and objects into a new patch.c file. The only functional change is to remove the unnecessary WARN_ON(!klp_is_object_loaded()) check from klp_patch_object(). Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- kernel/livepatch/Makefile

[RFC PATCH 2/9] livepatch: separate enabled and patched states

2015-02-09 Thread Josh Poimboeuf
and added to the klp_ops func stack. Also, since these states are binary, represent them with boolean-type variables instead of enums. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- include/linux/livepatch.h | 15 - kernel/livepatch/core.c | 79

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 03:40:14PM +0100, Miroslav Benes wrote: On Fri, 13 Feb 2015, Jiri Kosina wrote: On Fri, 13 Feb 2015, Josh Poimboeuf wrote: How about we take a slightly different aproach -- put a probe (or ftrace) on __switch_to() during a klp transition period

Re: [RFC PATCH 3/9] livepatch: move patching functions into patch.c

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 03:28:28PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: Move functions related to the actual patching of functions and objects into a new patch.c file. I am definitely for splitting the code to several different files. Otherwise

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 11:14:01AM +0100, Jiri Kosina wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: My biggest concerns and questions related to this patch set are: 1) To safely examine the task stacks, the transition code locks each task's rq struct, which requires using

Re: [RFC PATCH 2/9] livepatch: separate enabled and patched states

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 01:57:38PM +0100, Miroslav Benes wrote: On Mon, 9 Feb 2015, Josh Poimboeuf wrote: Once we have a consistency model, patches and their objects will be enabled and disabled at different times. For example, when a patch is disabled, its loaded objects' funcs can

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 03:22:15PM +0100, Jiri Kosina wrote: On Fri, 13 Feb 2015, Josh Poimboeuf wrote: How about we take a slightly different aproach -- put a probe (or ftrace) on __switch_to() during a klp transition period, and examine stacktraces for tasks that are just about

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-13 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 04:22:24PM +0100, Miroslav Benes wrote: On Tue, 10 Feb 2015, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c ... @@ -497,10 +500,6 @@ static struct attribute *klp_patch_attrs

Re: [RFC PATCH 3/9] livepatch: move patching functions into patch.c

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 07:27:51PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: Move functions related to the actual patching of functions and objects into a new patch.c file. The only functional change is to remove the unnecessary WARN_ON

Re: [RFC PATCH 7/9] proc: add /proc/pid/universe to show livepatch status

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 07:47:12PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: Expose the per-task klp_universe value so users can determine which tasks are holding up completion of a patching operation. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 01:27:59PM -0600, Seth Jennings wrote: On Mon, Feb 09, 2015 at 11:31:18AM -0600, Josh Poimboeuf wrote: diff --git a/kernel/livepatch/transition.h b/kernel/livepatch/transition.h new file mode 100644 index 000..ba9a55c --- /dev/null +++ b/kernel/livepatch

Re: [RFC PATCH 4/9] livepatch: get function sizes

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 07:30:50PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -197,8 +197,25 @@ static int klp_find_verify_func_addr(struct klp_object *obj, else ret

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-10 Thread Josh Poimboeuf
On Tue, Feb 10, 2015 at 08:02:34PM +0100, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c ... @@ -497,10 +500,6 @@ static struct attribute *klp_patch_attrs[] = { static void klp_kobj_release_patch(struct

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-12 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 02:16:07PM +0100, Jiri Kosina wrote: On Thu, 12 Feb 2015, Peter Zijlstra wrote: The short answer is: I need a way to ensure that a task isn't sleeping on any of the functions we're trying to patch. If it's not, then I can switch the task over to start using new

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-12 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 12:56:28PM +0100, Peter Zijlstra wrote: On Wed, Feb 11, 2015 at 09:21:21PM -0600, Josh Poimboeuf wrote: Ingo, Peter, Would you have any objections to making task_rq_lock/unlock() non-static (or moving them to kernel/sched/sched.h) so they can be called

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-12 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 01:42:01PM +0100, Jiri Kosina wrote: On Thu, 12 Feb 2015, Peter Zijlstra wrote: Well, the fact indisputable fact is that there is a demand for this. It's not about one machine, it's about scheduling dowtimes of datacentres. The changelog says: ... A

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-12 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 03:08:38PM +0100, Jiri Kosina wrote: On Thu, 12 Feb 2015, Peter Zijlstra wrote: I personally am not a big fan of the task_rq_lock() public exposure either. What might be generally useful though (not only for livepatching) would be an API that would allow for safe

Re: [RFC PATCH 6/9] livepatch: create per-task consistency model

2015-02-12 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 02:26:42PM +0100, Jiri Slaby wrote: On 02/12/2015, 04:21 AM, Josh Poimboeuf wrote: Ingo, Peter, Would you have any objections to making task_rq_lock/unlock() non-static (or moving them to kernel/sched/sched.h) so they can be called by the livepatch code

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-13 Thread Josh Poimboeuf
On Fri, Feb 13, 2015 at 05:17:10PM +0100, Miroslav Benes wrote: On Fri, 13 Feb 2015, Josh Poimboeuf wrote: Hm, even with Jiri Slaby's suggested fix to add the completion to the unregister path, I still get a lockdep warning. This looks more insidious, related to the locking order

Re: [RFC PATCH 8/9] livepatch: allow patch modules to be removed

2015-02-13 Thread Josh Poimboeuf
On Thu, Feb 12, 2015 at 04:22:24PM +0100, Miroslav Benes wrote: On Tue, 10 Feb 2015, Jiri Slaby wrote: On 02/09/2015, 06:31 PM, Josh Poimboeuf wrote: --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c ... @@ -497,10 +500,6 @@ static struct attribute *klp_patch_attrs

Re: live patching design (was: Re: [PATCH 1/3] sched: add sched_task_call())

2015-02-20 Thread Josh Poimboeuf
On Fri, Feb 20, 2015 at 10:46:13PM +0100, Vojtech Pavlik wrote: On Fri, Feb 20, 2015 at 08:49:01PM +0100, Ingo Molnar wrote: I.e. it's in essence the strong stop-all atomic patching model of 'kpatch', combined with the reliable avoidance of kernel stacks that 'kgraft' uses. That

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-20 Thread Josh Poimboeuf
On Fri, Feb 20, 2015 at 09:08:49PM +0100, Ingo Molnar wrote: * Josh Poimboeuf jpoim...@redhat.com wrote: On Fri, Feb 20, 2015 at 10:50:03AM +0100, Ingo Molnar wrote: * Jiri Kosina jkos...@suse.cz wrote: Alright, so to sum it up: - current stack dumping (even looking at /proc

Re: [PATCH 1/3] sched: add sched_task_call()

2015-02-19 Thread Josh Poimboeuf
On Thu, Feb 19, 2015 at 10:26:09PM +0100, Jiri Kosina wrote: On Thu, 19 Feb 2015, Josh Poimboeuf wrote: How about with a TIF_IN_USERSPACE thread flag? It could be cleared/set right at the border. Then for running tasks it's as simple as: if (test_tsk_thread_flag(task

Re: [PATCH v3] livepatch/module: Correctly handle coming and going modules

2015-03-09 Thread Josh Poimboeuf
On Mon, Mar 09, 2015 at 02:25:28PM +0100, Petr Mladek wrote: 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 but it does not keep the lock all the time. Therefore the following races are possible:

Re: [PATCH] README: make the README agnostic to version numbers

2015-03-09 Thread Josh Poimboeuf
On Mon, Mar 09, 2015 at 11:39:02PM +0800, Yaowei Bai wrote: On Fri, Mar 06, 2015 at 09:59:38AM -0600, Josh Poimboeuf wrote: On Tue, Mar 03, 2015 at 10:08:02PM +0800, Yaowei Bai wrote: As we have moved to 4.x, it should be reflected in README. Signed-off-by: Yaowei Bai bywxiao...@163

Re: [PATCH v3] livepatch/module: Correctly handle coming and going modules

2015-03-10 Thread Josh Poimboeuf
On Tue, Mar 10, 2015 at 01:01:07PM +0100, Petr Mladek wrote: On Mon 2015-03-09 09:40:55, Josh Poimboeuf wrote: On Mon, Mar 09, 2015 at 02:25:28PM +0100, Petr Mladek wrote: + mutex_unlock(module_mutex); } @@ -736,6 +748,7 @@ static int klp_init_object(struct klp_patch *patch

Re: [PATCH 2/2] livepatch: fix patched module loading race

2015-03-06 Thread Josh Poimboeuf
On Fri, Mar 06, 2015 at 08:37:26PM +0900, Masami Hiramatsu wrote: Actually, we can suppose this module unloading context is not changing universe. thus it is expected behavior, isn't it? In the case of my proposed consistency model RFC, if the module unloading task gets preempted, or if

Re: [PATCH v2 1/2] livepatch/module: Apply patch when loaded module is unformed

2015-03-06 Thread Josh Poimboeuf
On Fri, Mar 06, 2015 at 03:00:13PM +0100, Petr Mladek wrote: This brings me back to the original idea with that boolean that marks the state before and after the coming notifier (module_init). We could use a bitfield instead of the two booleans when requested. Yeah, that would work. Though I

Re: [PATCH v2 1/2] livepatch/module: Apply patch when loaded module is unformed

2015-03-05 Thread Josh Poimboeuf
On Thu, Mar 05, 2015 at 04:45:13PM +0100, Petr Mladek wrote: Existing live patches are applied to loaded modules using a notify handler. There are two problems with this approach. First, errors from module notifiers are ignored and could not stop the module from being loaded. But we will

Re: [PATCH v2 2/2] livepatch/module: Correctly handle going modules

2015-03-05 Thread Josh Poimboeuf
On Thu, Mar 05, 2015 at 04:45:14PM +0100, Petr Mladek wrote: Existing live patches are removed from going modules using a notify handler. There are two problems with the current implementation. First, new patch could still see the module in the GOING state even after the notifier has been

[PATCH] README: make the README agnostic to version numbers

2015-03-06 Thread Josh Poimboeuf
version-agnostic version? ---8--- Subject: [PATCH] README: make the README version number agnostic Remove all references to Linux version numbers (except for the examples) in the README so we won't have to update it again for Linux 5.0. Signed-off-by: Josh Poimboeuf jpoim...@redhat.com --- README

Re: [PATCH v3] livepatch/module: Correctly handle coming and going modules

2015-03-10 Thread Josh Poimboeuf
On Tue, Mar 10, 2015 at 05:58:02PM +0100, Petr Mladek wrote: On Tue 2015-03-10 09:47:01, Josh Poimboeuf wrote: On Tue, Mar 10, 2015 at 03:36:17PM +0100, Petr Mladek wrote: On Tue 2015-03-10 09:22:04, Josh Poimboeuf wrote: On Tue, Mar 10, 2015 at 01:01:07PM +0100, Petr Mladek wrote

Re: [PATCH v3] livepatch/module: Correctly handle coming and going modules

2015-03-10 Thread Josh Poimboeuf
On Tue, Mar 10, 2015 at 03:36:17PM +0100, Petr Mladek wrote: On Tue 2015-03-10 09:22:04, Josh Poimboeuf wrote: On Tue, Mar 10, 2015 at 01:01:07PM +0100, Petr Mladek wrote: On Mon 2015-03-09 09:40:55, Josh Poimboeuf wrote: On Mon, Mar 09, 2015 at 02:25:28PM +0100, Petr Mladek wrote

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-03-10 Thread Josh Poimboeuf
On Mon, Feb 09, 2015 at 11:31:12AM -0600, Josh Poimboeuf wrote: This patch set implements a livepatch consistency model, targeted for 3.21. Now that we have a solid livepatch code base, this is the biggest remaining missing piece. This code stems from the design proposal made by Vojtech [1

Re: [PATCH v4] livepatch/module: Correctly handle coming and going modules

2015-03-12 Thread Josh Poimboeuf
the value is false. Acked-by: Josh Poimboeuf jpoim...@redhat.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

Re: [RFC PATCH 0/9] livepatch: consistency model

2015-03-10 Thread Josh Poimboeuf
On Tue, Mar 10, 2015 at 05:02:20PM -0400, Jiri Kosina wrote: On Tue, 10 Mar 2015, Josh Poimboeuf wrote: Just an update on the status of this RFC. Thanks to everybody for all the useful comments. I plan to incorporate the resulting changes in an eventual v2 of this patch set

Re: [PATCH v2 1/1] livepatch: add support on s390

2015-03-24 Thread Josh Poimboeuf
On Tue, Mar 24, 2015 at 03:56:34PM +0100, Jiri Slaby wrote: This is a trivial port from kGraft. Module relocations are not +static inline int klp_write_module_reloc(struct module *mod, unsigned long + type, unsigned long loc, unsigned long value) +{ + /* not supported yet */

Re: [PATCH v3 1/1] livepatch: add support on s390

2015-03-25 Thread Josh Poimboeuf
On Tue, Mar 24, 2015 at 05:51:00PM +0100, Jiri Slaby wrote: This is a trivial port from kGraft. Module relocations are not supported. [v2] return ENOSYS Signed-off-by: Jiri Slaby jsl...@suse.cz --- arch/s390/Kconfig | 3 +++ arch/s390/include/asm/livepatch.h | 43

  1   2   3   4   5   6   7   8   9   10   >