Commit Graph

1109 Commits

Author SHA1 Message Date
Jessica Yu
a963ee76ee Merge pull request #631 from jpoimboe/treewide-rebuild-fixes
kpatch-build: fix tree-wide rebuild
2016-12-09 16:17:15 -08:00
Jessica Yu
6a6ff7e8ef Merge pull request #632 from jpoimboe/rhel-rebuild-workaround
kpatch-build: fix tree-wide rebuild on RHEL 7
2016-12-09 14:54:24 -08:00
Josh Poimboeuf
1fc364ee75 kpatch-build: fix tree-wide rebuild on RHEL 7
On RHEL 7 based kernels, copy_user_64.o misuses the .fixup section by
placing a normal function in it.  That confuses create-diff-object.

Work around it by just skipping the file altogether, which is fine to do
because it's an assembly file which should never change anyway.

Fixes #625.
2016-12-06 21:54:05 -06:00
Josh Poimboeuf
5f5fd136bb kpatch-build: fix tree-wide rebuild
For newer kernels, some new objects have been added to the 'head-y'
build target.  These objects aren't directly traceable to vmlinux so
they have to be added manually.

Fixes #626.
2016-12-05 21:13:15 -06:00
Jessica Yu
6fa5360c22 Merge pull request #620 from joe-lawrence/617_KASLR_support
Add CONFIG_RANDOMIZE_BASE KASLR support
2016-11-29 13:31:02 -08:00
Joe Lawrence
a6133bba08 Add CONFIG_RANDOMIZE_BASE KASLR support
Backport the symbol lookup and checking code from upstream livepatch
code that relies on a symbol position enumeration rather than a fixed
memory address.

Fixes #617.
2016-11-29 13:55:34 -05:00
Jessica Yu
dc3ef4d6da Merge pull request #616 from rosslagerwall/extable-addend
create-diff-object: Update fixup offsets in .rela__ex_table
2016-11-24 20:04:46 -08:00
Ross Lagerwall
13d61012f9 create-diff-object: Update fixup offsets in .rela__ex_table
When pruning entries from the fixup table, update the offsets in
.rela__ex_table otherwise the relas might point to the wrong fixup entry
or even out of the .fixup section.

Fixes #615.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2016-11-24 09:15:48 +00:00
Jessica Yu
e0d176465d Merge pull request #622 from jpoimboe/patch-author-guide-updates
doc: some patch author guide updates
2016-11-22 16:51:03 -08:00
Josh Poimboeuf
7535471b1d doc: some patch author guide updates
Update the patch author guide to reflect some recent experiences (with
upstream commits 19be0eaffa3a and 906c55579a63).
2016-11-18 10:59:07 -06:00
Josh Poimboeuf
f47d4c6cfc Merge pull request #621 from flaming-toast/dirty-srcdir
kpatch-build: refresh git index during cleanup if $SRCDIR was a git repository
2016-11-16 11:31:46 -06:00
Jessica Yu
de63a856c0 kpatch-build: refresh git index during cleanup if $SRCDIR was a git repository
If $SRCDIR was a git repo, we leave the repo with a dirty index even after
reversing the patch during cleanup. This gets picked up by
scripts/setlocalversion and consequently subsequent kpatch-builds using the
same $SRCDIR end up with a '+' sign appended to the version string. Fix
this by properly refreshing the index during cleanup.
2016-11-16 02:03:25 -08:00
Jessica Yu
ab012ab5d2 Merge pull request #619 from jpoimboe/kpatch-build-remove-git-dir
kpatch-build: remove ~/.kpatch/src/.git dir on Fedora
2016-11-15 14:22:00 -08:00
Josh Poimboeuf
d200d40569 kpatch-build: remove ~/.kpatch/src/.git dir on Fedora
Source RPMs for recent Fedora kernels have a '.git' subdirectory, which
causes '+' to be appended to the module version magic, causing the
module to fail to load:

  kpatch_readdir: version magic '4.8.6-201.fc24.x86_64+ SMP mod_unload ' should be '4.8.6-201.fc24.x86_64 SMP mod_unload '
2016-11-10 16:50:11 -06:00
Jessica Yu
4e1a5962da Merge pull request #611 from flaming-toast/v0.3.4
bump version to 0.3.4
2016-10-11 11:31:42 -07:00
Jessica Yu
2935ec3de0 bump version to 0.3.4 2016-10-11 11:28:44 -07:00
Josh Poimboeuf
7e00c94c4f Merge pull request #610 from joe-lawrence/skipcleanup
Add kpatch-build --skip-cleanup option
2016-10-11 13:14:42 -05:00
Joe Lawrence
86ba41ee06 Add kpatch-build --skip-cleanup option
Add a switch to kpatch-build that provides an opt-out to the cleanup
portion of the script.  This can be handy when debugging $TEMPDIR or
$RPMTOPDIR contents, as well as inspecting the patched source code
itself.
2016-09-29 16:30:38 -04:00
Josh Poimboeuf
fa557bd11d Merge pull request #609 from jpoimboe/v0.3.3
bump version to 0.3.3
2016-08-19 13:40:18 -04:00
Josh Poimboeuf
6645f8ef44 bump version to 0.3.3 2016-08-19 12:39:24 -05:00
Jessica Yu
835fc0474f Merge pull request #608 from jpoimboe/ipmodify
kmod/core: use FTRACE_OPS_FL_IPMODIFY flag
2016-08-19 10:33:07 -07:00
Josh Poimboeuf
3c7300c341 kmod/core: use FTRACE_OPS_FL_IPMODIFY flag
ftrace only allows a single user of this flag to register for a given
function.  This prevents kpatch conflicts with kprobes handlers which
also might want to change regs->ip for a function.

We should have done this a few years ago.  Better late than never...
2016-08-19 12:09:30 -05:00
Jessica Yu
c305c0b34f Merge pull request #605 from bearieq/master
kpatch-build: do not assume that TEMPDIR is unexported on entry to script
2016-07-25 19:01:56 -07:00
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