Commit Graph

629 Commits

Author SHA1 Message Date
Seth Jennings
ad8f2299ef Merge pull request #218 from jpoimboe/struct-def-change-error
kpatch-build: better error message for struct def change
2014-05-28 16:18:53 -05:00
Josh Poimboeuf
eb44c06918 kpatch-build: better error message for struct def change
Fixes #109.
2014-05-28 13:48:55 -05:00
Seth Jennings
2225bd83cc Merge pull request #180 from ryanmiao/print_funcs
export funcs via sysfs
2014-05-27 23:24:49 -05:00
Seth Jennings
52c0cd108d Merge pull request #217 from jpoimboe/check-page-rw
kmod/core: ensure page is RO before changing its permissions
2014-05-27 23:23:26 -05:00
Josh Poimboeuf
625fcdfb72 kmod/core: ensure page is RO before changing its permissions
Make sure we leave the page's execution permissions in the same state we
found them.
2014-05-27 21:58:15 -05:00
Josh Poimboeuf
ab941fb90a kmod/core: make loc variable a u64
So less casting is needed.
2014-05-27 21:49:45 -05:00
Josh Poimboeuf
80c1e8ac83 kmod/core: move dynamic relocation writes to new function
Unclutter kpatch_register a little bit.
2014-05-27 21:47:50 -05:00
Seth Jennings
23f2cdfec2 Merge pull request #214 from jpoimboe/special-sections
generic support for special sections
2014-05-27 15:18:48 -05:00
Josh Poimboeuf
98617df3ef Merge pull request #215 from jstancek/issue202
correlate symbols also by type
2014-05-27 12:49:42 -05:00
Josh Poimboeuf
92a4ca2621 create-diff-object: support tracepoints and related sections
Add support for the following special sections:

- __jump_table
- __tracepoints
- __tracepoints_ptrs
- __tracepoints_strings

Fixes #157.
2014-05-27 12:47:45 -05:00
Josh Poimboeuf
698cc1c137 create-diff-object: support fixup and related sections
Add support for the following sections:

- .fixup
- __ex_table
- .altinstructions
- .altinstr_replacement

Fixes #187.
2014-05-27 12:47:45 -05:00
Josh Poimboeuf
317d957f2c create-diff-object: generic special section support
Abstract out the common functionality for dealing with special sections
into a new kpatch_process_special_sections() function.

The base sections are partitioned into "groups".  Only those groups
whose relas reference a changed function are kept.  The only difference
in the logic for handling each special section is determining the size
of a given group.  Each section has its own group_size() callback for
this.  It's a callback instead of an integer because one of the
soon-to-be-supported special sections requires that its group sizes be
dynamically determined.
2014-05-27 12:47:45 -05:00
Josh Poimboeuf
d74f78342a create-diff-object: improve error message 2014-05-27 12:47:45 -05:00
Josh Poimboeuf
b1131bfeb6 create-diff-object: fix symbol section indexes
For a local non-included function or object which is needed by an
included function, its symbol table entry will still refer to a local
section index.  Instead it should be changed to SHN_UNDEF.
2014-05-27 12:47:45 -05:00
Josh Poimboeuf
0ebbed244e create-diff-object: percpu support
The -fdata-sections gcc flag doesn't work with objects in the
.data..percpu section.  Any function which uses a percpu variable
references this section, causing the section to get incorrectly included
in the patch module.

Manually convert these section references to object symbol references so
that the needed symbol can be found in vmlinux.

Also, the core module symbol verification code will fail when looking up
a percpu variable, because sprint_symbol doesn't think a percpu address
is a valid kernel address.  So rewrite the symbol verification code to
use kallsyms_on_each_symbol() instead.  It's not ideal performance-wise:
it seems to cost about 1ms per symbol lookup.  I think that's acceptable
for now.  In the future we may want to try to get a better upstream
kallsyms interface.
2014-05-27 12:47:42 -05:00
Seth Jennings
0ef39f8b0b Merge pull request #216 from jstancek/issue203
fix vmlinux parameter for kpatch-build
2014-05-27 12:45:32 -05:00
Jan Stancek
e89f6fa679 fix vmlinux parameter for kpatch-build
It was missing in getopt arguments.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2014-05-27 19:33:46 +02:00
Jan Stancek
ff88218d9e correlate symbols also by type
Both unpatched and patched objects may contain FILE
symbol with empty name. This is unexpected for
create-diff-object and could correlate 2 symbols
with same (empty) name but different types:
  sym 00, type 0, bind 0, ndx 00, name  (SAME)
  ...
  sym 425, type 4, bind 0, ndx 65521, name  (SAME)
  ...
  signal.o: changed function: do_rt_tgsigqueueinfo
  signal.o: changed function: do_rt_sigqueueinfo
  signal.o: changed function: get_signal_to_deliver
  signal.o: signal.o: changed section .rela__jump_table not selected for inclusion
  signal.o: 1 unsupported section change(s)
  /root/kpatch/kpatch-build/create-diff-object: unreconcilable difference

Introduce condition to match symbols also by type.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2014-05-27 19:25:34 +02:00
Josh Poimboeuf
6aee215b04 Merge pull request #213 from jpoimboe/test-combined
test: add much quicker combined test option
2014-05-27 09:51:57 -05:00
Josh Poimboeuf
d7f209f838 test: add much quicker combined test option
Combine all the patch modules into a single kpatch-COMBINED.ko for a
much quicker test which still gives 95% or so of the coverage compared
to the full test suite.  Use "make quick" for use this new option.
2014-05-27 09:40:24 -05:00
Seth Jennings
82f095167e Merge pull request #211 from useidel/master
rebased SPEC file to current version
2014-05-27 09:05:14 -05:00
Jincheng Miao
827a143caf kmod/patch: export patched functions information via sysfs
This feature is implemented as:
```
[root@localhost kpatch]# insmod ./kpatch-meminfo.ko
[root@localhost kpatch]# ls /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/
new_addr  old_addr
[root@localhost kpatch]# cat /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/new_addr
0xffffffffa05211e0
[root@localhost kpatch]# cat /sys/kernel/kpatch/patches/kpatch_meminfo/functions/meminfo_proc_show/old_addr
0xffffffff8125d0e0
```

The patch module init function will allocate and init kpatch_func_obj with
customized kobj_type func_ktype. The attribute new_addr and old_addr of
kpatch_func_obj is attached to this func_ktype, so that these files could
be created by kobject_add automatically.

Signed-off-by: Jincheng Miao <jincheng.miao@gmail.com>
2014-05-27 21:56:56 +08: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