Commit Graph

1867 Commits

Author SHA1 Message Date
Artem Savkov fcc7dad42a
Merge pull request #1074 from sm00th/pr_fetch
tests/integration: fetch pull-request data
2020-02-26 13:51:36 +01: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 40efb838cc
Merge pull request #1072 from jpoimboe/callback-strip-fix
create-diff-object: Don't strip callback section symbols
2020-02-18 14:43:31 -06:00
Josh Poimboeuf 687e2caabc create-diff-object: Don't strip callback section symbols
Internal CI is reporting a SIGSEGV in create-diff-object when it
processes macro-callbacks.patch, starting with 19baa5b7c7
("create-diff-object: process debug sections last").

The problem is that, after changing the order between callback and debug
section inclusion, kpatch_include_debug_sections() now tries to include
the callback section symbols.  But kpatch_include_callback_elements()
inadvertently un-includes the callback section symbols (e.g.,
".kpatch.callbacks.pre_patch") when it un-includes the callback struct
symbols (e.g., "kpatch_pre_patch_data").

So after kpatch_elf_teardown(kelf_patched), the callback section symbols
get freed even though there are DWARF .debug_info relocations which
reference them.  Then kpatch_check_relocations() goes off into the weeds
when it accesses one of the freed symbols.

Fix it by refining the callback un-include logic so that it *only*
strips the struct object symbols.

Fixes: 19baa5b7c7 ("create-diff-object: process debug sections last")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2020-02-18 10:16:39 -06: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
Josh Poimboeuf 1b7871507a
Merge pull request #1055 from jpoimboe/process-debug-sections-last
create-diff-object: process debug sections last
2020-02-17 14:50:39 -06:00
Joe Lawrence 2305fe1f59
Merge pull request #1067 from kamalesh-babulal/wconversion-flags
[RFC] Enable -Wconversion/-Wno-sign-conversion flags
2020-02-17 11:20:44 -05: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
Kamalesh Babulal 37e950a653 create-kpatch-module: Fix -Wconversion warnings
Fix warnings reported by -Wconversion,-Wno-sign-conversion CFLAGS.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-02-11 19:25:10 +05:30
Kamalesh Babulal ea9e708df0 create-klp-module: Fix -Wconversion warnings
Fix warnings reported by -Wconversion,-Wno-sign-conversion flags.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-02-11 19:25:04 +05:30
Kamalesh Babulal f67c2ebce0 kpatch-elf: Fix -Wconversion warnings
Fix warnings reported by -Wconversion,-Wno-sign-conversion flags.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-02-11 19:24:57 +05:30
Kamalesh Babulal 5f68db22e5 create-diff-object: Fix -Wconversion warnings
Fix warnings reported by -Wconversion,-Wno-sign-conversion flags.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-02-10 09:07:21 +05:30
Josh Poimboeuf fd8209aa00
Merge pull request #1068 from sm00th/integration_pass
Integration test stabilization
2020-01-24 08:03:38 -06: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
Kamalesh Babulal a0c608de70 kpatch-build/Makefile: Skip build insn/plugin with -Wconversion
Skip building insn/* on x86 and gcc-plugin on Power with -Wconversion,
-Wno-sign-converion flags.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-01-23 12:59:38 +05:30
Kamalesh Babulal 4e4a8d99da kpatch-build: add -Wconversion/-Wno-sign-conversion CFLAGS
Add -Wconversion and -Wno-sign-conversion to CFLAGS.  The first flag
should catch any implicit conversions like the one seen with #1065 and
the second flag suppress the warnings between signed and unsigned
integers.

Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2020-01-23 12:59:31 +05:30
Joe Lawrence 866faf5861
Merge pull request #1065 from euspectre/zero_page_reloc_fix
create-diff-object: fix relocations used for ZERO_PAGE(0)
2020-01-22 16:28:20 -05:00
Evgenii Shatokhin f5f5479614 create-diff-object: fix relocations used for ZERO_PAGE(0)
On x86_64, GCC generates the following instruction to compute
'empty_zero_page - __START_KERNEL_map' (__phys_addr_nodebug(), used in
the implementation of ZERO_PAGE()):

    48 ba 00 00 00 00 00 00 00 00   movabs $0x0,%rdx
          R_X86_64_64  empty_zero_page+0x80000000

__START_KERNEL_map is 0xffffffff80000000.

However, the relocation addend becomes wrong in the patch module:

    48 ba 00 00 00 00 00 00 00 00   movabs $0x0,%rdx
          R_X86_64_64  empty_zero_page-0x80000000

Note the sign of the addend.

As a result, ZERO_PAGE(0) returns a wrong value in any function touched
by the patch, which may lead to memory corruption and difficult-to-debug
kernel crashes.

The cause is that 'struct rela' uses 'int' for the addend, which is not
enough to store such values. r_addend from Elf64_Rela is int64_t
(Elf64_Sxword) for that.

Let us use 'long' instead of 'int' for the addend in 'struct rela'.

v2:
* Moved 'addend' field after 'offset' in struct rela to facilitate
  structure packing (suggested by Kamalesh Babulal).

Fixes https://github.com/dynup/kpatch/issues/1064.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2020-01-20 11:41:01 +03: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
Joe Lawrence eb0e84f748
Merge pull request #1063 from haoren3696/master
kpatch-build: replace all '-' to '_' in KOBJFILE_NAME
2020-01-06 10:34:04 -05:00
Zhipeng Xie 61c55d9e52 kpatch-build: replace all '-' to '_' in KOBJFILE_NAME
When patching kernel module dm-persistent-data, I found
that the KOBJFILE_NAME is incorrectly replaced to
dm_persistent-data while the module name in kernel is
dm_persistent_data.

Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
2019-12-30 17:48:14 +08:00
Joe Lawrence ff51f80177
Merge pull request #1041 from joe-lawrence/author-guide-updates
Author guide updates
2019-12-06 10:19:53 -05:00
Joe Lawrence 64027b4c9e patch-author-guide: remove kpatch.ko-era references
The kpatch.ko support module is no longer needed by modern upstream and
recent distribution kernels, so update the patch author guide
accordingly.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-12-05 15:01:01 -05:00
Joe Lawrence cd305fd7ec patch-author-guide: add sibling call info
kpatch-build doesn't support GCC's sibling call optimizations in patched
functions to avoid potentially dangerous generated code.  Explain the
error message that may result and link to the commit which provided
detailed explanation of why we disabled support for this in kpatch.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-12-05 15:00:58 -05:00
Joe Lawrence 59fbf45d8e patch-author-guide: add jump label notes
Add a quick explanation for jump labels and how to workaround the
current limitations.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-12-05 14:48:29 -05:00
Joe Lawrence 1e2f73216f patch-author-guide: explain "inline" and implicit "notrace"
The kernel's definition of "inline" implies "notrace" and that may lead
to unexpected kpatch-build errors.  Explain why that is and how to work
around the issue.

Fixes #983.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2019-12-05 14:48:29 -05:00
Julien Thierry 68530e4c2b kpatch-build: Make local static twining stricter
The current code to find the twin of a local static variable allows two
variables of the same name to be wrongly matched with the other's twin.

While there isn't a magic formula to avoid this, make stricter
requirements for twining static local from the original object with
a symbol from the patched object. This reduces the risk of erroneous
matches.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-11-22 09:53:16 +00:00
Josh Poimboeuf ea348164f6
Merge pull request #1058 from julien-thierry/doc-link-fix
doc: Update broken hyperlink
2019-11-14 10:47:49 -06:00
Julien Thierry e4b6e1ff6e doc: Update broken hyperlink
Referenced kernel documentation has moved from txt file to rst. Update
the hyperlink to point to the correct file.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-11-14 11:39:25 +00:00
Josh Poimboeuf 19baa5b7c7 create-diff-object: process debug sections last
Process the debug sections only after all the other inclusion logic has
finished, since it makes decisions based on what else has already been
included.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2019-11-01 15:26:07 -05:00
julien-thierry b53e4e3f44
Merge pull request #1048 from julien-thierry/correlation-rename-fixes
Correlation rename fixes
2019-11-01 07:41:21 +00: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 852bad5e8d create-diff-object: Use new helpers for static local correlation
Simplify static local variable correlation and renaming code by using
the newly introduced helpers for section and symbol correlation.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-29 15:29:51 +00:00
Julien Thierry e49e3a59c2 create-diff-object: Rename elements getting correlated
Change 935f199875 ('create-diff-object: simplify mangled function
correlation') simplified the way symbols are correlated and got rid of
symbol section renaming.

As a result a symbol/section can now have a CHANGED status, being
correlated to an element that doesn't have the exact same name. This
will cause lookups to the original object fail when creating the new
patch object.

So lets bring back the symbol/section renaming, but only once they
have actually been correlated.

Fixes: 935f199875 ('create-diff-object: simplify mangled function
correlation')
Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-29 15:27:51 +00:00
Julien Thierry 49a9adaf74 create-diff-object: Correlate objects related to a section at once
Elements from the original object and the patched object can be
correlated using their mangled names. In case an elements (section or
symbol) could be matched with more than one object through mangling,
make sure all elements related to a section are correlated with the
corresponding elements of the twin section.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-29 15:27:51 +00:00
Julien Thierry 770f529225 kpatch-elf: Ensure stale references are not used
When freeing a kpatch_elf, another object might have symbols and
sections twined with elements that are getting freed.

Clear the twin references, so if they are used after the object they
reference is freed, the program will crash.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
2019-10-29 10:48:02 +00:00