Commit Graph

690 Commits

Author SHA1 Message Date
Seth Jennings
11f8f8da76 mark mcount sections as SAME
Right now, in the case that the mcount sections have changed, we get a
"changed section not included" error on them.  Since we rebuild them
from scratch, just mark them as SAME even if they are different so that
we don't cause an error.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 09:29:46 -05:00
Seth Jennings
85da92132f s/funcs/functions/g
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 09:29:46 -05:00
Josh Poimboeuf
02e1a824d9 Merge pull request #331 from spartacus06/dont-check-shlink
remove sh_link from section comparison
2014-07-28 09:00:32 -05:00
Seth Jennings
5a4756bbb8 remove sh_link from section comparison
This sh_link line currently has a bug with both operands being sec1; the
second should be sec2.  However the bug is masking a logical flaw; that
is that the sh_link is the index of either the symtab or the strtab and
that can change if sections have been added or removed by the patch.

This commit removes the comparison.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-25 09:35:34 -05:00
Seth Jennings
4e41f39853 Merge pull request #328 from jpoimboe/static-local-vars
support for gcc static local variable naming
2014-07-24 17:23:30 -05:00
Josh Poimboeuf
9c3c9b0c0a support for gcc static local variable renaming
gcc renames static local variables by appending a period and a number.
For example, __key could be renamed to __key.31452.  Unfortunately this
number can arbitrarily change.  Try to rename the patched version of the
symbol to match the base version and then correlate them.

Fixes #313.
2014-07-24 15:08:15 -05:00
Josh Poimboeuf
402911b949 replace section symbols before correlating
The correlation logic could get confused if it compares two relas whose
symbols haven't been converted from section symbols to object or
function symbols.  So we should replace section symbols for both the
base and the patched object before correlating, so that it can compare
the function and object symbols rather than the section symbols.

This is also a prerequisite for dealing properly with gcc's renaming of
static local variables, because relas which reference static locals
usually use section symbols.
2014-07-24 14:51:57 -05:00
Josh Poimboeuf
ce8bb40fc0 Merge pull request #327 from spartacus06/make-all
remove build pass from kpatch-build
2014-07-23 11:30:53 -05:00
Seth Jennings
5321b21aa0 fixup review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 11:24:02 -05:00
Seth Jennings
9a2f8c5c44 remove build pass from kpatch-build
Now that we use the vmlinux from the distro debug package we don't need
to do any build runs without -ffunction-sections -fdata-sections.

Old:
Build orig in objdir
Build patched in objdir
Build orig w/ flags in objdir2
Copy orig .o's into orig
Build patched w/ flags in objdir2
Copy patched .o's into patched

New:
Build orig w/ flags in objdir
Build patched w/ flags in objdir
Copy patched .o's into patched
Build orig w/ flags in objdir
Copy orig .o's into orig

This commit also does try to build each change object singularly since
there are cases in the kernel tree where the Makefile does not reside in
the same directory as the changed object.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 10:03:00 -05:00
Seth Jennings
c40d164931 Merge pull request #326 from jpoimboe/unload-all
kpatch: add unload --all command
2014-07-23 09:50:12 -05:00
Josh Poimboeuf
d707c4062d kpatch: add unload --all command
This may end up being useful in the distro patch module upgrade path.
If the core module also needs updating, we can first do "kpatch unload
--all" and "rmmod kpatch" before doing "kpatch load" of the new patch
module.
2014-07-23 09:16:11 -05:00
Josh Poimboeuf
77c8700888 Merge pull request #323 from spartacus06/ignore-funcs-v2
add support for manually ignore functions
2014-07-23 09:01:55 -05:00
Seth Jennings
84618404e0 add support for manually ignore functions
This commit adds the KPATCH_IGNORE_FUNC() macro for ignoring functions
that may change as a side effect of a change in another function.  The
WARN class of macros, for example, embed the line number in an
instruction, which will cause the function to be detected as changed
when, in fact, there has been no functional change.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 09:00:16 -05:00
Seth Jennings
063668477c Merge pull request #320 from goldyfruit/master
readme.md: add support for Debian GNU/Linux Wheezy (7.x)
2014-07-21 09:25:32 -05:00
Gaetan Trellu
f69a9400eb readme.md: add support for Debian GNU/Linux Wheezy (7.x) 2014-07-20 22:53:50 -04:00
Josh Poimboeuf
434ed7a10e Merge pull request #319 from spartacus06/fix-msgs
fix logging in kpatch_verify_patchability()
2014-07-18 16:02:36 -05:00
Seth Jennings
bdb44e7594 fix logging in kpatch_verify_patchability()
log_normal() already prints the objname; no need to do it again

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-18 15:29:46 -05:00
Seth Jennings
1c8e8a7d57 Merge pull request #317 from jpoimboe/module-old-addr-fix
kmod/core: module old_addr fix
2014-07-18 10:44:25 -05:00
Josh Poimboeuf
8a008e8645 kmod/core: module old_addr fix
When patching a module, I ran into a "can't set ftrace filter at
address" error.  The root cause was due to the fact that
mod->module_core + old_offset is apparently not a reliable way to
determine the function's address.

Instead, just get the address from kallsyms like we do for module
dynrelas.
2014-07-18 10:09:52 -05:00
Josh Poimboeuf
576ee09442 Merge pull request #312 from spartacus06/add-rhel-install-doc
add install documentation for RHEL
2014-07-15 12:19:49 -05:00
Seth Jennings
00ebeb0b0d add install documentation for RHEL
Fixes #253

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-15 12:09:04 -05:00
Josh Poimboeuf
00a19e6508 Merge pull request #311 from spartacus06/version-compat-update
update supported kernel version
2014-07-15 11:51:10 -05:00
Seth Jennings
3025ce1dae remove mentry mention in kernel version requirement
There are more reasons besides mentry support for 3.9 being the
minimum supported kernel version.  There are also API changes that
happened in 3.9 that make the core module incompatible with previous
versions.

Rather than spelling all that out, just simply state the minimum
version.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-15 11:38:20 -05:00
Seth Jennings
d325e69c3c update supported kernel version
Some of the kernel APIs that are used by the core kernel module where
updated in 3.9 and are incompatible with previous kernel versions.

Update the README to reflect this.

Fixes #257

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-15 11:26:03 -05:00
Seth Jennings
f8813be8ef Merge pull request #310 from jpoimboe/checkpatch-fixes
kmod/core: checkpatch style fixes
2014-07-14 15:55:07 -05:00
Josh Poimboeuf
96d3d241f5 kmod/core: checkpatch style fixes 2014-07-14 15:53:41 -05:00
Seth Jennings
a12715c2e2 Merge pull request #303 from jpoimboe/warn-macros
add KPATCH_WARN_*_LINE macros
2014-07-14 09:51:30 -05:00
Seth Jennings
daa8762346 Merge pull request #307 from flaming-toast/kpatch-unload
kpatch: pass basename of argument to unload_module
2014-07-14 09:00:28 -05:00
Seth Jennings
60efcbd63e Merge pull request #301 from jpoimboe/debug-seg-fault
create-diff-object: fix for unincluded sec->secsym
2014-07-14 08:51:05 -05:00
Seth Jennings
ad82576f4c Merge pull request #308 from jpoimboe/readme-videos
readme: add links to more videos
2014-07-14 08:50:19 -05:00
Josh Poimboeuf
4d1ea6f4d1 readme: add links to more videos 2014-07-11 09:54:25 -05:00
Jessica Yu
5e1062cf29 kpatch: pass basename of argument to unload_module 2014-07-10 22:15:12 -07:00
Seth Jennings
f5189d815f Merge pull request #305 from jpoimboe/force-prevent-rmmod
prevent rmmod of forced modules
2014-07-09 22:57:30 -05:00
Josh Poimboeuf
40fbb4effc code review fix
Return 0 on rmmod error.
2014-07-09 22:41:02 -05:00
Josh Poimboeuf
e1890e627a prevent rmmod of forced modules
I found a bad bug:

- Module A is loaded, and registers function foo() with
  KPATCH_FORCE_UNSAFE.
- Module A is unloaded.  The new version of foo() is on the backtrace of
  a task, but the core module ignores it because of the force flag, so
  the unloading succeeds.
- The task returns to the new version of foo() which no longer exists.
- BOOM.

The only way I can think of to prevent this scenario is to prevent
forced modules from being unloaded (but still allow them to be
disabled).

An annoying side effect of this approach is that forced modules stay
loaded and in memory forever.  And that after "kpatch unload" of a
forced module, you can't ever load it again because the previous
instance of it is still loaded (but permanently disabled).

This is ugly but I can't really think of a better way to handle it.  If
necessary we could create a workqueue and periodically check to see if
we can safely call module_put() so that the module could be eventually
removed.
2014-07-09 22:16:29 -05:00
Seth Jennings
6c926a7692 Merge pull request #302 from goldyfruit/master
README.md: add debian support
2014-07-09 15:47:09 -05:00
Seth Jennings
d436576346 Merge pull request #304 from jpoimboe/force-fix
kmod/core: check force flag in replace case
2014-07-09 15:45:47 -05:00
Josh Poimboeuf
dfc759227a kmod/core: check force flag in replace case
When unpatching a function due to "kpatch replace", check the force flag
before doing the activeness safety check.
2014-07-09 15:06:57 -05:00
Josh Poimboeuf
57b51d0bdc add KPATCH_WARN_*_LINE macros
WARN macros are problematic because they embed the line number in an
instruction.  As a result, when a function is changed higher in a file,
the line numbers for any WARN calls below that function in the file can
result in unnecessarily changed functions.

These macros allow a patch author to hard code the line numbers in WARN
macros to prevent functions from otherwise changing and getting pulled
into a patch module unnecessarily.
2014-07-09 10:39:07 -05:00
Gaetan Trellu
dfa19166b3 README.md: add build-essential package 2014-07-08 13:25:29 -04:00
Gaetan Trellu
9dadc6ef2e README.md: add debian support 2014-07-08 13:21:47 -04:00
Josh Poimboeuf
4fefa662fd create-diff-object: fix for unincluded sec->secsym
When running kpatch-build with -d, I was getting a seg fault.  It was
faulting in kpatch_dump_kelf() when trying to print sec->secsym->name
for the .smp_locks section.  It turns out that the section was included
but its section symbol wasn't included, so sec->secsym pointed to freed
memory.
2014-07-08 08:12:34 -05:00
Josh Poimboeuf
6f38498d95 Merge pull request #299 from useidel/master
Rebase of SPEC file to current version
2014-07-07 21:09:54 -05:00
Seth Jennings
44ad2ba733 Merge pull request #298 from jpoimboe/no-fentry-dynrela
create-diff-object: don't create __fentry__ dynrelas
2014-07-07 21:02:50 -05:00
Seth Jennings
322b9b99ba Merge pull request #300 from jpoimboe/gcc-version-readelf
kpatch-build: extract GCC version from .comment section
2014-07-07 21:01:18 -05:00
Josh Poimboeuf
ddf4836466 kpatch-build: extract GCC version from .comment section
Extract the GCC version from the .comment section of vmlinux.  This
hopefully makes the version check more robust across various distros.

Fixes #297.
2014-07-07 20:54:57 -05:00
Udo Seidel
5c7630ee76 Rebase of SPEC file to current version 2014-07-07 22:08:54 +02:00
Josh Poimboeuf
e847026824 create-diff-object: don't create __fentry__ dynrelas
This fixes the following issue for a patch which changes a module:

  kpatch_create_mcount_sections: 1968: bad first rela in .rela.text.e_show

The first rela is "bad" because the real first rela was converted to a
dynrela and then removed from the rela list.

This is a temporary fix.  The more permanent fix should be to allow
lookups in vmlinux for patched modules so we don't create any
unnecessary dynrelas.
2014-07-07 14:03:02 -05:00
Seth Jennings
690385a37d Merge pull request #294 from jpoimboe/custom-rpmbuild-dir
kpatch-build: support custom ~/.rpmmacros file
2014-07-03 09:22:52 -05:00