On Mon, Feb 09, 2015 at 11:31:18AM -0600, 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 semantics. > > When a patch is enabled, livepatch enters into a transition state where > tasks are converging from the old universe to the new universe. If a > given task isn't using any of the patched functions, it's switched to > the new universe. Once all the tasks have been converged to the new > universe, patching is complete. > > The same sequence occurs when a patch is disabled, except the tasks > converge from the new universe to the old universe. > > The /sys/kernel/livepatch/<patch>/transition file shows whether a patch > is in transition. Only a single patch (the topmost patch on the stack) > can be in transition at a given time. A patch can remain in the > transition state indefinitely, if any of the tasks are stuck 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 <jpoimboe@xxxxxxxxxx> > --- > include/linux/livepatch.h | 18 ++- > include/linux/sched.h | 3 + > kernel/fork.c | 2 + > kernel/livepatch/Makefile | 2 +- > kernel/livepatch/core.c | 71 ++++++---- > kernel/livepatch/patch.c | 34 ++++- > kernel/livepatch/patch.h | 1 + > kernel/livepatch/transition.c | 300 ++++++++++++++++++++++++++++++++++++++++++ > kernel/livepatch/transition.h | 16 +++ > kernel/sched/core.c | 2 + > 10 files changed, 423 insertions(+), 26 deletions(-) > create mode 100644 kernel/livepatch/transition.c > create mode 100644 kernel/livepatch/transition.h > <snip> > diff --git a/kernel/livepatch/transition.h b/kernel/livepatch/transition.h > new file mode 100644 > index 0000000..ba9a55c > --- /dev/null > +++ b/kernel/livepatch/transition.h > @@ -0,0 +1,16 @@ > +#include <linux/livepatch.h> > + > +enum { > + KLP_UNIVERSE_UNDEFINED = -1, > + KLP_UNIVERSE_OLD, > + KLP_UNIVERSE_NEW, > +}; > + > +extern struct mutex klp_mutex; klp_mutex isn't defined in transition.c. Maybe this extern should be in the transition.c file or in a core.h file, since core.c provides the definition? Thanks, Seth > +extern struct klp_patch *klp_transition_patch; > + > +extern void klp_init_transition(struct klp_patch *patch, int universe); > +extern void klp_start_transition(int universe); > +extern void klp_reverse_transition(void); > +extern void klp_try_complete_transition(void); > +extern void klp_complete_transition(void); > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 78d91e6..7b877f4 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -74,6 +74,7 @@ > #include <linux/binfmts.h> > #include <linux/context_tracking.h> > #include <linux/compiler.h> > +#include <linux/livepatch.h> > > #include <asm/switch_to.h> > #include <asm/tlb.h> > @@ -4601,6 +4602,7 @@ void init_idle(struct task_struct *idle, int cpu) > #if defined(CONFIG_SMP) > sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu); > #endif > + klp_update_task_universe(idle); > } > > int cpuset_cpumask_can_shrink(const struct cpumask *cur, > -- > 2.1.0 > -- To unsubscribe from this list: send the line "unsubscribe live-patching" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html