Commit Graph

213 Commits

Author SHA1 Message Date
Joe Lawrence
54268bfb3e integration: update gcc-static-local-var-4.test
The gcc-static-local-var-4.patch and test check that unmodified
functions that contain dynamic debugging printk's aren't incorrectly
included in the resulting livepatch .ko.

Note that on RHEL-7.7 ppc64le, the gcc-static-local-var-4.ko livepatch
module may include klp-relocation references to free_ioctx(), a function
that would match the above criteria.  These klp-relocation symbols are
OK as they are only used for referencing said functions, they are not
copies that the check should FAIL on.

Modify gcc-static-local-var-4.test in a few ways:

  - Use eu-readelf instead of readelf, which some versions have problems
    handling klp-relocations.

  - Set pipefail to catch any errors in the symbol table dump (missing
    elfutils, etc.)

  - Instead of a grep regex, use awk to string compare exact function
    and module names.  This avoids matching on .klp.sym prefixed
    klp-relocation symbols.

Fixes #1069.
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-02-14 16:09:37 -05:00
Artem Savkov
272761dd3a integration/Makefile: fix a typo
"vagrant" target's should be 'vagrant-quick', not 'vagrant_quick'.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:46 +01:00
Artem Savkov
3280e8e0e9 Add support for specific commits in vagrant
Relay KPATCH_GIT and KPATCH_REV into vagrant so it can checkout
specified repo/commit.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:46 +01:00
Artem Savkov
f9e4399309 Fix kmod build for fedoras before fc30
We recently disabled building kmod by default, make sure fedora-27 (and
others before fc30) integration tests still build that.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:46 +01:00
Artem Savkov
a48fb4a6f6 integration: rhel-7.6 and 7.7 module-call-external fix unsupported sibling call
These patches cause the following error on ppc64le on both 7.7 and 7.6:
create-diff-object: ERROR: export.o: kpatch_no_sibling_calls_ppc64le: 3290: Found an unsupported sibling call at e_show()+0x100.  Add __attribute__((optimize("-fno-optimize-sibling-calls"))) to e_show() definition.

Adding -fno-optimize-sibling-calls breaks build on x86_64, so limit it
to ppc64le only.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:35 +01:00
Artem Savkov
68c04e8282 integration: disable rhel8/macro-printk
This is supposedly fixed by #1053 and should be re-enabled when it is
merged.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:25 +01:00
Artem Savkov
6f570059ec integration: disable rhel8/gcc-static-local-var-5
This is supposedly fixed by #1054 and should be reinabled once that is
merged.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:25 +01:00
Artem Savkov
94156bed45 integration: disable tests with jump labels
Disabled due to #940. Please re-enable this test once it is fixed.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:25 +01:00
Artem Savkov
c1d5cc47d7 Fix epel ccache installation
ccache version in epel updates from time to time so instead of
using a direct link install epel repo and install ccache without
specifying the version.

Suggested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-01-24 10:37:21 +01:00
Josh Poimboeuf
34a45ba847
Merge pull request #993 from kamalesh-babulal/r8-test-rebase
test/integration: Rebase to RHEL 8.0
2020-01-15 09:11:45 -06:00
Julien Thierry
54553c0622 test/unit: Update unit test submodule
Include test for mangled symbol modification.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-11-01 07:37:54 +00:00
Julien Thierry
0c96fd0968 test/integration: Fix RHEL-8 test new-function for ppc64le
new-function test fails on ppc64le with the following message:

create-diff-object: ERROR: n_tty.o: kpatch_no_sibling_calls_ppc64le: 3445: Found an unsupported sibling call at n_tty_write()+0x20.  Add __attribute__((optimize("-fno-optimize-sibling-calls"))) to n_tty_write() definition.

Add the suggested attribute, as was done for rhel-7.[5-7] versions of
the test.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:49:24 +00:00
Julien Thierry
6943128ceb test/integration: Disable test affecting jump label on ppcle64
On ppcle64, test gcc-static-local-var-4 impacts a jump label reference
which is currently unsupported.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:49:24 +00:00
Julien Thierry
4710df3c78 test/integration: Disable RHEL-8.0 tests using jump labels
Jump labels are unsupported, so tests modifying functions using them are
expected to fail. So disable them, for now...

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:49:24 +00:00
Kamalesh Babulal
f42a4127f5 test/integration: Rebase to RHEL 8.0
Rebase the integration test cases on top of RHEL 8.0 kernel version
4.18.0-80.el8.

Suggested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
[JT: adapt data-new-LOADED to new meminfo format,
     use common template for multiple.test]
Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-31 12:49:24 +00:00
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