Commit Graph

458 Commits

Author SHA1 Message Date
Seth Jennings
82f095167e Merge pull request #211 from useidel/master
rebased SPEC file to current version
2014-05-27 09:05:14 -05:00
Josh Poimboeuf
54111376c0 Merge pull request #212 from spartacus06/remove-inventory-test-framework
remove inventory based testing
2014-05-27 08:05:16 -05:00
Seth Jennings
be4ee611c1 remove inventory based testing
The inventory based testing for create-diff-object was introduced at a
time when create-diff-object only needed the two object files to operate.
Now, it requires vmlinux as well.  This makes the inventory testing (a
unit testing framework for create-diff-object) obsolete and difficult to
update in it's current form.

This commit removes the inventory test framework.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-26 16:51:53 -05:00
Udo Seidel
d6af58d3ab rebased SPEC file to current version 2014-05-24 14:51:11 +02:00
Josh Poimboeuf
ae24942c9e Merge pull request #209 from spartacus06/symbol-location-verification
Symbol location verification
2014-05-24 07:11:59 -05:00
Seth Jennings
a5d986ee96 review fixups
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-23 23:41:28 -05:00
Seth Jennings
505e948af0 symbol location verification support
This commit introduces functionality to verify the location of symbols
used in both the patch and dynrelas sections.  It adds significant
protection from mismatches between the base and running kernels.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-23 16:39:56 -05:00
Seth Jennings
08dc2ae78c change matching criteria for NULL sym
Right now the matching criteria for the NULL sym is type LOCAL and shndx
UNDEF.  Unfortunately, that would also match any new LOCAL symbol
added to the symbol table with uninit'd sym.* fields i.e. the upcoming
__kpatch_strings and .kpatch.strings symbols.

Change the matching criteria to be symbols that have a zero-length name;
a property unique to the NULL sym.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-23 16:39:55 -05:00
Josh Poimboeuf
4fb7930d34 Merge pull request #208 from spartacus06/fix-symbol-migration
fix symbol migration
2014-05-23 15:54:37 -05:00
Seth Jennings
46a7a0b7b8 fix symbol migration
kpatch_migrate_included_symbols() is called from
kpatch_reorder_symbols() now, not kpatch_migrate_included_elements().
The difference is the kpatch_reorder_symbols() is operating on the
output kpatch_elf structure, and thus all symbols are by definition
included.

Remove the check and rename the function since it is redundant.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-23 15:46:41 -05:00
Seth Jennings
9261bcc642 Merge pull request #206 from jpoimboe/symtab-sh-info
create-diff-object: fix symtab sh_info field
2014-05-23 14:25:54 -05:00
Josh Poimboeuf
2022ed1140 create-diff-object: fix symtab sh_info field
This fixes the weird ld errors we've been seeing lately.

According to the "ELF-64 Object File Format" spec, the symtab sh_info
field should contain "Index of first non-local symbol (i.e., number of
local symbols)".
2014-05-23 14:20:08 -05:00
Seth Jennings
d82e430053 Merge pull request #204 from terrywang/ubuntu
kpatch Ubuntu support and more
2014-05-23 14:11:55 -05:00
Josh Poimboeuf
56fbd41eeb Merge pull request #201 from spartacus06/delay-reindexing-reordering
delay element reindexing and symbol reordering
2014-05-23 09:09:36 -05:00
Terry Wang
0098bd0036 kpatch: make kpatch load & unload work on more distros with less code ;-D 2014-05-23 23:32:12 +10:00
Seth Jennings
847ddaa2e2 delay element reindexing and symbol reordering
Right now, reindexing of the included sections and symbols is done
when they migrate to the output kpatch_elf structure.  However, due
to recently added features, the section and symbol list is not
final at this point, leading to constant tracking of the indexes for
addition sections and symbols added after this point.  Additionally,
symbols have to be in a particular order, adding to the complexity.

This commit delays the reindexing and symbol reordering until the
section and symbol lists are finalized, removing the need to
track indexes and placeholders in the symbol list.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-22 16:28:51 -05:00
Seth Jennings
24fba4f773 Merge pull request #200 from jpoimboe/kb-cachedir
kpatch-build: put cache in ~/.kpatch/src
2014-05-22 09:24:14 -05:00
Josh Poimboeuf
d7cea80eac kpatch-build: put cache in ~/.kpatch/src
Since we only ever have one cache at a time, move the kernel source from
~/.kpatch/$(uname -r)/src to ~/.kpatch/src.  This allows ccache to work
between kernel version changes, making it less painful to build for
multiple kernels.  The cache's kernel version is stored in
~/.kpatch/version.
2014-05-22 09:17:57 -05:00
Josh Poimboeuf
2601b154d3 Merge pull request #199 from jpoimboe/kpatch-install-refactor
kpatch: get rid of system-installed modules
2014-05-21 16:53:19 -05:00
Josh Poimboeuf
53f8f1d149 kpatch: change --kver to --kernel-version 2014-05-21 16:50:33 -05:00
Josh Poimboeuf
8779d79c50 kpatch: get rid of system-installed modules
The user-installed vs system-installed dichotomy is confusing.  Let's
just have "installed".  RPM-installed modules can just call "kpatch
install" in their post-install step.
2014-05-21 16:50:28 -05:00
Josh Poimboeuf
6dc6d78627 kpatch: uninstall should only look in user-installed dir 2014-05-21 10:52:59 -05:00
Josh Poimboeuf
7e76dba346 kpatch: prevent installing a duplicate patch module 2014-05-21 10:09:11 -05:00
Josh Poimboeuf
761f1e8586 Merge pull request #197 from jpoimboe/test-log-message
test: tell user to check test.log on error
2014-05-20 14:34:47 -05:00
Josh Poimboeuf
b143442916 test: tell user to check test.log on error 2014-05-20 14:34:11 -05:00
Josh Poimboeuf
1f09f09373 Merge pull request #196 from spartacus06/dynamic-symbol-linking
add dynamic symbol linking support (again)
2014-05-20 13:37:18 -05:00
Seth Jennings
b95f0f53af add teardown/free functions for kpatch_elf data structures
Because create-diff-object is a one-shot program (not a long lived
process) we haven't really bothered with cleaning up and freeing any
allocated memory.  However, freeing data when it passes out of the
logical scope does have debugging benefits.

This commit adds two new functions for tearing down and freeing the
primary struct kpatch_elf data structures.  The idea is the if a stale
pointer still references the old data structure that has passed out of
the logical scope, an issue will be more immediately apparent (i.e. NULL
references).

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:31 -05:00
Seth Jennings
b6e77846e8 remove redundant rela buffer rebuild
We rebuild the rela section data buffer in kpatch_create_rela_section()
just to rebuild it again later in kpatch_rebuild_rela_section_data()
before writing the output ELF file.

This commit removes the redundant rebuild while retaining the update
for the section header data.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:31 -05:00
Seth Jennings
170c8b1ba1 fix review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:31 -05:00
Seth Jennings
21fc274448 dynrelas support, obsoleting link-vmlinux-syms
This adds dynamic linking support for the patch modules.  It is the
first step toward supporting patching module code and relocatable
kernels.

Rela entries that reference non-included local and non-exported global
symbols are converted to "dynrelas".  These dynrelas are relocations
that are done by the core module, not the kernel module linker.  This
allows the core module to apply offsets to the base addresses found
in the base vmlinux or module.

Signed-off-by: Seth Jennings <sjenning@redhat.com>

Conflicts:
	kpatch-build/kpatch-build
2014-05-20 12:44:31 -05:00
Seth Jennings
fd8176faf8 rename .patches section to .kpatch.patches
Adding .kpatch to the section name more clearly documents that these
are kpatch related sections.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:30 -05:00
Seth Jennings
6b7d576341 merge add-patches-section functionality into create-obj-diff
In preparation for dynamic symbol linking, the symbol lookup logic
is going to move into create-diff-obj anyway.  We might as well
minimize the code duplication and pull this into create-diff-obj.
This avoids having to re-parse the ELF file modify it in-place.

Signed-off-by: Seth Jennings <sjenning@redhat.com>

Conflicts:
	kpatch-build/kpatch-build
2014-05-20 12:44:30 -05:00
Seth Jennings
b49bfac8fa fix included syms pointing to non-included sections
Right now, there is a case where a symbol is included but not its
section.  This is the case when the symbol is a rela dependency of
another section by the symbol section (the object or function) has not
changed.  When we migrate the included symbols over to the output kelf
structure however, these symbols are still referencing their old
non-included section via their sec fields.  This is a bug.

This commit adds code to the symbol migration to test whether the
symbol's section was also included.  If so, it updates the symbol's
section index.  If not it sets the section index to UNDEF and its sec
field to NULL.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:30 -05:00
Seth Jennings
797b7af234 cleanup: remove unneeded patches variable
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-20 12:44:30 -05:00
Seth Jennings
4238d1bb42 Merge pull request #195 from jpoimboe/initramfs-core-module-path
dracut: fix core module path
2014-05-19 21:06:17 -05:00
Josh Poimboeuf
57ca8eae40 dracut: fix core module path
Forgot to update this file when moving the core module to the extras
subdirectory with a6694fffff.
2014-05-19 19:49:05 -05:00
Josh Poimboeuf
0f3f8ae336 Merge pull request #192 from jpoimboe/vmlinux-mismatch
kpatch-build: use original vmlinux
2014-05-17 09:47:23 -05:00
Josh Poimboeuf
5c98ec65a0 kpatch-build: use original vmlinux
There's at least one case in the kernel (ddebug_proc_show) where the
compiled instructions are affected by the source file path given to gcc.
Which means that compiling the kernel with O= will result in many of the
function addresses changing.  This causes a mismatch between the locally
compiled vmlinux and the original vmlinux, which is very dangerous,
since we need the addresses to be correct.

The easy fix is just to use the original vmlinux for all the function
addresses.

Other potential ways to fix it which we might want to consider in the
future:

- use a combination of the old System.map and the new vmlinux to find
  the addresses.  The function ordering should be the same.  For
  non-duplicate symbols, use System.map.  For duplicate symbols, use
  vmlinux to find what order the symbol comes in.  e.g. the 2nd
  occurrence of foo() in System.map.  It adds a little complexity to the
  lookup code, but seems safe and wouldn't require the kernel debuginfo
  package.  However, this may not help us for patching modules.

- do something similar at runtime, i.e. use kallsyms_lookup_name for
  non-dups and kallsyms_on_each_symbol for dups, and look for the nth
  occurrence of the symbol (value of n is decided at build time).  This
  has the complexity of the previous option but it's done at runtime
  rather than build time, so... why?  Doing it at build time is better.

- compile the kernel in place.  This basically means no more caching
  because recompiling with --function-sections causes everything to be
  recompiled again.  This is bad for kpatch developers' SSDs...
2014-05-16 21:19:25 -05:00
Josh Poimboeuf
bf4be47e62 Merge pull request #191 from jpoimboe/revert-dynamic
Revert #186 (add dynamic symbol linking support)
2014-05-15 17:35:40 -05:00
Josh Poimboeuf
5e25365244 Revert #186 (add dynamic symbol linking support)
We merged PR #186 a little too hastily.  It seg faults with the new
parainstructions-section.patch in the integration test suite.  Reverting
it for now until we get it figured out.

This reverts commit e1177e3a03.
This reverts commit 880e271841.
This reverts commit 2de5f6cbfb.
This reverts commit 38b7ac74ad.
This reverts commit 108cd9f95e.
2014-05-15 17:34:16 -05:00
Josh Poimboeuf
d349d705bf Merge pull request #190 from jpoimboe/test-special-sections
add tests for special sections
2014-05-15 17:29:43 -05:00
Josh Poimboeuf
ecfed91904 test: add basic tests for special sections
One of the tests is now failing:

    ERROR: smp-locks-section: kpatch replace failed

I suspect the issue is the vmlinux mismatch problem.  Fix for that
coming soon.
2014-05-15 17:14:25 -05:00
Josh Poimboeuf
707afe238c test: add make targets 2014-05-15 16:24:33 -05:00
Josh Poimboeuf
c7d3c5d86c test: do load/unload testing for modules that don't have tests
Do some basic load/unload tests for all the test modules, even if they
don't have a corresponding -LOADED.test file.
2014-05-15 16:22:45 -05:00
Josh Poimboeuf
59e9011a30 Merge pull request #188 from spartacus06/fix-list-corruption
fix list corruption in special section handlers
2014-05-15 15:44:10 -05:00
Seth Jennings
2b92531df2 fix list corruption in special section handlers
The kpatch_regenerate_* functions use a local list_head to construct the
new list.  While the local list_head is copied to the sec->relas after
it is built, the neighboring nodes in the list are not updated, leading
to list corruption.

This commit uses list_replace() which updates the neighbor nodes properly.

Regression introduced by PR #117 5d36dd1.

Fixes #185.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 15:27:53 -05:00
Josh Poimboeuf
b3864a11c5 Merge pull request #186 from spartacus06/dynamic-symbol-linking
add dynamic symbol linking support
2014-05-15 14:09:53 -05:00
Seth Jennings
e1177e3a03 fix review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:42:27 -05:00
Seth Jennings
880e271841 dynrelas support, obsoleting link-vmlinux-syms
This adds dynamic linking support for the patch modules.  It is the
first step toward supporting patching module code and relocatable
kernels.

Rela entries that reference non-included local and non-exported global
symbols are converted to "dynrelas".  These dynrelas are relocations
that are done by the core module, not the kernel module linker.  This
allows the core module to apply offsets to the base addresses found
in the base vmlinux or module.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:29:15 -05:00
Seth Jennings
2de5f6cbfb rename .patches section to .kpatch.patches
Adding .kpatch to the section name more clearly documents that these
are kpatch related sections.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-15 13:28:24 -05:00