Commit Graph

259 Commits

Author SHA1 Message Date
Joe Lawrence
eccf6bf566 test/integration: add rhel-7.9
Rebased against kernel-3.10.0-1160.el7.

data-read-mostly.patch.disabled remains disabled as we hit several build
errors like:

  "Found a jump label at __netif_receive_skb_core()+0x50, using key
  netstamp_needed.  Jump labels aren't supported with this kernel.  Use
  static_key_enabled() instead."

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-09-04 13:57:02 -04:00
Julien Thierry
11df5340c9 test/integration: Add integration tests for symvers disagreement
Add a RHEL reproducer that causes a kpatch-build to fail when the final
module references a symbol with a different CRC than the original
kernel.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-08-17 12:38:32 +01:00
Joe Lawrence
de1d0c6e08 kpatch-test: don't clear dmesg during test
The kpatch-test script clears the kernel log buffer to distinguish
between old and new dmesg entries.  Wiping out the old buffer may
surprise some users, but isn't too hard to avoid:

  - save the last dmesg line
  - run the tests
  - filter out old dmesg lines until after finding the saved entry
    - if no saved entry is found, the buffer most likely overflowed
      - inform the user to increase the log size

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-07-30 14:59:32 -04:00
Joe Lawrence
d76110ed24 kpatch-test: clear dmesg just before tests commence
Defer clearing the kernel buffer until we're ready to start the tests,
otherwise we increase the likelihood of catching stray errors while
we're building the modules and preparing the tests.

Fixes #1133 ("kpatch-test should ignore older kernel log messages")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-07-30 14:58:31 -04:00
Artem Savkov
104d835342 test/integration: centos-8 support
Add centos-8 as a symlink to latest rhel-8.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-07-22 11:16:09 +02:00
Evgenii Shatokhin
78f2c063ae kpatch-test: make it easier to use custom kpatch and kpatch-build commands
The commands used to build the livepatches and to load or unload them
are currently hard-coded in kpatch-test.

This patch adds 2 options to kpatch-test to make it easier to use custom
kpatch and kpatch-build commands:

*  --system-kpatch-tools - if set, 'sudo kpatch' will be used to
load/unload the patches; 'kpatch-build' - to build them.

To use custom tools here, the user can adjust $PATH.

If the option is not set, kpatch-test will assume it is in kpatch source
tree, same as before this commit, and will use the tools from there.

* --kpatch-build-opts="..." - additional options to pass to
kpatch-build.

Example:

  ./kpatch-test \
    --system-kpatch-tools \
    --kpatch-build-opts="-s ./linux-src -c ./config -v ./vmlinux" \
    -d my_kpatch_tests/test/integration/v01

In this case, kpatch and kpatch-build installed in the system will be used,
and kpatch-build will look for the kernel source tree, configuration
file and vmlinux binary in the current directory.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2020-07-16 20:36:23 +03:00
Yannick Cote
62cd3efc57
Merge pull request #1118 from sm00th/ddbg-fix
Don't enable dynamic debug during integration tests on older rhels
2020-06-30 18:46:52 -04:00
Josh Poimboeuf
4d75b26fe5 test/unit: Update to latest tests
Update master to use the latest tests for #1091 and #1102.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2020-06-30 17:03:48 -05:00
Artem Savkov
3fc97d75c3 Don't enable dynamic debug during integration tests on older rhels
RHELs older than 7.7 are missing 5279631271b3 "module: fix ddebug_remove_module()"
which leads to a crash if dynamic debug is used with livepatching.
Disable recent dynamic debug addition on those distros.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-06-30 11:48:28 +02:00
Julien Thierry
22e2c1a95c test: Ignore remaining quoting warnings
Fixing the remaining warnings suggesting to quote the output subshell
invocation would hinder readability. Also the results of dirname and
"type -p" used in the subshell should return spaceless strings in kpatch
usecases.

Ignore the warnings for now.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
e906db9b81 test: Fix shellcheck quoting issues
It wouldn't be bash without pondering over what to quote or not to
quote.

Shellcheck reports a bunch of quoting issues in our scripts. Fix what
can be fixed.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
f876aed900 test/difftree.sh: Silence warning about looping over find output
Shellcheck emits the following warning:
SC2044: For loops over find output are fragile. Use find -exec or a while read loop.

Disable it for now.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
ac2d6e3759 test/difftree.sh: Remove useless command invocations
Shellchecks warns about two useless commands:
SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Simplify that line with those suggestions.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
4dd55cd407 test: Avoid issues with names starting with dashes
Shellcheck emmits the following warning:
SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.

Which seems like a fair recommendation.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
22d1046412 test/difftree.sh: Remove unused variable
Shellcheck reports VMVLINUX is unused. Also it seems to has a typo
in the name.

Lets remove it.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
857f892407 kpatch-test: Fix type error
Shellcheck reports the following error:
SC2145: Argument mixes string and array.

Lets pretend that types are a thing in bash and use the list of
arguments as a single string instead of the array of arguments.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
555a578fe9 kpatch-test: Remove unused variable
As reported by shellcheck, RMMOD seems no longer used. Get rid of it.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
1839980d1d test/integration: Silence warning about which
Shellcheck complains with the following warning:
SC2230: which is non-standard.

It is probably fair to assume that which is available for now, so just
ignore the warning.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
9a66fa7df4 test/integration: Silence unspecified input warning
Shellcheck complains with the following warning:
SC1091: Not following: /etc/os-release was not specified as input (see shellcheck -x)

Which is already silenced in lib.sh.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-04 20:30:28 +01:00
Julien Thierry
443cdedb29 test/integration: Explicitly add some missing dependencies for RHEL-8
On RHEL-8, yum builddep misses some necessary dependencies to build the
kernel.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-02 19:40:40 +01:00
Julien Thierry
4df66fa15f test/integration: Handle python version for RHEL-8 platforms
On RHEL-8, version agnostic python-devel package does not exist.

On previous RHEL releases, python-devel is for python2.

On RHEL-8, the platform-python (which provides the needed utilities)
is python3.

Assuming this will be the same for future RHEL releases, specify the
python major as part of the kpatch dependencies.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-06-02 19:40:36 +01:00
Artem Savkov
5edd45bbcf Integration tests: enable dynamic debug in klp_try_switch_task()
Enable dynamic debug prints in klp_try_switch_task() function before
going through with load tests and switch back to a previous state
afterwards.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-05-20 14:54:41 +02:00
Yannick Cote
dd24313e9b
Merge pull request #1106 from joe-lawrence/integration-tests-rhel-8.2
test/integration: add RHEL-8.2 integration tests
2020-05-18 09:22:31 -04:00
Joe Lawrence
5331463768
Merge pull request #1102 from joe-lawrence/jp-ppc-mcount
create-diff-object: Add ppc64le mcount support
2020-05-18 09:20:40 -04:00
Joe Lawrence
1a4fd65282 testing/rhel-8.1: disable shadow-newpid-LOADED integration test
For consistency, disable the shadow-newpid-LOADED integration test
script since its corresponding patch already is already disabled.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-05-18 08:42:46 -04:00
Josh Poimboeuf
b958ed601c create-diff-object: Add ppc64le mcount support
Add the __mcount_loc section on ppc64le.  It has pointers to all the
mcount calls.  This will enable the ftrace hook to be used for patched
functions.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> (rebased)
2020-05-18 08:35:33 -04:00
Joe Lawrence
3aa8fd9a4f test/integration: add RHEL-8.2 integration tests
Patches rebased against RHEL-8.2 GA kernel-4.18.0-193.el8.

Tests disabled for errors when building against updated
4.18.0-193.3.1.el8_2.x86_64 z-stream kernel:

  * data-read-mostly.patch:
  dev.o: Found a jump label at __netif_receive_skb_core()+0x32, using key netstamp_needed_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  dev.o: Found a jump label at __netif_receive_skb_core()+0x95, using key generic_xdp_needed_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  dev.o: Found a jump label at __netif_receive_skb_core()+0xd0, using key ingress_needed_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  dev.o: Found a jump label at __netif_receive_skb_core()+0x412, using key nf_hooks_needed.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  /root/github-kpatch/kpatch-build/create-diff-object: ERROR: dev.o: kpatch_regenerate_special_section: 2344: Found 4 jump label(s) in the patched code. Jump labels aren't currently supported. Use static_key_enabled() instead.

  * gcc-static-local-var-4.patch (ppc64le only):
  aio.o: Found a jump label at aio_free_ring()+0x7c, using key devmap_managed_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  /root/github-kpatch/kpatch-build/create-diff-object: ERROR: aio.o: kpatch_regenerate_special_section: 2344: Found 1 jump label(s) in the patched code. Jump labels aren't currently supported. Use static_key_enabled() instead.

  * shadow-newpid.patch:
  fork.o: WARNING: unable to correlate static local variable ctr.70325 used by _do_fork, assuming variable is new
  fork.o: changed function: _do_fork
  exit.o: Found a jump label at do_exit()+0x6d3, using key devmap_managed_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  /root/github-kpatch/kpatch-build/create-diff-object: ERROR: exit.o: kpatch_regenerate_special_section: 2344: Found 1 jump label(s) in the patched code. Jump labels aren't currently supported. Use static_key_enabled() instead.

  * special-static.patch:
  fork.o: Found a jump label at copy_process.part.34()+0x1fc, using key memcg_kmem_enabled_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  fork.o: Found a jump label at copy_process.part.34()+0x21b, using key memory_cgrp_subsys_enabled_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  fork.o: Found a jump label at copy_process.part.34()+0x72a, using key memory_cgrp_subsys_enabled_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead.
  fork.o: Found a jump label at copy_process.part.34()+0x773, using key memcg_kmem_enabled_key.  Jump labels aren't supported with this kernel.  Use static_key_enabled() instead
  ./root/github-kpatch/kpatch-build/create-diff-object: ERROR: fork.o: kpatch_regenerate_special_section: 2344: Found 4 jump label(s) in the patched code. Jump labels aren't currently supported. Use static_key_enabled() instead.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-05-17 11:07:08 -04:00
Artem Savkov
149ff8d1dc integration/centos-7: update tests to current kernel
Since the kernel we were testing against before is no longer available
in centos repos I've updated our test vagrant image bringing the kernel
version to 3.10.0-1127.el7. Since this is basically the rhel-7.8 kernel
and we don't want extra work maintaining extra sets of patches just
symlink centos-7 patch directory to rhel-7.8. If(when) we are in this
situation again we'll just switch the symlink to the appropriate minor
again.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-05-05 20:06:46 +02:00
Artem Savkov
e0e41f0943 tests/integration/module.patch: fix ppc64le build
ppc64le build currently fails dues to unused sched_clock variable. Move
it's declaration into ifdef block.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-04-23 14:15:31 +02:00
Julien Thierry
c1caee1468 create-diff-object: Ignore kpatch_ignored functions/sections missing ftrace hook
Some theoretically unchanged functions can have undesired changes if the
compiler decides to perform inlining in a different way (e.g. because of
newly added references). In such a case, it can be useful to discard
changes to functions that don't actually need modification.

Sadly, this currently doesn't work for functions missing the ftrace hook
(e.g. notrace code) as presence of the hook is checked before
identifying elements to ignore.

Look for functions/sections to ignore earlier.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-04-23 08:22:50 +01:00
Josh Poimboeuf
61ef8238d1 test/unit: Use non-failing jump label tests
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2020-04-14 17:41:17 -05:00
Josh Poimboeuf
f24f5cb2ca test/integration: improve module integration test
Replace module-call-external.patch with a more fleshed-out version which
tests multiple things (including jump tables for newer kernels), and
also includes a runtime test.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2020-04-14 16:46:03 -05:00
Yannick Cote
e2c66d7fb0
Merge pull request #1054 from julien-thierry/static-local-reworks
Static local reworks
2020-04-04 17:00:35 -04:00
Joe Lawrence
666635d4b0
Merge pull request #1083 from joe-lawrence/integration-rhel-7.8
test/integration: add rhel-7.8 rebased patches
2020-03-31 19:03:01 -04:00
Kamalesh Babulal
2e4309eebb test/integration: rhel-8.1 Add missing *.test files
Add the missing *.test files in test/integration/rhel-8.1

[Artem Savkov: Suggested to disable gcc-static-local-var-4.test]
Suggested-by: Artem Savkov <asavkov@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-03-30 20:21:00 +05:30
Julien Thierry
24fc731ab2 test/integration: Reenable test
Reenable previously failing test gcc-static-local-var-5.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-03-30 14:21:40 +01:00
Julien Thierry
2265ce6fc2 test/unit: Add unit test for static local moving sections
Signed-off-by: Julien Thierry <jthierry@redhat.com>
2020-03-30 14:14:17 +01:00
Yannick Cote
421df07ffa
Merge pull request #1086 from kamalesh-babulal/rhel8-1-testcases-rebase
test/intergation: Rebase to RHEL 8.1
2020-03-27 11:47:43 -04:00
Kamalesh Babulal
db3c916e7c test/integration: Disable special-static testcase
Disabling the test case, until we find a workaround for functions
with the static key getting inlined. Read the comments from
@joe-lawrence in #1086 for detailed analysis.

Suggested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-03-27 15:46:41 +05:30
Kamalesh Babulal
4423e471d1 test/intergation: Rebase to RHEL 8.1
Rebase the integration testcase on top of RHEL 8.1 kernel
4.18.0-147.el8.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-03-17 17:31:09 +05:30
Joe Lawrence
d9a40744aa test/integration: add rhel-7.8 rebased patches
Rebased against the RHEL-7.8 GA kernel-3.10.0-1127.el7.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-03-11 10:09:30 -04:00
Joe Lawrence
ffe36c7716 testing/integration: update rebase_patches tool
Update the rebase_patches hack^H^H^H tool to make it easier to define
environment variables to drive it, rather than sourcing source
/etc/os-release for everything.  Fix a bunch of shellcheck warnings
along the way.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2020-03-10 10:36:46 -04:00
Artem Savkov
f3e6f8e538 tests/integration: fetch pull-request data
Fetch pull-request data before resetting to a specified commit. This
will allow us to run integration tests on pull-request using master
repo, without cloning the original.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2020-02-25 17:33:24 +01:00
Joe Lawrence
69acfe8a2f
Merge pull request #1071 from joe-lawrence/gcc-static-local-var-4
integration: update gcc-static-local-var-4.test
2020-02-19 09:16:59 -05:00
Josh Poimboeuf
648be4c380
Merge pull request #1053 from julien-thierry/stricter-static-twin
kpatch-build: Make local static twining stricter
2020-02-17 15:15:52 -06:00
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