1
0
mirror of https://github.com/dynup/kpatch synced 2024-12-27 15:52:02 +00:00
Commit Graph

1440 Commits

Author SHA1 Message Date
Josh Poimboeuf
0d99e91c46
Merge pull request from joe-lawrence/author-guide-callback-locks
patch-author-guide: more on locks in callbacks
2018-04-16 07:59:13 -05:00
Joe Lawrence
9b5ade5c12
Merge pull request from sm00th/unittests
Unittests
2018-04-13 17:15:07 -04:00
Joe Lawrence
88241ef8e5
Merge pull request from sm00th/sign-compare
Sign compare fixes
2018-04-13 15:21:07 -04:00
Joe Lawrence
fb06282505 patch-author-guide: more on locks in callbacks
Elaborate on the difficulties in using locks/mutexes from the kpatch
callback routines and suggest a few workarounds.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-04-13 15:13:18 -04:00
Artem Savkov
1ada45a352 unittests: top-level make target
Add new 'unit' make target to top-level makefile.
Add unittests dir to CLEAN_DIRS.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 18:11:51 +02:00
Artem Savkov
a0edfc1ded unittests: check that obj files are fetched
Check that tested .o is not an lfs meta-file before testing.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 18:11:50 +02:00
Artem Savkov
b9c56c475a uinttests: add strip check
Check that files are stripped of debuginfo as it is useless for
unittesting at this moment.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 18:11:17 +02:00
Artem Savkov
3ee81ec4ee x86_64: integration test objs
Populate x86_64 dir with objectfiles from integration test builds.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 18:10:34 +02:00
Artem Savkov
a05c644c7b Add create-diff-object unittest framework
Add a simple unittest framework for create-diff-object implemented in
GNU Make.
It will automatically scan the kpatch-unit-objs/$(uname -m) directory
for specifically named files running one of 3 tests:
  - creating diff object with expected success
  - creating diff object with expected failure
  - creating diff object and running a shell script on it with expected
  success

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 18:09:37 +02:00
Artem Savkov
a39eace756 kpatch-build: add -Wsign-compare to CFLAGS
Add -Wsign-compare to kpatch-build CFLAGS to make sure something like 
never happens again.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 16:27:23 +02:00
Artem Savkov
1638c64fe5 Fix multiple sign-compare warnings
- convert section/symbol indexes and rela->offset to unsigned int as I
    couldn't find any way for them to become negative.
  - cast a number of rela->addend comparisons to int (assuming an 64bit
    system this should be enough)
  - a number of simple for-loop counter conversions to the type it
    compares against

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-13 16:26:06 +02:00
Joe Lawrence
c5e4b51982
Merge pull request from vincentbernat/fix/ubuntu-kernel-retry
kpatch-build: fix Ubuntu kernel detection on successive retries
2018-04-12 14:11:38 -04:00
Joe Lawrence
2a53a96ade
Merge pull request from sm00th/oorr-comparison-fix
Fix false-positives in kpatch_check_relocations
2018-04-12 13:44:23 -04:00
Vincent Bernat
e2e7d2cd21 kpatch-build: fix Ubuntu kernel detection on successive retries
If a patch failed a first time, kpatch-build is using the previous
cache directory on subsequent builds. The UBUNTU_KERNEL=1 variable is
not set in this case. Therefore, utsrelease.h is not updated correctly
and the appropriate structures are not used. Just check if distro is
Ubuntu and we didn't request our own specific directory.

Signed-off-by: Vincent Bernat <vincent@bernat.im>
2018-04-12 18:29:18 +02:00
Artem Savkov
4591c0701c Fix false-positives in kpatch_check_relocations
Because of signedness difference kpatch_check_relocations() would trigger
an error on any negative addend.
Fix by casting Elf_Data->d_size from size_t to int.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-12 17:46:12 +02:00
Joe Lawrence
88e9eb3ee0
Merge pull request from sm00th/oorr
create-diff-object: check for out-of-range relocations
2018-04-11 14:54:24 -04:00
Joe Lawrence
86d18c7ce3
Merge pull request from joe-lawrence/module-probe-failed
kmod/core: account for failing modules in notifier
2018-04-11 10:40:58 -04:00
Joe Lawrence
326b8f863b
Merge pull request from sm00th/aguide
patch-author-guide: sleeping locks in callbacks
2018-04-11 10:12:28 -04:00
Joe Lawrence
ae79f2206d
Merge pull request from kirawrath/upstart-support
Adding support to upstart systems.
2018-04-11 10:10:59 -04:00
Artem Savkov
1d9f75a155 create-diff-object: check for out-of-range relocations
Check that none of the relocations are out-of-range of their
corresponding sections before writing the output elf.

Fixes: 

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2018-04-11 10:40:34 +02:00
Joe Lawrence
fdf36400fb kmod/core: account for failing modules in notifier
The module notifier currently only handles newly loaded modules in the
MODULE_STATE_COMING state.  If target modules need to be unloaded, the
any kpatch module that patches it must first be disabled, releasing
module references held against the target module.  When the kpatch
modules are disabled, the target module is unpatched and the kpatch
core's data structures updated accordingly.

If a loading module happens to fail its init routine (missing hardware
for example), that module will not complete loading.  The kpatch core
doesn't properly account for this "phantom" target module, so when the
kpatch patch module is removed, it spews out an ugly warning when
attempting to remove a non-existing ftrace filter on the target module.

Register an additional module notifier (first in the list) to handle the
MODULE_STATE_GOING case.  This handler needs to do the inverse of the
MODULE_STATE_COMING handler.

Fixes .

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-04-10 11:46:36 -04:00
Joe Lawrence
e73d98ec0f
Merge pull request from kamalesh-babulal/ppc64le_rela_equal
create-diff-object: Refactor rela_equal() using toc_rela()
2018-04-06 17:24:24 -04:00
Kamalesh Babulal
ed14d8d332 create-diff-object: Refactor rela_equal() using toc_rela()
Heavy lifting of reading .toc rela entries for rela symbols
referring to .toc + offset, can be simplified using toc_rela() in
rela_equal() and remove the #ifdery guarding PowerPC code.

This patch also trims the commentary related to PowerPC.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-04-06 21:12:51 +05:30
Artem Savkov
808a6b83de patch-author-guide: sleeping locks in callbacks
Add a note about dealing with sleeping locks in callbacks.
2018-04-06 16:28:02 +02:00
loretob
c9614c4298 Adding support to upstart systems.
Currently kpatch rely on systemd to load all kmods on startup.
This patch aims to enable kpatch to be used on upstart systems.

Limitations:
With systemd, it would be possible to unload all modules by issuing:
        systemctl stop kpatch
It was not possible to make a reasonable upstart's equivalent of it, so
to unload the modules it will be necessary to call kpatch explicitly:
        kpatch unload --all

I believe this it an non-issue, as it is still possible to unload
the modules by calling kpatch explicitly.

The file /etc/init/kpatch.conf will be installed unconditionally, and
removed on uninstall.

On my tests I have verified that all newly added files by this commit
are also deleted on uninstall.

It was also verified that applied patches are loaded again on startup.

rpmlint does not complain about anything new.

Signed-off-by: Bruno Loreto <loretob@amazon.com>
2018-04-06 16:12:02 +02:00
Josh Poimboeuf
547f6eda1f
Merge pull request from kamalesh-babulal/testcase_cleanup
Testcase: Clean up gcc-static-local-var-2
2018-04-06 08:32:12 -05:00
Josh Poimboeuf
9792d8e542 test: test github's support of git-lfs
Testing github's support of git-lfs for our unit tests.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-04-06 07:55:31 -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
Josh Poimboeuf
055f9c8596
Merge pull request from jpoimboe/ppc64le-static-locals-part-1
create-diff-object: fix ppc64le static local variable correlation
2018-04-05 09:48:26 -05:00
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
Josh Poimboeuf
ff8b2510af create-diff-object: fix ppc64le static local variable correlation
On ppc64le, the static local variable correlation doesn't take into
account the .toc rela indirection for data references, meaning that it's
basically broken in many cases.

Fix it by making the code .toc-aware.

Fixes .

Reported-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-04-04 16:30:07 -05:00
Joe Lawrence
55650e16af
Merge pull request from joe-lawrence/livepatch-hooks
kmod: add support for in-kernel livepatch hooks
2018-04-02 14:49:07 -04:00
Joe Lawrence
9e7db03d3f
Merge pull request from joe-lawrence/sparse
sparse: quiet latest trivial complaints
2018-03-24 15:50:08 -04:00
Joe Lawrence
e4131d4651
Merge pull request from joe-lawrence/make-check
scripts: small ShellCheck cleanups
2018-03-24 15:49:48 -04:00
Joe Lawrence
812081c329
Merge pull request from kamalesh-babulal/ppc64le_callback
[RFC] PC64le - do not use the patched functions as callbacks directly
2018-03-24 15:49:22 -04:00
Joe Lawrence
4d5febd4a8 sparse: quiet latest trivial complaints
Fixes sparse warnings:

  kmod/core/core.c:142:20: warning: symbol 'trace' was not declared. Should it be static?

  livepatch-patch-hook.c:73:18: warning: symbol 'lpatch' was not declared. Should it be static?

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-03-23 16:20:45 -04: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
64173f4f1d scripts: small ShellCheck cleanups
Cleanup some of the new bash script code to appease 'make check':

  - kpatch: Use integer comparison for $MAX_LOAD_ATTEMPTS
  - kpatch-build: Quote ${TEMPDIR} variable

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-03-23 10:27:35 -04:00
Joe Lawrence
7e1b495f52
Merge pull request from joe-lawrence/fedora-27-rebase
testing fedora 27: rebase integration test patches
2018-03-22 14:43:48 -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 .

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2018-03-22 14:36:34 -04:00
Joe Lawrence
4a0b3541be
Merge pull request from jpoimboe/plugin-fix
gcc-plugin: run the plugin at an earlier pass
2018-03-22 14:32:10 -04:00
Joe Lawrence
5ec00a0bfd
Merge pull request from sm00th/extsym
Undefined reference failure logic rework
2018-03-22 14:20:02 -04:00
Joe Lawrence
0f17a019be
Merge pull request from jpoimboe/include-logic-rewrite
create-diff-object: refactor symbol/section inclusion logic
2018-03-22 13:06:09 -04:00
Joe Lawrence
4031927f13
Merge pull request from jpoimboe/gitignore
gitignore: ignore cache.mk from newer kernel builds
2018-03-22 10:44:27 -04:00
Joe Lawrence
2aa75f268f
Merge pull request from jpoimboe/lookup-fix
lookup: fix discarded symbol handling for all kernel versions
2018-03-22 10:43:50 -04:00
Josh Poimboeuf
fefa67554b
Merge pull request from cardoe/drop-rpmdevtools
drop unused rpmdevtools dependency
2018-03-21 22:34:03 -05:00
Josh Poimboeuf
f1d71ac846 create-diff-object: refactor symbol/section inclusion logic
kpatch_include_symbol() is confusing.  Refactor it:

- Remove the "inclusion tree" debug messages.  I never use them, and
  they just help make the code more confusing and the debug output more
  cluttered.

- Split it up into two functions: kpatch_include_symbol() and
  kpatch_include_section(), so that kpatch_include_section() can be used
  elsewhere.

- Call kpatch_include_section() from kpatch_include_standard_elements().
  This covertly fixes , by also including the .rela.rodata section.

- Add a bunch of comments to clarify some of the trickier points.

Fixes .
Fixes .

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-03-21 21:36:33 -05: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
Josh Poimboeuf
d4e4258172 gitignore: ignore cache.mk from newer kernel builds
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-03-21 13:22:26 -05:00
Josh Poimboeuf
b811940173 lookup: fix discarded symbol handling for all kernel versions
Fix discarded symbol handling for all kernel versions.

Fixes .

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2018-03-21 13:19:31 -05:00