Commit Graph

516 Commits

Author SHA1 Message Date
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
Seth Jennings
38b7ac74ad 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>
2014-05-15 13:26:41 -05:00
Seth Jennings
108cd9f95e cleanup: remove unneeded patches variable
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-14 14:04:54 -05:00
Seth Jennings
d55523f624 Merge pull request #184 from jpoimboe/kb-os-release
kpatch-build: check distro in /etc/os-release
2014-05-13 15:38:06 -05:00
Josh Poimboeuf
e1305886c7 kpatch-build: check distro in /etc/os-release
/etc/issue isn't valid in RHEL 7 RC.  The official way to query the
distro seems to be /etc/os-release.
2014-05-13 15:33:00 -05:00
Seth Jennings
783985a9d7 Merge pull request #183 from jpoimboe/modules-extra
kmod: install core module to "extra" subdir
2014-05-13 15:25:16 -05:00
Josh Poimboeuf
a6694fffff kmod: install core module to "extra" subdir
To be more consistent with other out-of-tree modules, install the core
module to /usr[/local]/lib/modules/`uname -r`/extra/kpatch/kpatch.ko.
2014-05-13 15:10:40 -05:00
Josh Poimboeuf
5ea376a47a Merge pull request #181 from spartacus06/interface-refactor
refactor core <-> patch interface
2014-05-12 15:43:26 -05:00
Josh Poimboeuf
f5b442c50f Merge pull request #182 from spartacus06/fix-warning
fix incompatible pointer type warning
2014-05-12 15:38:01 -05:00
Seth Jennings
e5f17c6b9a fix incompatible pointer type warning
Fixes the following warning:

kpatch-patch-hook.c:71:2: warning: initialization from incompatible pointer type [enabled by default]
  __ATTR(enabled, 0644, patch_enabled_show, patch_enabled_store);
  ^

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-12 15:20:09 -05:00
Seth Jennings
681a6e80b9 refactor core <-> patch interface
Make kpatch_funs truly internal by:
Defining it in core.c
Adding a struct kpatch_internal, declared in kpatch.h and defined in
 core.c, that contains per patch module internal data.
Adding an "internal" field to struct kpatch_modules.
Allocating internal and funcs data in core.c, not in the patch module,
 since the patch module has no knowledge of kpatch_func anymore.
Adding a "patch" field to kpatch_func that points directly to the
 kpatch_patch provided by the module (rather than a field-by-field copy)

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-12 14:58:29 -05:00
Josh Poimboeuf
a3efb7e1aa Merge pull request #177 from spartacus06/linked-list
convert core data structures from arrays to linked-lists
2014-05-12 09:23:36 -05:00
Seth Jennings
a78bb8bcb3 cleanup logic in rela comparison
Per review comments.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-12 08:48:33 -05:00
Seth Jennings
207c237e48 fixup review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-09 23:42:11 -05:00
Seth Jennings
c34f4c23e0 Merge pull request #179 from jpoimboe/modprobe-core-module
kpatch: try to modprobe core module
2014-05-09 23:24:42 -05:00
Josh Poimboeuf
ac8a54e535 kpatch: try to modprobe core module
Try to modprobe the core module, for systems that have the core module
properly installed with depmod.
2014-05-09 20:24:26 -05:00
Seth Jennings
20c7882d93 remove temporary debug message
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-07 11:18:54 -05:00
Seth Jennings
08dbc37c75 add null symbol to inventory files
Add the null symbol to in inventory files.  Before the linked-link
change, the null symbol wasn't included in the inventory.  However,
it is required to be a valid ELF file and should be inventoried and
check for in the test.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-07 10:16:39 -05:00
Seth Jennings
5d36dd1c32 convert from arrays to linked-lists
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-05-07 10:06:41 -05:00
Josh Poimboeuf
a7dc43ab24 Merge pull request #176 from ryanmiao/for-pr-141
Fix kpatch.ko build on Ubuntu Saucy.
2014-05-07 09:54:57 -05:00
Jincheng Miao
171cd567ce Fix kpatch.ko build on Ubuntu Saucy.
The error likes:
make -C /lib/modules/3.11.0-12-generic/build M=/home/ryan/kpatch/kmod/core kpatch.ko
make[3]: Entering directory `/usr/src/linux-headers-3.11.0-12-generic'
  CC [M]  /home/ryan/kpatch/kmod/core/core.o
/home/ryan/kpatch/kmod/core/core.c:42:32: fatal error: linux/preempt_mask.h: No such file or directory
 #include <linux/preempt_mask.h>

I feel sorry to introduce this problem from my laster commit 6c2d6444.
Some old kernel doesn't have header file preempt_mask.h, and the safe
way is using hardirq.h to find in_nmi().

Signed-off-by: Jincheng Miao <jincheng.miao@gmail.com>
2014-05-07 17:48:02 +08:00
Seth Jennings
135b438af0 Merge pull request #175 from jpoimboe/kpatch-list
kpatch: show loaded modules in list command
2014-05-06 14:02:55 -05:00
Josh Poimboeuf
49f832c2b9 kpatch: change "patches" to "patch modules" in list 2014-05-06 12:53:45 -05:00
Josh Poimboeuf
10004a9e6e kpatch: list loaded modules 2014-05-06 12:52:00 -05:00
Seth Jennings
74fb803eac Merge pull request #173 from madper/dracut-fix
Add dirname to initramfs
2014-05-06 08:51:25 -05:00
Madper Xie
b74395c537 Add dirname to initramfs
kpatch script need dirname to git SCRIPTDIR. But dracut won't copy it to
initramfs by default.

Signed-off-by: Madper Xie <cxie@redhat.com>
2014-05-06 17:43:49 +08:00
Josh Poimboeuf
c41319e1a5 Merge pull request #172 from jpoimboe/integration-tests
add more integration tests
2014-05-05 20:05:03 -05:00
Josh Poimboeuf
b541692061 test: add test for loading multiple modules 2014-05-05 20:03:57 -05:00
Josh Poimboeuf
1fced0bc3d test: fix unload_all 2014-05-05 20:03:57 -05:00
Josh Poimboeuf
df2e2daa92 test: send status messages to log file 2014-05-05 20:03:54 -05:00
Josh Poimboeuf
100f358b1d test: fix custom test error condition check 2014-05-05 17:05:49 -05:00
Josh Poimboeuf
bcbc9d3109 test: make .init sections can't be changed 2014-05-05 17:05:49 -05:00
Josh Poimboeuf
7c60dcf2a3 test: make output messages easier to read 2014-05-05 17:05:49 -05:00
Josh Poimboeuf
46786dad93 test: add custom test for kpatch replace 2014-05-05 17:05:44 -05:00
Josh Poimboeuf
757120d8a0 test: add meminfo-cmdline test 2014-05-05 16:05:00 -05:00
Josh Poimboeuf
a0c9aff4cc test: fix uninitialized skip variable 2014-05-05 16:05:00 -05:00
Josh Poimboeuf
3ae6bc46ff test: add cmdline-string test 2014-05-05 16:05:00 -05:00
Josh Poimboeuf
d3aee7c734 test: test 'kpatch reload' and cleanup between tests 2014-05-05 16:04:58 -05:00
Seth Jennings
3866aeab03 Merge pull request #171 from jpoimboe/style
kmod/core: minor style fix
2014-05-05 14:01:00 -05:00
Josh Poimboeuf
ab112cce2d kmod/core: minor style fix
For compatibility with checkpatch
2014-05-05 13:40:42 -05:00
Seth Jennings
66cab1d4a2 Merge pull request #170 from jpoimboe/module-special-chars
kpatch-build: replace special characters in module name
2014-05-05 11:10:47 -05:00
Josh Poimboeuf
5e4ac36253 kpatch-build: replace special characters in module name
Having a '.' in the kmod name confuses lsmod, which prints "Size" and
"Used by" values of -2.  Prevent any special characters other than '_'
and '-', so that our patch module names will be consistent with typical
kmod names.
2014-05-05 11:07:35 -05:00
Seth Jennings
2adb1d6837 Merge pull request #168 from jpoimboe/readme-patch-example
readme: give a more concrete patch example
2014-05-05 09:01:52 -05:00