Commit Graph

722 Commits

Author SHA1 Message Date
Seth Jennings
9b86df0eee Merge pull request #344 from jpoimboe/verbose
__verbose special section support
2014-08-04 16:58:01 -05:00
Seth Jennings
822b2a5655 Merge pull request #342 from jpoimboe/kpatch-printk
macros: add KPATCH_PRINTK macro
2014-08-04 13:39:01 -05:00
Josh Poimboeuf
b4b0f76e4c compare __func__ references by value
Fixes the following error:

    kpatch_correlate_static_local_variables: 850: found another static local variable matching __func__.49968 in patched .rela__verbose
2014-08-04 13:17:18 -05:00
Josh Poimboeuf
1bb9b81db1 detect .rodata.* bundled sections
Detect .rodata.* bundled sections so that .rodata.__func__.* relocation
references can be converted to refer to their corresponding object
symbols.

Fixes the following error:

    kpatch_correlate_static_local_variables: 830: static local variable __func__.49968 not used
2014-08-04 13:17:18 -05:00
Josh Poimboeuf
f1775ec73d don't correlate __verbose statics
The __verbose section stores several static local structs named
"descriptor".  These structs contain information related to dynamic
debugging printks and are specific to the patched object, so they
shouldn't be correlated with their base object counterparts.

Fixes the following error:

    kpatch_correlate_static_local_variables: 830: static local variable descriptor.49967 not used
2014-08-04 13:17:18 -05:00
Seth Jennings
c93b723dfb Merge pull request #329 from terrywang/ubuntu-mirror
kpatch-build and README.md update
2014-08-04 12:07:29 -05:00
Josh Poimboeuf
a8a037271d macros: add KPATCH_PRINTK macro
Use this instead of calling printk to avoid unwanted compiler
optimizations which cause kpatch-build errors.

The printk function is annotated with the __cold attribute, which tells
gcc that the function is unlikely to be called.  A side effect of this
is that code paths containing calls to printk might also be marked cold,
leading to other functions called in those code paths getting moved into
.text.unlikely or being uninlined.

This macro places printk in its own code path so as not to make the
surrounding code path cold.

I have a related integration test to add, but right now it's broken
because we don't yet properly support the __verbose special section.
That'll be another PR.

Fixes #296.
2014-07-31 23:11:20 -05:00
Josh Poimboeuf
4e0ec591e3 macros: document more implications of KPATCH_FORCE_UNSAFE 2014-07-31 13:54:15 -05:00
Josh Poimboeuf
6ed046f1c2 Merge pull request #341 from jpoimboe/0.1.10
0.1.10 release
2014-07-31 11:23:49 -05:00
Josh Poimboeuf
6a2b4bb93c 0.1.10 release 2014-07-31 11:22:08 -05:00
Terry Wang
a56d48e19d kpatch-build: remove unneeded comments readme: roll back unneeded changes 2014-07-30 20:08:17 +10:00
Seth Jennings
aa6f510bc0 Merge pull request #339 from jpoimboe/module-name-fixes
module name fixes
2014-07-29 20:59:39 -05:00
Seth Jennings
57a8fb352e Merge pull request #338 from jpoimboe/kpatch-build-usage
kpatch-build: don't show full kpatch-build path in usage message
2014-07-29 20:54:33 -05:00
Josh Poimboeuf
4f91924d7e kpatch-build: truncate long patch names
Otherwise the module name listed in /proc/modules is corrupted due to an
array buffer overrun.
2014-07-29 17:02:48 -05:00
Josh Poimboeuf
a0756a5f1d kpatch-build: convert spaces in patch name to '-' 2014-07-29 17:02:10 -05:00
Josh Poimboeuf
749da4f261 kpatch-build: don't show full kpatch-build path in usage message
For interface consistency with other unix utilities.
2014-07-29 16:46:12 -05:00
Seth Jennings
c884811bb9 Merge pull request #337 from jpoimboe/core-module-path
kpatch: change core module path again
2014-07-29 09:44:20 -05:00
Josh Poimboeuf
ec77b26c76 kpatch: change core module path again
On RHEL I'm seeing issues with putting the core module in the "extra"
path.  On the next depmod run, it gets added to modules.dep, and on a
subsequent kpatch install I see the following errors:

    /usr/lib/dracut/modules.d/50drm/module-setup.sh: line 26: /lib/modules/3.10.0-123.4.4.el7.x86_64//weak-updates/kpatch/kpatch.ko: No such file or directory
    /usr/lib/dracut/modules.d/90kernel-modules/module-setup.sh: line 14: /lib/modules/3.10.0-123.4.4.el7.x86_64//weak-updates/kpatch/kpatch.ko: No such file or directory
    modinfo: ERROR: Module /lib/modules/3.10.0-123.4.4.el7.x86_64/weak-updates/kpatch/kpatch.ko not found.

Until the core module gets merged into Linux, I think we can put it in
/usr/lib/kpatch, which is also where the patch modules are going to be
delivered in the RHEL RPM.

Making sure the other options still work with the kpatch utility for
now, so as to keep backwards compatibility between a newer kpatch
utility and older core modules.  We can break this compatibility for
kpatch 0.2.0.
2014-07-28 20:30:20 -05:00
Josh Poimboeuf
7db96adb9c Merge pull request #335 from spartacus06/user-libdir
allow user-defined LIBDIR in install paths
2014-07-28 15:55:43 -05:00
Seth Jennings
fe9dd75f56 Merge pull request #334 from jpoimboe/revert-warn-macros
Revert "add KPATCH_WARN_*_LINE macros"
2014-07-28 15:14:35 -05:00
Josh Poimboeuf
c260364882 Revert "add KPATCH_WARN_*_LINE macros"
This reverts commit 57b51d0bdc.

Probably no longer needed now that we have KPATCH_IGNORE_FUNCTION and
KPATCH_IGNORE_SECTION.
2014-07-28 15:04:25 -05:00
Josh Poimboeuf
b68dec7d22 Merge pull request #332 from spartacus06/ignore-sections
add KPATCH_IGNORE_SECTION support (plus fixups)
2014-07-28 15:03:40 -05:00
Seth Jennings
392049a283 make symbol section change an error
make symbol section change an error, except when moving out of an
ignored section

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 14:09:33 -05:00
Seth Jennings
ebf55f8614 add support for replacing section syms for unbundled sections
Right now, the test patch unnecessarily includes hrtimer_nanosleep()
because the call to do_nanosleep() generates a rela the references the
unbundled .sched.text section.  This section symbol is not currently
replaced by kpatch_replace_sections_syms() as it only replaces bundled
sections symbols.

This commit adds logic to kpatch_replace_sections_syms() to replace
unbundled section symbols as well by scanning the symbol table for
symbols that start at the rela entry's offset within the matching
section.

This allows for properly rela section correlation when the functions
have moved from an unbundled section to a bundled section.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 11:10:32 -05:00
Seth Jennings
8ac20f5475 add KPATCH_IGNORE_SECTION support
This macro is for ignoring sections that may change as a side effect of
another change or might be a non-bundlable section; that is one that
does not honor -ffunction-section and create a one-to-one relation from
function symbol to section.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 11:10:32 -05:00
Seth Jennings
da45b84bbc Merge pull request #333 from goldyfruit/master
kmod/core/Makefile: update the Makefile for Debian Like
2014-07-28 09:58:22 -05:00
Gaetan Trellu
52ad9452ba kmod/core/Makefile: update the Makefile for Debian Like 2014-07-28 10:50:03 -04:00
Josh Poimboeuf
02f97cda44 Merge pull request #330 from goldyfruit/master
kpatch: update the kpatch version and the man and the kmod/core/Makefile
2014-07-28 09:31:33 -05:00
Seth Jennings
11f8f8da76 mark mcount sections as SAME
Right now, in the case that the mcount sections have changed, we get a
"changed section not included" error on them.  Since we rebuild them
from scratch, just mark them as SAME even if they are different so that
we don't cause an error.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 09:29:46 -05:00
Seth Jennings
85da92132f s/funcs/functions/g
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-28 09:29:46 -05:00
Josh Poimboeuf
02e1a824d9 Merge pull request #331 from spartacus06/dont-check-shlink
remove sh_link from section comparison
2014-07-28 09:00:32 -05:00
Terry Wang
d5bb38d42d readme: update, add RHEL 7 as supported distro, break up long lines and beautify using GitHub flavored markdown 2014-07-28 21:23:08 +10:00
Seth Jennings
5a4756bbb8 remove sh_link from section comparison
This sh_link line currently has a bug with both operands being sec1; the
second should be sec2.  However the bug is masking a logical flaw; that
is that the sh_link is the index of either the symtab or the strtab and
that can change if sections have been added or removed by the patch.

This commit removes the comparison.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-25 09:35:34 -05:00
Gaetan Trellu
a44fbf3f8b kpatch: update the kpatch version and the man 2014-07-25 09:33:41 -04:00
Terry Wang
cde33f13ed kpatch-build: use close archive mirror for Ubuntu for speed 2014-07-25 21:08:20 +10:00
Seth Jennings
4e41f39853 Merge pull request #328 from jpoimboe/static-local-vars
support for gcc static local variable naming
2014-07-24 17:23:30 -05:00
Josh Poimboeuf
9c3c9b0c0a support for gcc static local variable renaming
gcc renames static local variables by appending a period and a number.
For example, __key could be renamed to __key.31452.  Unfortunately this
number can arbitrarily change.  Try to rename the patched version of the
symbol to match the base version and then correlate them.

Fixes #313.
2014-07-24 15:08:15 -05:00
Josh Poimboeuf
402911b949 replace section symbols before correlating
The correlation logic could get confused if it compares two relas whose
symbols haven't been converted from section symbols to object or
function symbols.  So we should replace section symbols for both the
base and the patched object before correlating, so that it can compare
the function and object symbols rather than the section symbols.

This is also a prerequisite for dealing properly with gcc's renaming of
static local variables, because relas which reference static locals
usually use section symbols.
2014-07-24 14:51:57 -05:00
Josh Poimboeuf
ce8bb40fc0 Merge pull request #327 from spartacus06/make-all
remove build pass from kpatch-build
2014-07-23 11:30:53 -05:00
Seth Jennings
5321b21aa0 fixup review comments
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 11:24:02 -05:00
Seth Jennings
9a2f8c5c44 remove build pass from kpatch-build
Now that we use the vmlinux from the distro debug package we don't need
to do any build runs without -ffunction-sections -fdata-sections.

Old:
Build orig in objdir
Build patched in objdir
Build orig w/ flags in objdir2
Copy orig .o's into orig
Build patched w/ flags in objdir2
Copy patched .o's into patched

New:
Build orig w/ flags in objdir
Build patched w/ flags in objdir
Copy patched .o's into patched
Build orig w/ flags in objdir
Copy orig .o's into orig

This commit also does try to build each change object singularly since
there are cases in the kernel tree where the Makefile does not reside in
the same directory as the changed object.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 10:03:00 -05:00
Seth Jennings
c40d164931 Merge pull request #326 from jpoimboe/unload-all
kpatch: add unload --all command
2014-07-23 09:50:12 -05:00
Josh Poimboeuf
d707c4062d kpatch: add unload --all command
This may end up being useful in the distro patch module upgrade path.
If the core module also needs updating, we can first do "kpatch unload
--all" and "rmmod kpatch" before doing "kpatch load" of the new patch
module.
2014-07-23 09:16:11 -05:00
Josh Poimboeuf
77c8700888 Merge pull request #323 from spartacus06/ignore-funcs-v2
add support for manually ignore functions
2014-07-23 09:01:55 -05:00
Seth Jennings
84618404e0 add support for manually ignore functions
This commit adds the KPATCH_IGNORE_FUNC() macro for ignoring functions
that may change as a side effect of a change in another function.  The
WARN class of macros, for example, embed the line number in an
instruction, which will cause the function to be detected as changed
when, in fact, there has been no functional change.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-23 09:00:16 -05:00
Seth Jennings
063668477c Merge pull request #320 from goldyfruit/master
readme.md: add support for Debian GNU/Linux Wheezy (7.x)
2014-07-21 09:25:32 -05:00
Gaetan Trellu
f69a9400eb readme.md: add support for Debian GNU/Linux Wheezy (7.x) 2014-07-20 22:53:50 -04:00
Josh Poimboeuf
434ed7a10e Merge pull request #319 from spartacus06/fix-msgs
fix logging in kpatch_verify_patchability()
2014-07-18 16:02:36 -05:00
Seth Jennings
bdb44e7594 fix logging in kpatch_verify_patchability()
log_normal() already prints the objname; no need to do it again

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-07-18 15:29:46 -05:00
Seth Jennings
1c8e8a7d57 Merge pull request #317 from jpoimboe/module-old-addr-fix
kmod/core: module old_addr fix
2014-07-18 10:44:25 -05:00