Commit Graph

792 Commits

Author SHA1 Message Date
Josh Poimboeuf
99308028d5 print new functions
Fixes #397.
2014-09-04 08:44:54 -05:00
Josh Poimboeuf
4cd66aa713 Merge pull request #396 from spartacus06/include-new-symbols
Include new symbols
2014-09-03 17:12:26 -05:00
Seth Jennings
4506a9575e add test case for new globals inclusion
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-09-03 17:06:50 -05:00
Seth Jennings
6023e9bbde always include new global symbols
In the case that a new global symbol is defined in a file but not used
by a changed function, the symbol will currently not be included.

However, since it is global, another file in the patch my reference it,
but it will not be there.

This commit includes new global symbols so that they may be referenced
by changes in other files within the same patch.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-09-03 14:32:58 -05:00
Seth Jennings
b790e4dc27 Merge pull request #395 from jpoimboe/static-local-fixes
static local variable fixes for WARN_ON_ONCE
2014-09-03 13:23:55 -05:00
Josh Poimboeuf
02fcfa506b code review fixes
Rename bundled1 to bundled and bundled2 to basebundled.
2014-09-03 13:11:04 -05:00
Josh Poimboeuf
aca9b52567 add test case for issue #394. 2014-09-03 10:10:07 -05:00
Josh Poimboeuf
8ac338aac4 support renaming of unbundled static locals
WARN_ON_ONCE places the __warned static local variable in the
.data.unlikely section, so it's not bundled (i.e. ignored by the
-fdata-sections gcc flag).  There's no reason why we can't rename
unbundled symbols, so add support for them.

Fixes #394.
2014-09-03 10:03:01 -05:00
Josh Poimboeuf
017c5e6395 allow multiple references to same static local var
This fixes a logic bug in the static local variable code where we don't
allow multiple relocation references to the same static local variable
symbol.
2014-09-03 09:55:40 -05:00
Josh Poimboeuf
0fd7f7f0be Merge pull request #393 from jpoimboe/0.2.1
0.2.1 release
2014-09-02 11:11:56 -05:00
Josh Poimboeuf
24d8e961ea 0.2.1 release 2014-09-02 11:11:14 -05:00
Seth Jennings
d0606ae91d Merge pull request #390 from jpoimboe/inter-object-call
support for calling a new function in another object
2014-09-02 11:08:55 -05:00
Seth Jennings
21c684a794 Merge pull request #378 from jpoimboe/rodata-isra
support renaming of mangled .rodata sections
2014-09-02 11:06:16 -05:00
Josh Poimboeuf
f257de7c77 support for calling a new function in another object
If a patch adds a new function in foo.c, and calls that function from
bar.c, currently it fails with something like:

    kpatch_create_dynamic_rela_sections: 2115: lookup_global_symbol failed for tpe_allow_file, needed for .text.do_mmap_pgoff

This (crudely) fixes the issue by assuming that if we can't find the
global symbol in the original vmlinux, that it will be provided by
another object in the patch module.  If that assumption is incorrect,
the module will fail to load due to the missing symbol dependency.

A (perhaps) better way to fix this is to search for the symbol in the
patched version of the vmlinux.  But I think this approach is good
enough, for now at least.

Fixes #388.
2014-09-02 10:05:49 -05:00
Seth Jennings
b369d4852a Merge pull request #383 from jpoimboe/sec2-var-rename
rename variables for better readability
2014-08-29 16:15:03 -05:00
Josh Poimboeuf
091930fc80 rename variables for better readability
The naming of variables in this function is confusing, and really threw
me for a loop: sec is first used as an iterator, then sec is reused to
point to the dynrela section, then sec2 is used as another iterator.

Instead make sec the iterator for both loops and dynsec the dynrela
section pointer.
2014-08-29 16:05:52 -05:00
Seth Jennings
ffa6e8c871 Merge pull request #382 from jpoimboe/ignore-section-error-msg
improve KPATCH_IGNORE_SECTION error message
2014-08-29 15:18:25 -05:00
Josh Poimboeuf
ffe560f565 improve KPATCH_IGNORE_SECTION error message 2014-08-29 15:16:52 -05:00
Seth Jennings
00ab879473 Merge pull request #379 from jpoimboe/ignoring-msg-format
change format of "ignoring" messages
2014-08-28 15:43:58 -05:00
Josh Poimboeuf
ae4ad2b4f1 change format of "ignoring" messages
Change the "ignoring" message formatting to be consistent with the
"changed function:" message to make it a little easier to read.
2014-08-28 15:30:43 -05:00
Josh Poimboeuf
e7d00cb9df support renaming of mangled .rodata sections
When a function foo.isra.1 has a switch statement, it might have a
corresponding .rodata.foo.isra.1 section (in addition to its
.text.foo.isra.1 section).  If so, rename that section too.

Otherwise kpatch-build will get confused when comparing the function's
relas which reference the .rodata section, and will mark the function's
rela section as changed because the rela symbol names differ.

I found this bug when trying to build the patch from upstream Linux
commit a3c54931.  Unfortunately this issue is already fixed on F20 and I
wasn't able to come up with a similarly failing test case for the
integration test suite.
2014-08-28 14:34:19 -05:00
Josh Poimboeuf
2e46fef4b6 Merge pull request #375 from spartacus06/modprobe-names
Support modprobe style names in kpatch load
2014-08-28 10:02:00 -05:00
Seth Jennings
58134fd449 Support modprobe format names in uninstall
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-27 14:30:39 -05:00
Seth Jennings
1d63ce8493 Support modprobe style names in kpatch load
When the argument is a .ko file, it should be considered a path (i.e.
don't even look for it in the installed DB). When the argument is a
module name, it should be considered a loaded or installed module (and
then in the case of kpatch load we have to do a reverse translation of
all installed modules to see if any of them match).

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-26 15:47:07 -05:00
Josh Poimboeuf
688a03d8b6 Merge pull request #369 from jpoimboe/0.2.0
0.2.0 release
2014-08-20 11:09:38 -05:00
Josh Poimboeuf
9a7a1038ac 0.2.0 release
ABI breakage b/w core module <-> patch module:
6a69f5f91a
2014-08-20 11:09:05 -05:00
Josh Poimboeuf
aee8c445a1 Merge pull request #340 from goldyfruit/master
REAME.md: add g++ package to the Debian Wheezy procedure
2014-08-20 11:04:58 -05:00
Seth Jennings
e6e15340ef Merge pull request #368 from jpoimboe/readme-rhel7-typo
readme: fix RHEL 7 prereq typo
2014-08-19 09:31:17 -05:00
Seth Jennings
76b262055d Merge pull request #367 from terrywang/oraclelinux
Add support for Oracle Linux 7 and CentOS 7
2014-08-19 09:30:45 -05:00
Josh Poimboeuf
ffda1aaf59 readme: fix RHEL 7 prereq typo 2014-08-19 09:17:29 -05:00
Terry Wang
cd5e136169 readme: add support for Oracle Linux 7 and CentOS 7 2014-08-19 20:56:02 +10:00
Terry Wang
9fcd8ba732 kpatch-build: add Oracle Linux 7 and CentOS 7 support 2014-08-19 17:38:47 +10:00
Seth Jennings
7b82b59a68 Merge pull request #360 from flaming-toast/func-sysfs-fix
kpatch-patch-hook: fix incorrect old_offsets for loadable modules
2014-08-15 21:33:45 -05:00
Jessica Yu
6a69f5f91a consolidate variables func->old_offset and func->old_addr to just old_addr
To reduce redundancy, remove/change the old_offset fields in the
kpatch_func and kpatch_patch_func structs to just old_addr. Since
old_offset is being used as a placeholder for old_addr, might as well
consolidate it to just one variable.
2014-08-15 23:42:26 -07:00
Jessica Yu
8464c25d95 kpatch-patch-hook: fix incorrect old_offsets for loadable modules
Fix incorrect old_offsets for loadable modules during sysfs
initialization in patch_init.

sysfs will be initialized on patch module init regardless of whether
or not the module is loaded. func_old_addr_show() will read from func->old_addr,
which is initially set to 0; it'll be eventually filled in by the core module.
2014-08-15 23:42:22 -07:00
Seth Jennings
b16f85cad3 Merge pull request #366 from jpoimboe/allow-new-data
create-diff-object: allow new data to be included
2014-08-14 07:56:40 -05:00
Josh Poimboeuf
543ad11ccd create-diff-object: allow new data to be included
Allow the inclusion of new global variables.
2014-08-14 01:12:27 -05:00
Josh Poimboeuf
437245e374 Merge pull request #365 from spartacus06/issue-359-v2
always include .rodata.str1.* sections
2014-08-14 00:19:07 -05:00
Seth Jennings
26ef7bfcb1 always include .rodata.str1.* sections
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-13 21:26:34 -05:00
Seth Jennings
f466a60708 fix use-after-free error
Don't use rela after you just freed it!

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-13 17:08:42 -05:00
Josh Poimboeuf
a57342806c Merge pull request #363 from jpoimboe/add-hook-test
test: add hook macro test
2014-08-13 14:25:35 -05:00
Josh Poimboeuf
eb62038e92 test: add hook macro test
From issue #357.
2014-08-13 14:24:18 -05:00
Josh Poimboeuf
ae04b84f51 Merge pull request #362 from spartacus06/fix-dynrela-corruption-in-hooks
fix dynrela corruption in load/unload hooks
2014-08-13 14:19:07 -05:00
Seth Jennings
7dfad2fb76 fix dynrela corruption in load/unload hooks
In kpatch_create_dynamic_rela_sections() the dest field is filled in
with either the function symbol or the section symbol that contains the
function depending on whether or not the sym field of the base section
is NULL or not (around line 2153).

In the case of the hook functions, we strip the FUNC symbol to prevent
it from being added to the kpatch.funcs section as a patched function.
However we weren't unbundling the stripped symbol from the section.
This resulted in the sym field pointing to the null symbol (index 0),
corrupting the dynrelas rela section.

Before:

Relocation section [14] '.rela.kpatch.dynrelas' for section [13] '.kpatch.dynrelas' at offset 0x8b8 contains 6 entries:
  Offset              Type            Value               Addend Name
  000000000000000000  X86_64_64       000000000000000000      +9
  0x0000000000000018  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000020  X86_64_64       000000000000000000      +0 .kpatch.strings
  0x0000000000000030  X86_64_64       000000000000000000      +9
  0x0000000000000048  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000050  X86_64_64       000000000000000000      +0 .kpatch.strings

This commit unbundles the stripped symbol from the section so that the
section symbol is used in the dynrelas rela section.

After:

Relocation section [14] '.rela.kpatch.dynrelas' for section [13] '.kpatch.dynrelas' at offset 0x8b8 contains 6 entries:
  Offset              Type            Value               Addend Name
  000000000000000000  X86_64_64       000000000000000000      +9 .text.kpatch_load_aio_max_nr
  0x0000000000000018  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000020  X86_64_64       000000000000000000      +0 .kpatch.strings
  0x0000000000000030  X86_64_64       000000000000000000      +9 .text.kpatch_unload_aio_max_nr
  0x0000000000000048  X86_64_64       000000000000000000      +8 .kpatch.strings
  0x0000000000000050  X86_64_64       000000000000000000      +0 .kpatch.strings

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-13 13:40:29 -05:00
Josh Poimboeuf
5763fcdb27 Merge pull request #361 from spartacus06/issue-357
allow patches that only contains hook functions
2014-08-13 11:38:50 -05:00
Seth Jennings
e020127eea allow patches that only contains hook functions
Fixes #357

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-13 11:28:43 -05:00
Seth Jennings
c8c69a8eaa Merge pull request #355 from jpoimboe/rhel7-tmp-obj-fix
kpatch-gcc: fix for .tmp_* objects on RHEL 7
2014-08-12 23:08:14 -05:00
Josh Poimboeuf
7b4ee86197 kpatch-gcc: fix for .tmp_* objects on RHEL 7
On RHEL 7 I see the following error when trying to patch meminfo.o:

    cp: cannot stat ‘/home/user/.kpatch/obj/fs/proc/.tmp_meminfo.o’: No such file or directory

It turns out that on RHEL 7, a given object foo.o is compiled as
.tmp_foo.o before then being linked as foo.o.  I have no idea why.  The
fix is to record .tmp_foo.o as foo.o in the changed_objs file.
2014-08-12 21:21:53 -05:00
Josh Poimboeuf
0efd8b0f2b Merge pull request #354 from spartacus06/diff-tree-tests
add difftest.sh test
2014-08-12 11:05:00 -05:00
Seth Jennings
a59607742e add difftest.sh test
The purpose of this test script is to determine if create-diff-object
can properly recognize object file equivalence when passed the same file
for both the original and patched objects.  This verifies that
create-diff-object is correctly parsing, correlating, and comparing the
different elements of the object file.  In practice, a situation similar
to the test case occurs when a commonly included header file changes,
causing Make to rebuild many objects that have no functional change.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-12 10:50:46 -05:00