Commit Graph

1086 Commits

Author SHA1 Message Date
Martin Carroll
145d1289dc kpatch-build: do not assume that TEMPDIR is unexported on entry to script
The user's environment might have TEMPDIR exported.  If so, then kpatch-build
dies with a bogus "invalid ancestor" error. If you turn those bogus errors into
warnings, then the script goes on to incorrectly put into the generated .ko file
every single function that was compiled in the *original* kernel build, thereby
producing an immense .ko file with more than 64k sections that the linux kernel
cannot load.  This fix makes sure that TEMPDIR is unexported on the build of the
original kernel.  Actually, this fix uses a separate KPATCH_GCC_TEMPDIR variable,
so that if the kernel build is interrupted, the cleanup function in the kpatch-kbuild
script will still have TEMPDIR set correctly.

Signed-off-by: Martin Carroll <martin.carroll@alcatel-lucent.com>
2016-07-25 11:02:37 -04:00
Jessica Yu
649764db02 Merge pull request #603 from jpoimboe/warn_on_once
create-diff-object: fix WARN*_ONCE detection on newer kernels
2016-07-15 11:07:36 -07:00
Josh Poimboeuf
6b03bc8ec0 create-diff-object: fix WARN*_ONCE detection on newer kernels
This fixes the detection of WARN_ON_ONCE, WARN_ONCE, and WARN_TAINT_ONCE
on Linux 4.6 and newer.

The signature for those macros changed with upstream Linux commit
dfbf2897d004 ("bug: set warn variable before calling WARN()").

Fixes #602.
2016-07-13 16:53:02 -05:00
Josh Poimboeuf
f678f31898 Merge pull request #601 from flaming-toast/kpatch-elf
Introduce a common kpatch-elf "api"
2016-07-13 10:31:11 -04:00
Jessica Yu
a343edcff0 kpatch-elf: make is_bundleable() a static function
Since is_bundleable() is only called once by kpatch_create_symbol_list(),
and no other kpatch-build tool will need to call this function, we can
simply make it static and local to kpatch-elf.c
2016-07-12 14:45:18 -07:00
Jessica Yu
adcd4581cc kpatch-elf: introduce a common kpatch-elf and logging interface
Introduce a common kpatch elf api by moving all functions and struct
declarations related to manipulating kpatch_elf objects from
create-diff-object to kpatch-elf.{h,c}. Move logging macros to a separate
file log.h, and have kpatch-elf.h include it. These changes will generalize
the kpatch-elf and logging api and make it available to other kpatch-build
tools.
2016-07-12 14:45:16 -07:00
Josh Poimboeuf
8e54471f4a Merge pull request #600 from arges/patch-1
Add section on removing static local references.
2016-07-01 17:07:39 -04:00
Josh Poimboeuf
e6b02cc25c Merge pull request #596 from flaming-toast/altinstructions
Only include .altinstr_replacement if .altinstructions is also included
2016-07-01 17:06:33 -04:00
Jessica Yu
cfe9aff51e create-diff-object: include .altinstr_replacement if .altinstructions is included
Including the .altinstr_replacement section by itself and without
.altinstructions doesn't make sense, as it only serves as a memory area to
hold replacement instructions to be copied over when alternatives are
applied. Don't include .altinstr_replacement unconditionally and only
include it when .altinstructions is also marked as included.
2016-07-01 12:33:28 -07:00
Chris J Arges
b28c2b0638 Add section on removing static local references.
This was discovered when trying to patch a netfilter issue and resulted in the following issue:
https://github.com/dynup/kpatch/issues/599

This patch adds some documentation in case this situation is encountered in the future.
2016-07-01 14:21:29 -05:00
Jessica Yu
03ef5a2ff4 Merge pull request #595 from rosslagerwall/install-fix
kmod: Fix install path
2016-05-06 11:35:59 -07:00
Ross Lagerwall
075c4745f0 kmod: Fix install path
When building against a different kernel from the one that is currently
running, install the kernel module to a directory based on the version
of the target kernel rather than the currently running kernel.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2016-05-06 10:47:43 +01:00
Josh Poimboeuf
71afb17143 Merge pull request #594 from NonerKao/master
kpatch-build: Add "CONFIG_DEBUG_KERNEL" kernel config checking
2016-05-02 22:28:51 -05:00
Quey-Liang Kao
f4686ee7df kpatch-build: Add "CONFIG_DEBUG_KERNEL" kernel config checking
While the officially supported distributions all have
CONFIG_DEBUG_KERNEL enabled, this is not true for some other
distributions.
This option is necessary when kpatch-build retrieves the
SPECIAL_VARS using readelf command.

Signed-off-by: Quey-Liang Kao <s101062801@m101.nthu.edu.tw>
2016-05-03 04:49:30 +08:00
Josh Poimboeuf
8256149124 Merge pull request #592 from flaming-toast/584
kmod/core: fix stacktrace_ops 'address' function prototype for 4.6
2016-04-28 16:06:16 -05:00
Jessica Yu
684171acc7 kmod/core: fix stacktrace_ops 'address' function prototype for 4.6
Upstream commit 568b329a "perf: generalize perf_callchain" modified the
return type (void -> int) of the address member of struct stacktrace_ops.
Use the void function if the kernel version is < 4.6 or return an int
otherwise.
2016-04-27 14:40:28 -07:00
Jessica Yu
f7db7947f8 Merge pull request #591 from jpoimboe/taint-livepatch
kmod/core: TAINT_USER -> TAINT_LIVEPATCH
2016-04-14 15:19:41 -07:00
Josh Poimboeuf
c56c411b2a kmod/core: TAINT_USER -> TAINT_LIVEPATCH
Ok, technically it's not livepatch.  But it's close enough, and more
accurate than TAINT_USER.
2016-04-14 16:28:49 -05:00
Jessica Yu
d2d1f639b2 Merge pull request #590 from euspectre/paravirt-alt-reloc-fix
kmod/core: Skip relocations of already altered instructions
2016-04-11 10:41:37 -07:00
Evgenii Shatokhin
8dac9d0871 kmod/core: Skip relocations of already altered instructions
When a patch module is loaded, the kernel facilities like alternatives
and paravirt may alter some of its instructions. This happens before
Kpatch core module is notified and tries to apply dynrelas to it. If an
instruction to apply a dynrela to has already been changed by these
facilities, an incorrect instruction might be written as a result.

The core module now detects such conditions and does not apply dynrela
to the changed instructions.

Suggested by Josh Poimboeuf in the discussion of
https://github.com/dynup/kpatch/issues/580.

Changes in v.2:
* Used pr_notice to give more emphasis to the messages.
* Added an explanation message.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2016-04-11 15:11:35 +03:00
Jessica Yu
7eda8dab6d Merge pull request #588 from euspectre/kpatch-service-enable0
contrib/service: allow to turn the service off at boot time
2016-04-05 15:18:15 -07:00
Evgenii Shatokhin
20eddbac0c contrib/service: allow to turn the service off at boot time
It may be convenient to be able to turn off the automatic loading of
the patches that kpatch.service does. This helps, for example, if a
buggy patch is installed and crashes the system at boot.

This commit allows to specify kpatch.enable=0 in the kernel command
line. In this case, the binary patches will not be loaded automatically,
and the users should be able to remove or replace the offending patches
after the system boots.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2016-04-04 16:52:40 +03:00
Jessica Yu
b156a786a6 Merge pull request #583 from euspectre/kpatch-build-livepatch-fix
kpatch-build: fix building of livepatch-based patches
2016-03-22 09:40:28 -07:00
Evgenii Shatokhin
6a76da9236 kpatch-build: fix building of livepatch-based patches
kpatch-build currently requires Module.symvers for the Kpatch core
module unconditionally and fails if it is not found. This does not allow
using kpatch-build to prepare livepatch-based patches.

This patch fixes the problem.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2016-03-22 16:14:07 +03:00
Jessica Yu
f80c2cf47e Merge pull request #582 from libin2015/process-the-patch-name
kpatch-build: process the patch name correctly
2016-03-01 15:30:36 -08:00
Li Bin
441ab87643 kpatch-build: process the patch name correctly
Process the patch name correctly that only concern the fuffix with
.patch or .diff. Otherwise if the patch name is not end with .patch
or .diff but has it as substring, the fuffix will be removed
unreasonably.

Signed-off-by: Li Bin <huawei.libin@huawei.com>
2016-02-27 11:24:27 +08:00
Josh Poimboeuf
706b63ad99 Merge pull request #581 from jpoimboe/new-version
bump version to 0.3.2
2016-02-17 15:37:18 -06:00
Josh Poimboeuf
a24b13cfb1 bump version to 0.3.2 2016-02-17 15:36:40 -06:00
Josh Poimboeuf
c85bb50ff7 Merge pull request #579 from flaming-toast/core_fix
kmod: core: use new module core_layout struct
2016-02-17 15:34:37 -06:00
Jessica Yu
85a055665e kmod: core: use new module core_layout struct
Commit 7523e4dc5057 upstream ("module: use a structure to encapsulate
layout") uses a new field to access module memory. Account for this change
and ensure backwards compatibility with kernel versions < 4.5
2016-02-17 13:13:46 -08:00
Josh Poimboeuf
83beb356ed Merge pull request #573 from arges/493
livepatch-patch-hook: add support for livepatch sympos structures
2016-02-17 08:57:06 -06:00
Chris J Arges
b64ab2b5e4 livepatch-patch-hook: add support for livepatch sympos
Support patching objects that have duplicated function names. This feature was
introduced upstream in Linux v4.5.

This patch appends the symbol position to the symbol structure when
lookup_local_symbol is called. This pos variable is then used when creating the
funcs and dynrelas sections. Finally, incorporate sympos into the livepatch
patch hook only if the kernel version is greater than v4.5. In other cases the
older format is used.

Fixes: #493

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
2016-02-16 10:31:44 -06:00
Jessica Yu
08f55afa0a Merge pull request #575 from arges/packaging
Changes to make packaging easier
2016-02-10 12:12:45 -08:00
Chris J Arges
e9b9654602 Makefile: add BUILDMOD parameter to select building kmod core
In some cases when packaging it may not be useful to build kmod/core at
package build time (for example if using DKMS). Add a parameter 'BUILDMOD'
that when set to 'yes' will build kmod/core.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
2016-02-10 09:55:45 -06:00
Chris J Arges
3c8f5f7bfa Makefile: determine kernel release in Makefile
Don't assume we are building for the current kernel. In addition print out
a proper package necessary for building the module.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
2016-02-10 09:46:38 -06:00
Chris J Arges
06ad01b784 Makefile: make libexec a parameter
Some distributions prefer not to use /usr/libexec. To make things easier
for packaging, allow this directory to be set easily via environment
variables.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
2016-01-12 20:12:59 -06:00
Chris J Arges
053622b902 kpatch-build: allow external LDFLAGS
When building binaries such as create-diff-object it would be useful
to be able to pass LDFLAGS when running make from the command line.
2016-01-11 14:26:50 -06:00
Seth Jennings
b8c224c6c0 Merge pull request #569 from terrywang/fedora-23
readme: add support for Fedora 23
2015-12-07 09:11:27 -06:00
Terry Wang
580acabdc0 readme: update Fedora support information 2015-12-05 00:07:52 +11:00
Terry Wang
85c5cc224f readme: remove out-dated Fedora 21 2015-12-01 13:58:49 +11:00
Terry Wang
701e5c0a34 readme: add support for Fedora 23 2015-11-26 23:59:55 +11:00
Seth Jennings
b60d3acddb Merge pull request #560 from euspectre/get-kernel-version
Get kernel version from vmlinux if the kernel source tree is used
2015-11-18 15:28:42 -06:00
Seth Jennings
b781c0a843 Merge pull request #564 from jpoimboe/more-static-fixes
create-diff-object: static local uncorrelation/correlation fixes
2015-11-18 15:15:27 -06:00
Josh Poimboeuf
792a4fc537 Merge pull request #563 from jpoimboe/gcc-check
revert gcc check changes
2015-11-18 15:13:30 -06:00
Josh Poimboeuf
02d3c193ed create-diff-object: static local uncorrelation/correlation fixes
The uncorrelation logic is incomplete.  For bundled symbols, in addition
to uncorrelating the sections, it should also uncorrelate the section
symbols and any rela sections.

Similarly the correlation logic needs to correlate section symbols.  (It
already correlates rela sections.)
2015-11-18 14:56:02 -06:00
Josh Poimboeuf
707435ec62 Revert "kpatch-build: fix gcc_version_check"
This reverts commit 9fedd0d283.
2015-11-18 14:44:45 -06:00
Josh Poimboeuf
7b48c4ce12 Revert "kpatch-build: fix gcc_version_check: both "GNU" and "GCC" are possible"
This reverts commit 5737028667.
2015-11-18 14:44:26 -06:00
Josh Poimboeuf
f4b5eded0c Merge pull request #561 from euspectre/gcc-gnu-fix
kpatch-build: fix gcc_version_check: both "GNU" and "GCC" are possible
2015-11-18 10:28:18 -06:00
Josh Poimboeuf
129fb4a22b Merge pull request #551 from libin2015/reduce-dependency-on-bash-version
kpatch-build: reduce dependency on bash version >4.0
2015-11-17 08:35:52 -06:00
Evgenii Shatokhin
e169d82192 kpatch-build: get kernel version from vmlinux if source tree is used
If a kernel SRPM is used to get the kernel sources, the target kernel
version is determined from the name of the SRPM.

One cannot obtain the target kernel version this way if the source tree
is used instead of an SRPM, so let us extract that information from
vmlinux.

Signed-off-by: Evgenii Shatokhin <eshatokhin@odin.com>
2015-11-17 16:41:16 +03:00