Commit Graph

198 Commits

Author SHA1 Message Date
Julien Thierry
0f648b8056 test/integration: Skip disabled tests for combined test
Disabled patches won't trigger a build, but the combined load test
will still attempt to run their associated LOADED.test script. The
combined test will fail due to voluntarily disabled tests.

Do not run tests scripts associated with disabled tests.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:47:01 +00:00
Julien Thierry
4aa909eb8f test/integration: Skip disabled tests in multiple.test
Tests intentionaly disabled should be skipped by multiple.test

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:47:01 +00:00
Julien Thierry
c9a4e09b45 test/integration: Fix kpatch-test module unloading
The unload_all() function in kpatch-test script is out dated and
does not unload patches loaded through livepatching.

Luckily, "kpatch unload --all" should support both kpatch unloading
kpatch patches and livepatch patches.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-08 08:32:42 +01:00
Julien Thierry
e59355c2b7 test/integration: Make multiple.test cleanup after itself
If an error occurs while loading a module or one of the tests,
multiple.test will exit leaving the working modules loaded. This leaves
the system in an unwanted state and causes the test that previously pass
to fail (succeeding before being loaded for multiple.test's point of
view).

Cleanup the loaded modules before exiting due to errors.

Also take this opportunity to factorize the test for the different
distros.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-08 08:31:39 +01:00
Josh Poimboeuf
935f199875 create-diff-object: simplify mangled function correlation
The RHEL powerpc kernel is compiled with -O3, which triggers some
"interesting" new optimizations.  One of them, which seems to be
relatively common, is the replacing of a function with two separate
"constprop" functions.

Previously we only ever saw a single constprop clone, so we just renamed
the patched version of the function to match the original version.  Now
that we can have two such clones, that no longer makes sense.

Instead of renaming functions, just improve the correlation logic such
that they can be correlated despite having slightly different symbol
names.  The first clone in the original object is correlated with the
first clone in the patched object; the second clone is correlated with
the second clone; and so on.

This assumes that the order of the symbols and sections doesn't change,
which seems to be a reasonable assumption based on past experience with
the compiler.  Otherwise it will just unnecessarily mark the cloned
constprop functions as changed, which is annoying but harmless, and
noticeable by a human anyway.

Fixes #935.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-10-03 09:38:29 -05:00
Artem Savkov
52d4936e72 integration/rhel-*: fix multiple.test
When these from internal depths of Red Hat upstream paths changed and
now we are one level deeper in directory tree.

The issue probably also exist in rhel8.0 rebase pr #993.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-09-18 12:29:50 +02:00
Artem Savkov
f6fd787468 test/integration: add an ability to check specific repo/commit
Add an ability to run vagrant integration tests on specified
repos/commits.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-08-22 15:31:11 +02:00
Joe Lawrence
2e9cfa2fb3
Merge pull request #1027 from jpoimboe/ignore-descriptor-static-key
create-diff-object: allow dynamic debug static keys
2019-08-19 10:50:13 -04:00
Josh Poimboeuf
2975775768 create-diff-object: allow dynamic debug static keys
While static keys (jump labels) are currently broken in livepatch, a
broken dynamic debug static key is harmless since it just disables
dynamically enabled debug printks in the patched code.

Fixes: #1021

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-08-15 16:01:55 -05:00
Josh Poimboeuf
2fede60e8f
Merge pull request #1019 from sm00th/integration_7_7
test/integration: add  rhel-7.7 rebased patches
2019-08-14 10:40:24 -05:00
Joe Lawrence
b3ea0171ff test: remove testmod/
Remove test/testmod/ as it has been unmaintained for years now.

Fixes: issue #1017

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-08-13 11:50:40 -04:00
Artem Savkov
0e0cee369a test/integration: add rhel-7.7 rebased patches
Added integration-test patches rebased against rhel-7.7 GA kernel. No
conflicts, some fuzz.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-08-12 14:36:16 +02:00
Artem Savkov
e2fdd33d4f tests/integration: fix dependency ccache on centos 7
Standard centos7 repos don't contain ccache so we have to install it
from epel just like we do on rhel7.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-08-09 16:31:19 +02:00
Josh Poimboeuf
c6259d898c
Merge pull request #1006 from sm00th/unit_fail
tests/unit: fix inconsistent FAIL test failures
2019-07-24 09:58:14 -05:00
Josh Poimboeuf
cef3360936 test/unit: Add unit test for ppc64le bundle replace_sections_syms()
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-23 18:11:54 -05:00
Josh Poimboeuf
9101ca99ef test/unit: update ppc64le tests for jump labels and sibling calls 2019-07-23 11:11:29 -05:00
Josh Poimboeuf
0e57bb0236 test/integration: disable sibling calls in failing integration tests
Now that sibling calls aren't supported in ppc64le, change the RHEL 7.5
and 7.6 versions of the new-function tests to disable the sibling call
optimization.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-23 11:11:29 -05:00
Artem Savkov
8c6a031cdb tests/unit: fix inconsistent FAIL test failures
Use make's .DELETE_ON_ERROR special target to make sure we don't have
any .OUTPUT.o leftovers for failed tests.

Fixes: #999

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-07-23 10:57:43 +02:00
Josh Poimboeuf
64f07c6c72 test/unit: Fix symtab generation for ppc64le
The ppc64le unit tests are failing because the lookup code is getting
confused by the "[<localentry>: 8]" string in the readelf symbol table
output.

Remove the string so the lookup code can parse it correctly.
kpatch-build already uses the same sed, so they should match.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-22 14:48:25 -05:00
Josh Poimboeuf
ef98dd7544 test/unit: Bump unit tests to latest
Needed to make the unit tests pass again after adding jump label error
detection.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-17 09:03:17 -05:00
Josh Poimboeuf
b7edef7360 test/unit: Fix env override for Make 3.x
Make 3.8 doesn't support the "file" function, which is used by the unit
test Makefile to output the contents of a custom env file, if one
exists.  Use shell instead.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-16 21:58:41 -05:00
Josh Poimboeuf
9940c1d5a1 test/unit: add test object file for #990
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-16 16:16:24 -05:00
Josh Poimboeuf
20b7ab02c4 test/unit: Don't automatically rebase submodule
"make unit" automatically rebases the submodule, which causes a lot of
surprises.  Instead, just print a warning if it's out of date.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-15 18:49:00 -05:00
Josh Poimboeuf
3b936efa10 test/unit: add test object files for #975
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-15 18:11:48 -05:00
Josh Poimboeuf
946f636ca5 Remove convert-global-local integration test
This test is no longer needed.  I had previously converted it to a unit
test and forgot to remove its integration test counterpart.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-07-05 16:22:25 -05:00
Artem Savkov
76ebcd2fa4 test/integration: add patches rebased for recent rhel minor releases
This commit contains centos-7 patches rebased and adjusted to work with
recent rhel minors so that integration tests actually pass on those.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-06-14 10:53:57 +02:00
chenzefeng
d91b416b00 test: use readelf instead of eu-readelf
readelf is more standard, using readelf insteaded

test/difftree.sh: the symbol name may be with "FILE", which may be
get a incorrect count, here add "awk".

test/unit/Makefile.include: use "readelf -s --wide" instead of
"eu-readelf -s".

Signed-off-by: chenzefeng <chenzefeng2@huawei.com>
2019-05-30 17:45:44 +08:00
Artem Savkov
5dfe17cb02 Update fixup-section patches
These patches previously would try to dereference a userspace pointer
directly which can cause issue on some systems. Since the aim of these
patches is to check fixup section changes we can don't need to do any
meaningful changes to the function, so change the patches to just add
asm("nop") instead.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-05-15 10:28:45 +02:00
Joe Lawrence
7dff9b5f6a unit-tests: include oot-issue-928 objects
Add object files that verify kpatch issue #928.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-02-22 10:50:55 -05:00
Joe Lawrence
ccd0615407 test/unit: relax stripped object requirement
Some unit tests may need debug symbols to reproduce problems (see
issue #928 for example), so skip the unit-test Makefile.include
check_stripped call for objects that include "NOSTRIP" in their
filename.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-02-22 10:49:54 -05:00
Josh Poimboeuf
09ee03f3df Revert "create-diff-object: add jump label support"
This reverts commit 87c64519fc.

The jump label support doesn't work with upstream livepatch.  Joe
Lawrence found the following ordering issue:

load_module

  apply_relocations

    /* Livepatch relocation sections are applied by livepatch */
    if (info->sechdrs[i].sh_flags & SHF_RELA_LIVEPATCH)
            continue;

  post_relocation
    module_finalize
      jump_label_apply_nops        << crash

  ...

  do_init_module
    do_one_initcall(mod->init)
      __init patch_init [kpatch-patch]
        klp_register_patch
          klp_init_patch
            klp_init_object
              klp_init_object_loaded
                klp_write_object_relocations

So jump_label_apply_nops() is called *before*
klp_write_object_relocations() has had a chance to write the klp
relocations (.klp.rela.kvm_intel.__jump_table, for example).

We need to resolve this upstream first.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-02-19 16:10:54 -06:00
Joe Lawrence
a16c003d88
Merge pull request #937 from jpoimboe/jump-tables
Add jump label support
2019-02-11 13:47:36 -05:00
Josh Poimboeuf
87c64519fc create-diff-object: add jump label support
Add support for jump labels, also known as static jumps, static keys,
static branches, and jump tables.  Luckily,
kpatch_process_special_sections() is already generic enough to make this
an easy fix.

Fixes: #931

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-02-08 13:45:38 -06:00
Artem Savkov
e94bba2b94 test/unit: add support for .env files
Add support for optional <test-name>.env files that contain additional
environment variables. This can also be used to override per-arch env
vars we have because last value assigned will be used.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-02-08 15:16:17 +01:00
Artem Savkov
56be80720a integration/centos-7: fix shadow-newpid.patch warnings
When quickly loading/unloading this patch multiple times it is possible
to hit "Duplicate shadow variable" warnings since the patch doesn't have
any cleanup hooks on unload.
Switch to klp_shadow_get_or_alloc to ignore these.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-28 17:19:45 +01:00
Artem Savkov
fb11c794f2 integration: blacklists in multiple.test
Hardcode a blacklist of modules in multiple.test so we can deal
with conflicts while only updating the test when those arise.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-17 09:26:35 +01:00
Artem Savkov
70f9221c01 integration: dynamic module list in multiple.test
Dynamically compile module list based on -LOADED.test files in all
multiple.test scripts.
The scripts is now the same across all three directories so it might be
good to deduplicate it somehow along with other common tests.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-14 21:29:32 +01:00
Artem Savkov
7c774350fc integration: save dmesg on detected errors
Dump dmesg to dmesg.log when detecting a call trace.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-14 12:20:43 +01:00
Artem Savkov
a3afc831e2 integration/vm-integration-run: explain src manipulations
Add a comment to explain predownloaded kernel sources manipulations in
vm-integration-run.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-14 12:08:45 +01:00
Artem Savkov
992ea01625 integration/centos-7: reverse unload in multiple.test
Livepatch requires modules to be unloaded in reverse order.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 11:46:08 +01:00
Artem Savkov
c39a48a606 integration: temporary disable ubuntu1604
ubuntu1604's kernel is a 4.4 with backported livepatch witch confuses
kpatch-build and livepatch-patch-hook.c. Integration tests currently
fail on load/unload stage. Disabling all ubuntu integration tests until
this is resolved.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:34:13 +01:00
Artem Savkov
28a18efa21 integration/centos7: update shadow-newpid.patch
Switch to klp shadow-variable API.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:34:13 +01:00
Artem Savkov
31f6b02279 integration/centos7: update module-shadow.patch
Switch to klp shadow-variable API.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:34:13 +01:00
Artem Savkov
abe04af23a integration/centos7: disable rebuild-SLOW patch
It currently hits CSWTITCH issue from https://github.com/dynup/kpatch/issues/876

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:34:06 +01:00
Artem Savkov
f2b226ad37 integration/centos7: update macro-printk.patch
Rebase macro-printk.patch on top of 3.10.0-957.1.3.el7.x86_64 used in
centos7 vagrant image.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:32:49 +01:00
Artem Savkov
3478a85459 integration/centos7: fix module prefixes
Modules were previously prefixed with either 'kpatch-' or 'livepatch-'
depending on which was used. This is no longer true and all modules are
now prefixed with "test-". Update test scripts accordingly.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:32:49 +01:00
Artem Savkov
baa1355447 integration/ubuntu1604: fix module prefixes
Modules were previously prefixed with either 'kpatch-' or 'livepatch-'
depending on which was used. This is no longer true and all modules are
now prefixed with "test-". Update test scripts accordingly.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:32:49 +01:00
Artem Savkov
77304f60ce integration/ubuntu1604: remove shadow-variable patches
The kernel used in ubuntu1604 vagrant image does not have shadow
variable API.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:32:20 +01:00
Artem Savkov
14f7367e45 integration/ubuntu1604: disable module-call-external.patch
Original build includes "kzalloc" in af_netlink.c's symbol list, this
does not happen during kpatch build so create-diff-object fails with
find_local_syms.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:32:04 +01:00
Artem Savkov
9cd7eb224a integration/ubuntu1604: temporary disable -SLOW patch
kpatch-build currently fails with "invalid ancestor" error. This happens
with at least drivers/gpu/drm/i2c/adv7511.o and drivers/hwmon/htu21.o
files. The problem is their .ko counterparts are never built for some
reason, This looks like a kernel bug since in both cases there are files
with same name but in different paths that have .ko module built.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2019-01-11 10:30:43 +01:00