kpatch/test/integration/special-static.patch
Josh Poimboeuf 2982962549 support for__key and __warned special static local vars
Add support for the __key and __warned "special" static local variables.
I'm calling them that for lack of a better term, analagous to the
kernel's special sections that we have to deal with.

__warned: Used by WARN_ONCE et al as an indicator as to whether a
message has already been printed.  I think it makes sense (and is much
easier) to reset this counter for a given function when replacing the
function, since the user may expect the new function to warn again.

__key: Used by lockdep as an identifier for a given lock initialization
code path (see http://lwn.net/Articles/185666/ for more info).  I think
it makes sense (and is much easier) to create a new key for a given
function when replacing the function, because the locking semantics may
have changed, so it makes sense for lockdep to use a new key to validate
the new locking behavior.

So for both __warned and __key static variables, the new version of the
variable should be used when referenced by an included function.

Made the following changes to support these special variables:

- Ignore their suffixes when comparing them in rela_equal, so that gcc
  renaming them will not result in a function being marked as changed
  just because it referenced a renamed static local

- Don't ever correlate them, so that their new versions will be included
  if a changed or new function uses their corresponding symbols

Fixes #402.
2014-09-09 13:36:20 -05:00

24 lines
510 B
Diff

Index: src/kernel/fork.c
===================================================================
--- src.orig/kernel/fork.c
+++ src/kernel/fork.c
@@ -1029,10 +1029,18 @@ static void posix_cpu_timers_init_group(
INIT_LIST_HEAD(&sig->cpu_timers[2]);
}
+void kpatch_foo(void)
+{
+ if (!jiffies)
+ printk("kpatch copy signal\n");
+}
+
static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
{
struct signal_struct *sig;
+ kpatch_foo();
+
if (clone_flags & CLONE_THREAD)
return 0;