Commit Graph

95 Commits

Author SHA1 Message Date
Artem Savkov
f43b061bb4 Integration tests with vagrant
This commit adds scripts/make targets to run integration tests on
fedora/ubuntu/centos through vagrant.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-10-30 10:56:19 +01:00
Artem Savkov
30e943defd integration/lib.sh: add write_vagrantfile* functions
Add vagrantfile generating functions to lib.sh.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-10-30 10:56:19 +01:00
Artem Savkov
e84fe6b14f integration/lib.sh: vagrant installation
Vagrant installation functions for fedora/centos with libvirt plugin.
This is intended to be used in scripts to provision a new test-machine,
human users of vagrant integration test targets are expected to have
working vagrant installation.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-10-30 10:56:19 +01:00
Artem Savkov
3bc5234ef0 integration/lib.sh: add separate_partition/disk_cache functions
Add functions to prepare a separate partition/disk for cache use
(.ccache and .kpatch dirs). This is useful for vagrant images that are
generally not big enough for kpatch build.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-10-30 10:56:19 +01:00
Artem Savkov
b003955257 Add integration/lib.sh with distro dependency functions
Add test/integration/lib.sh for use in other kpatch related scripts
and or directly by end-users. Initial version contains per-distro
dependency functions, so it can be quickly installed as follows:

$ . test/integration/lib.sh
$ kpatch_dependencies

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-10-30 10:56:00 +01:00
Artem Savkov
5371d9f972 kpatch-test: remove -SLOW special cases
Treat -SLOW patches the same way as normal ones, i.e. include them
during "quick" testing. Keeping "-SLOW" suffix in patch names to as a
way to distinguish them manually.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-09-10 10:01:16 +02:00
Artem Savkov
80f78c78bb test/integration: skip -SLOW load tests in combined run
We are not including -SLOW patches into combined module, so there is no
reason to expect their -LOADED tests to succeed with combined module.
Skip them in run_combined_test().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-08-23 09:23:50 +02:00
Artem Savkov
1a91e256ff test/integration: run -FAIL tests when invoked with --quick
Include -FAIL tests as well as combined in 'quick' target.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-08-23 09:23:30 +02:00
Artem Savkov
6cbf55d77b test/integration: include build log on failures
If a patch build fails copy the build log to <prefix>.log file.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-08-23 09:23:03 +02:00
Joe Lawrence
7646c68b59 testing: kpatch-build should set all module names
Since c0105ea467 ("kpatch-build: set default module prefix
accordingly") kpatch-build has automatically named resulting patch
modules with a "kpatch-" or "livepatch-" prefix (depending on its type).

To avoid naming confusion, have kpatch-test name all of its patch
modules with a "test-" prefix.

Fixes #867.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-06-01 16:59:08 -04:00
Josh Poimboeuf
e16b4187a1 test/integration: remove obsolete tests
Cleaning house a bit.  Now that we have unit tests, a lot of these tests
aren't very useful anymore.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-04-19 17:19:09 -05:00
Josh Poimboeuf
8e315b42e0 test/integration: update WARN detection patch
Update the WARN detection patch to be based on net/core/dev.c, which is
a much better stress test.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-04-19 17:19:09 -05:00
Josh Poimboeuf
af9f9f491c test: remove obsolete tests
After doing some research, I've discovered that most of these tests no
longer test what they were originally intended to test.

An exception here is the 'macro-hooks' test, which is probably better
suited as an integration test, so I removed its unit test and kept its
integration test.

Really, most of these tests weren't all that useful to begin with, so
it's not a big loss.  The one exception is 'gcc-static-local-var-2',
which was originally meant to test multiple static local variables with
the same name in the name function.  That's a good thing, so I'll try to
come up with another test for that which works with Linux 4.16.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-04-19 17:19:08 -05:00
Kamalesh Babulal
4d3363a975 Testcase: Clean up gcc-static-local-var-2
The test case gcc-static-local-var-2 doesn't uses any macros
from kpatch-macros.h, so remove the hunk including it.

Cc: Joe Lawrence <jdl1291@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-04-06 12:11:05 +05:30
Kamalesh Babulal
bfacf5d15c Testing: Add testcase for correlating static local variable
This patch adds a reproducer testcase for correlating static local
variables added in .rodata* section, ahead of .toc section. This
testcase is for issue seen on PowerPC. For more details on the issue
refer pull request: 793.

It add's the testcase for:
- Fedora-27 Kernel version 4.15.10-300
- Centos-7 Kernel version 3.10.0-693 and
- Ubuntu-16.04 Kernel version 4.13.0-25.29

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-04-05 09:44:45 -05:00
Joe Lawrence
926e4e0c7d kmod: add support for in-kernel livepatch hooks
Upstream 4.15 kernels provide support for pre and post (un)patch
callbacks, inspired by the kpatch load hooks.  Add support for them
in the livepatch-patch-hook.

At the same time, convert the kpatch hooks to use the same API.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-03-23 10:32:14 -04:00
Joe Lawrence
1d942ebb41 testing: rebase patches for Fedora 27 4.13.9-300.fc27.x86_64
Rename the old Fedora 25 integration patch directory and rebase to
Fedora 27 sources.

Fixes #761.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-03-22 14:36:34 -04:00
Doug Goldstein
ff5c554a40
drop unused rpmdevtools dependency
It appears that since 0dec5136ee nothing
has been used from the rpmdevtools package by kpatch-build.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
2018-03-21 15:15:08 -05:00
Joe Lawrence
eda8357743 testing: simplify combined integration test
Now that kpatch-build can accept multiple patches on the command line,
ditch the combinediff and associated logic in the integration test
script.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-09-25 09:17:07 -04:00
Joe Lawrence
2f8170e962 testing: rebase patches for CentOS 7.4 kernel-3.10.0-693.el7
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-09-22 17:02:33 -04:00
Joe Lawrence
9a786313e0 testing - rebase for integration tests for Fedora 25
Kernel version 4.9.7-201.fc25.x86_64
2017-02-09 15:41:41 -05:00
Joe Lawrence
3215c4ff2f testing: remove extra '}' from run_custom_test's prefix variable
Fixes: #664.
2017-01-26 11:06:02 -05:00
Josh Poimboeuf
ac899455ab create-diff-object: convert global symbols to local
As reported in PR #658, when patching an exported function which is used
by the patch module init code, the init code will incorrectly link to
the patched version of the function and will call the patched function
before its relocations have been applied.

For example, when patching __kmalloc(), I see:

  # insmod kpatch-kmalloc.ko
  kpatch_kmalloc: module is marked as livepatch module, but livepatch support is disabled
  kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
  BUG: unable to handle kernel paging request at ffffc90001d03c58
  IP: 0xffffc90001d03c58
  PGD 7c8b4067
  PUD 7c8b5067
  PMD 755f7067
  PTE 800000007ad03163
  Oops: 0011 [#1] PREEMPT SMP
  Modules linked in: kpatch_kmalloc(OE+) kpatch(OE) ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw snd_hda_codec_generic ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel virtio_balloon snd_hda_codec snd_hwdep serio_raw virtio_console snd_hda_core parport_pc parport snd_pcm virtio_net snd_timer snd i2c_piix4 soundcore virtio_blk qxl drm_kms_helper ttm drm virtio_pci virtio_ring virtio ata_generic pata_acpi
  CPU: 1 PID: 1042 Comm: insmod Tainted: G           OE   4.10.0-rc5 #1
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
  task: ffff88007560d480 task.stack: ffffc90001d00000
  RIP: 0010:0xffffc90001d03c58
  RSP: 0018:ffffc90001d03c50 EFLAGS: 00010286
  RAX: 0000000000000004 RBX: 0000000000000008 RCX: 0000000000000000
  RDX: 0000000000000000 RSI: 00000000014080c0 RDI: 0000000000000008
  RBP: ffff88007ad00058 R08: 0000000000000001 R09: 0000000000000001
  R10: 0000000000000000 R11: 0000000000000001 R12: 00000000fffffff4
  R13: ffffffffa0394ef0 R14: 0000000000000000 R15: ffffc90001d03ea8
  FS:  00007f9689d74700(0000) GS:ffff88007d000000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffffc90001d03c58 CR3: 000000007af1d000 CR4: 00000000001406e0
  Call Trace:
   ? kzalloc.constprop.6+0xe/0x10 [kpatch_kmalloc]
   ? patch_init+0xa6/0x1000 [kpatch_kmalloc]
   ? 0xffffffffa0399000
   ? do_one_initcall+0x52/0x1b0
   ? do_init_module+0x27/0x1fa
   ? rcu_read_lock_sched_held+0x4a/0x80
   ? kmem_cache_alloc_trace+0x28a/0x2f0
   ? do_init_module+0x5f/0x1fa
   ? load_module+0x2446/0x2b90
   ? __symbol_put+0x90/0x90
   ? vfs_read+0x137/0x180
   ? SYSC_finit_module+0xdf/0x110
   ? SyS_finit_module+0xe/0x10
   ? entry_SYSCALL_64_fastpath+0x1f/0xc2
  Code: c9 ff ff 10 00 00 00 00 00 00 00 86 02 01 00 00 00 00 00 50 3c d0 01 00 c9 ff ff 18 00 00 00 00 00 00 00 b4 33 39 a0 ff ff ff ff <a0> 3c d0 01 00 c9 ff ff a6 90 39 a0 ff ff ff ff 00 00 00 00 00
  RIP: 0xffffc90001d03c58 RSP: ffffc90001d03c50
  CR2: ffffc90001d03c58
2017-01-23 15:50:13 -06:00
Joe Lawrence
97be7f57fb testing: add full path for /sbin executables
"/sbin" might not be in the user's path, so prefix callouts to such
utilities with their full path.
2017-01-13 13:54:35 -05:00
Joe Lawrence
f7b59ca809 testing: skip combined test for a single patch
If kpatch-test processes a single .patch file, it will skip creating a
COMBINED.patch.

Do the same on the testing side (instead of complaining that it "can't
find kpatch-COMBINED.ko, skipping.")
2017-01-13 13:54:35 -05:00
Joe Lawrence
1096da7155 testing: handle empty glob cases
If kpatch-test looks for *.patch or *.test globs in a directory that
contains no such files, it will try to handle a single file named
"*.patch" or "*.test".

Set the global nullglob option to avoid this problem.  At the same time,
stop and whine to the user if no .patch files were found.
2017-01-13 13:54:04 -05:00
Joe Lawrence
6ee3c0f8fa testing: add a PATCHES_LIST to kpatch-test
Instead of building *.patch, allow the user to specify patch files on
the command line.  For example:

  kpatch-test --quick centos-7/cmdline-string.patch centos-7/data-new.patch

Update the top-level Makefile as well, so it can be similarly invoked:

  PATCHES="centos-7/cmdline-string.patch centos-7/data-new.patch" make quick

If no patches are specified on the kpatch-test command line, then fall
back to the previous behavior of *.patch.

NOTE: If patches *are* specified, then only the .test files
corresponding to those patches will be executed.  Provided patch paths
will also override any --directory value.
2016-12-16 16:18:19 -05:00
Joe Lawrence
5db4e232ee testing: use common Makefile
Move the integration tests Makefile up a directory level so that it can
be shared.  Update the kpatch-test script to accept a patch-directory
argument and the multiple.test cases to handle this new arrangement.
2016-12-16 16:16:30 -05:00
Joe Lawrence
b6692c14d7 testing: add and rebase integration tests for Ubuntu 16
Kernel version: 4.4.0-53-generic
2016-12-16 16:06:49 -05:00
Joe Lawrence
11ce8102c2 testing: add and rebase integration tests for CentOS 7
Kernel version: 3.10.0-327.36.3.el7.x86_64
2016-12-16 16:06:28 -05:00
Joe Lawrence
d7bcd38787 testing: rebase integration tests for Fedora 25
Kernel version 4.8.6-300.fc25.x86_64
2016-12-16 16:06:15 -05:00
Joe Lawrence
1592c5a711 testing: move integration test patches directory
Prepare for updating the integration tests and move into a standard path
(this should be easier for future automation).

The patch directory name(s) should be in the form ${ID}-${VERSION_ID}/
as defined by the target's /etc/os-release.
2016-12-16 16:05:59 -05:00
Joe Lawrence
33ac7db028 testing: add rebase_patches tool 2016-12-16 16:05:06 -05:00
Josh Poimboeuf
353f976312 test: integration test cleanup
- fix kpatch tool path in multiple.test
- remove "kpatch replace" tests (replace is deprecated)
2015-10-30 16:47:34 -05:00
Josh Poimboeuf
aa9f7fb1f6 test: add ability to run tests remotely
Create a "make remote" target and a poor man's ansible to allow setting
up a remote F22 system and running integration tests on it.

To run tests remotely:

  make remote SSH_HOST=my.remote.f22.box
2015-10-26 22:35:40 -05:00
Josh Poimboeuf
69b241ab38 test: fix ccache
For some reason CCACHE_HASHDIR needs to be unset for ccache to work when
building the integration tests from the kpatch-test script.
2015-10-26 22:35:40 -05:00
Josh Poimboeuf
3d46973c40 test: fix patches
Update the integration test patches so that they apply against the F22
kernel.
2015-10-26 21:09:19 -05:00
Josh Poimboeuf
8dc6a4dd3c test: move tests to f22 directory
The integration tests are targeted for Fedora kernels, so move them to a
new f22 directory.  The README file specifies the exact kernel version
they're targeted for.
2015-10-26 21:09:19 -05:00
Seth Jennings
664fb2a8a2 Merge pull request #453 from jpoimboe/rs-special-static
make _rs a "special" static local variable
2014-10-08 10:58:11 -05:00
Josh Poimboeuf
4c7fb9119a detect and ignore WARN-only changes
WARN-only function changes are very common, and a serious PITA for patch
authors.  Detect and ignore them.

Fixes #454.
2014-10-07 11:56:41 -05:00
Josh Poimboeuf
c799ecc55f make _rs a special static local
The _rs variable is used for printk ratelimiting, similar to __warned,
which makes it a logical candidate to be "special": don't correlate it,
yet don't mark a function as changed just because it references it.
2014-10-07 08:09:20 -05:00
Seth Jennings
bb6edd16f9 Merge pull request #452 from jpoimboe/module-call-external
allow patched modules to call external functions
2014-10-07 00:04:43 -05:00
Seth Jennings
31852c0dfa Merge pull request #451 from jpoimboe/sections-syms-fix
section reference replacement for references inside symbols
2014-10-07 00:01:20 -05:00
Seth Jennings
8e9aa2b559 Merge pull request #448 from jpoimboe/static-local-fixes
improve static local variable correlation
2014-10-06 23:56:24 -05:00
Josh Poimboeuf
f5de932b8d allow patched modules to call external functions
When patching a kernel module, if we can't find a needed dynrela symbol,
we currently assume it's exported.  However, it's also possible that
it's provided by another .o in the patch module.  Add support for that.

Fixes #445.
2014-10-06 23:16:13 -05:00
Josh Poimboeuf
3dd442b12d section reference replacement for references inside symbols
Currently unbundled section references are only replaced if the start of
the symbol is referenced.  It's also useful to support replacement of
references which point to inside the symbol.
2014-10-06 22:52:01 -05:00
Josh Poimboeuf
7876ce4aae test: make sure TMP.patch is cleaned up 2014-10-06 14:42:34 -05:00
Josh Poimboeuf
fb49e254cf improve static local variable correlation
Improve the static local variable correlation logic, for the case where
a static local is used by multiple functions.  For each usage of the
variable, look for a corresponding usage in the base object.  If we find
at least one matching usage, consider it a twin.
2014-10-06 14:38:46 -05:00
Josh Poimboeuf
36150a8beb fix integration test patch conflict 2014-10-06 12:42:45 -05:00
Seth Jennings
6175658196 Merge pull request #441 from jpoimboe/module-shadow
allow shadow functions to be called from modules
2014-10-02 23:22:26 -05:00