Commit Graph

867 Commits

Author SHA1 Message Date
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
Josh Poimboeuf
817d3746b4 kpatch-build: support custom ~/.rpmmacros file
Be able to deal with a custom ~/.rpmmacros file, for which the SPECS and
BUILD directories are configurable.
2014-07-03 09:16:49 -05:00
Josh Poimboeuf
11cac52533 Merge pull request #293 from spartacus06/support-forced-patching
support forced patching
2014-07-02 14:13:25 -05:00
Seth Jennings
2e93c5e1e3 support forced patching
Some functions in the kernel are always on the stack of some thread
in the system.  Attempts to patch these function will currently always
fail the activeness safety check.

However, through human inspection, it can be determined that, for a
particular function, consistency is maintained even if the old and new
versions of the function run concurrently.

This commit introduces a KPATCH_FORCE_UNSAFE() macro to define patched
functions that such be exempted from the activeness safety check.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-02 14:06:33 -05:00
Seth Jennings
6b428eec2f Merge pull request #291 from jpoimboe/gcc-ubuntu
kpatch-build: fix gcc version check on ubuntu
2014-07-02 08:35:19 -05:00
Josh Poimboeuf
dda01a5a1d Merge pull request #290 from goldyfruit/master
kpatch-build: use getconf to get the processors number
2014-07-02 06:21:12 -05:00
Josh Poimboeuf
5893a28fdf kpatch-build: fix gcc version check on ubuntu 2014-07-02 06:17:59 -05:00
Gaetan Trellu
9d72c76b1a kpatch-build: use getconf to get the processors number 2014-07-01 22:18:16 -04:00
Josh Poimboeuf
aaf1bf3e8e Merge pull request #288 from spartacus06/section-create-refactor
consolidate new section pair creation
2014-07-01 16:27:06 -05:00
Seth Jennings
1f17adec07 consolidate new section pair creation
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-01 16:00:51 -05:00
Seth Jennings
94ec430201 Merge pull request #286 from jpoimboe/check-gcc-version
kpatch-build: gcc version checks
2014-07-01 15:07:55 -05:00
Josh Poimboeuf
73171714bc kpatch-build: gcc version checks
Ensure the version of the locally installed gcc matches the one used to
compile the kernel, and is >= 4.8.

Fixes #246.
2014-07-01 14:24:53 -05:00
Seth Jennings
fd637ce542 Merge pull request #285 from goldyfruit/master
kpatch-build: add debian support
2014-07-01 14:02:57 -05:00
Gaetan Trellu
4e3b4825ad kpatch-build: merge the ubuntu and debian section 2014-07-01 14:41:57 -04:00
Josh Poimboeuf
df679e3192 Merge pull request #278 from spartacus06/user-hook-support-v2
add user-defined load/unload hook support
2014-07-01 13:09:33 -05:00
Seth Jennings
d4e4d14dbe fixup review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-01 12:22:16 -05:00
Seth Jennings
1ebae501ba Merge pull request #283 from jpoimboe/mcount
create-diff-object: create __mcount_loc section
2014-07-01 11:10:59 -05:00
Josh Poimboeuf
d2201980e6 kmod/core: ftrace function_graph tracer compatibility
Steven Rostedt recommended to return "regs->ip + MCOUNT_INSN_SIZE",
which is what the function_graph tracer expects.  This fixes
function_graph tracing for a patched function.

This change also means that the function tracer will only show the
patched function once (corresponding to a trace of the original
function) rather than twice.  This is probably more in line with what a
user would expect.
2014-07-01 10:16:38 -05:00
Gaetan Trellu
d341e3237e kpatch-build: fix SUBLEVEL in the Makefile 2014-07-01 11:16:23 -04:00
Gaetan Trellu
0459810dd3 kpatch-build: add debian support 2014-07-01 10:55:43 -04:00
Seth Jennings
cae31c410b Merge pull request #284 from jpoimboe/ftrace-unregister-order
kmod/core: fix ftrace unregister order
2014-07-01 09:33:26 -05:00
Josh Poimboeuf
2dbae9ae42 kmod/core: fix ftrace unregister order
Currently, when removing a patch module, the ftrace buffer gets flooded
with traces.  This happens because we're clearing the ftrace ops filter
before unregistering the ops, which creates a small window where all
functions are being traced.

We should be doing the unregistering in the reverse order in which we
registered, meaning ops should be unregistered and _then_ the filter
should be cleared.
2014-07-01 08:52:59 -05:00
Josh Poimboeuf
79bd9f03ee create-diff-object: create __mcount_loc section
For ftrace to be able to trace a patched function, it requires that the
__mcount_loc section contains a pointer to the function, and that the
first instruction of the function is "callq __fentry__".

Normally that work is done by the recordmcount script, but it ignores
functions that aren't in a few standard sections (.text and a few
others).
2014-07-01 08:29:37 -05:00
Josh Poimboeuf
d3550bfc3a Merge pull request #282 from goldyfruit/master
core.c: add check to be sure that the kernel run with CONFIG_KALLSYMS_AL...
2014-06-30 21:28:19 -05:00