mirror of
https://github.com/dynup/kpatch
synced 2025-01-03 19:42:03 +00:00
Merge pull request #436 from jpoimboe/descriptor
make "descriptor" a special static local variable
This commit is contained in:
commit
c6506ec549
@ -534,12 +534,20 @@ char *special_static_prefix(struct symbol *sym)
|
|||||||
|
|
||||||
if (!strncmp(sym->name, "__warned.", 9))
|
if (!strncmp(sym->name, "__warned.", 9))
|
||||||
return "__warned.";
|
return "__warned.";
|
||||||
|
|
||||||
|
if (!strncmp(sym->name, "descriptor.", 11))
|
||||||
|
return "descriptor.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym->type == STT_SECTION &&
|
if (sym->type == STT_SECTION) {
|
||||||
!strncmp(sym->name, ".bss.__key.", 11))
|
if (!strncmp(sym->name, ".bss.__key.", 11))
|
||||||
return ".bss.__key.";
|
return ".bss.__key.";
|
||||||
|
|
||||||
|
/* __verbose section contains the descriptor variables */
|
||||||
|
if (!strcmp(sym->name, "__verbose"))
|
||||||
|
return sym->name;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,14 +949,6 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
|||||||
if (special_static_prefix(sym))
|
if (special_static_prefix(sym))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
|
||||||
* The static variables in the __verbose section contain
|
|
||||||
* debugging information specific to the patched object and
|
|
||||||
* shouldn't be correlated.
|
|
||||||
*/
|
|
||||||
if (!strcmp(sym->sec->name, "__verbose"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strchr(sym->name, '.'))
|
if (!strchr(sym->name, '.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
21
test/integration/gcc-static-local-var-4.patch
Normal file
21
test/integration/gcc-static-local-var-4.patch
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Index: src/fs/aio.c
|
||||||
|
===================================================================
|
||||||
|
--- src.orig/fs/aio.c
|
||||||
|
+++ src/fs/aio.c
|
||||||
|
@@ -229,9 +229,16 @@ static int __init aio_setup(void)
|
||||||
|
}
|
||||||
|
__initcall(aio_setup);
|
||||||
|
|
||||||
|
+void kpatch_aio_foo(void)
|
||||||
|
+{
|
||||||
|
+ if (!jiffies)
|
||||||
|
+ printk("kpatch aio foo\n");
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void put_aio_ring_file(struct kioctx *ctx)
|
||||||
|
{
|
||||||
|
struct file *aio_ring_file = ctx->aio_ring_file;
|
||||||
|
+ kpatch_aio_foo();
|
||||||
|
if (aio_ring_file) {
|
||||||
|
truncate_setsize(aio_ring_file->f_inode, 0);
|
||||||
|
|
7
test/integration/gcc-static-local-var-4.test
Executable file
7
test/integration/gcc-static-local-var-4.test
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if $(nm kpatch-gcc-static-local-var-4.ko | grep -q free_ioctx); then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
@ -2,19 +2,24 @@ Index: src/fs/aio.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- src.orig/fs/aio.c
|
--- src.orig/fs/aio.c
|
||||||
+++ src/fs/aio.c
|
+++ src/fs/aio.c
|
||||||
@@ -1642,3 +1642,15 @@ SYSCALL_DEFINE5(io_getevents, aio_contex
|
@@ -1626,6 +1626,20 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
+
|
|
||||||
|
+static int aio_max_nr_orig;
|
||||||
+void kpatch_load_aio_max_nr(void)
|
+void kpatch_load_aio_max_nr(void)
|
||||||
+{
|
+{
|
||||||
|
+ aio_max_nr_orig = aio_max_nr;
|
||||||
+ aio_max_nr = 0x40000;
|
+ aio_max_nr = 0x40000;
|
||||||
+}
|
+}
|
||||||
+void kpatch_unload_aio_max_nr(void)
|
+void kpatch_unload_aio_max_nr(void)
|
||||||
+{
|
+{
|
||||||
+ aio_max_nr = 0x10000;
|
+ aio_max_nr = aio_max_nr_orig;
|
||||||
+}
|
+}
|
||||||
+#include "kpatch-macros.h"
|
+#include "kpatch-macros.h"
|
||||||
+KPATCH_LOAD_HOOK(kpatch_load_aio_max_nr);
|
+KPATCH_LOAD_HOOK(kpatch_load_aio_max_nr);
|
||||||
+KPATCH_UNLOAD_HOOK(kpatch_unload_aio_max_nr);
|
+KPATCH_UNLOAD_HOOK(kpatch_unload_aio_max_nr);
|
||||||
|
+
|
||||||
|
/* io_getevents:
|
||||||
|
* Attempts to read at least min_nr events and up to nr events from
|
||||||
|
* the completion queue for the aio_context specified by ctx_id. If
|
||||||
|
Loading…
Reference in New Issue
Block a user