Commit Graph

746 Commits

Author SHA1 Message Date
Seth Jennings
e020127eea allow patches that only contains hook functions
Fixes #357

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-13 11:28:43 -05:00
Seth Jennings
c8c69a8eaa Merge pull request #355 from jpoimboe/rhel7-tmp-obj-fix
kpatch-gcc: fix for .tmp_* objects on RHEL 7
2014-08-12 23:08:14 -05:00
Josh Poimboeuf
7b4ee86197 kpatch-gcc: fix for .tmp_* objects on RHEL 7
On RHEL 7 I see the following error when trying to patch meminfo.o:

    cp: cannot stat ‘/home/user/.kpatch/obj/fs/proc/.tmp_meminfo.o’: No such file or directory

It turns out that on RHEL 7, a given object foo.o is compiled as
.tmp_foo.o before then being linked as foo.o.  I have no idea why.  The
fix is to record .tmp_foo.o as foo.o in the changed_objs file.
2014-08-12 21:21:53 -05:00
Josh Poimboeuf
0efd8b0f2b Merge pull request #354 from spartacus06/diff-tree-tests
add difftest.sh test
2014-08-12 11:05:00 -05:00
Seth Jennings
a59607742e add difftest.sh test
The purpose of this test script is to determine if create-diff-object
can properly recognize object file equivalence when passed the same file
for both the original and patched objects.  This verifies that
create-diff-object is correctly parsing, correlating, and comparing the
different elements of the object file.  In practice, a situation similar
to the test case occurs when a commonly included header file changes,
causing Make to rebuild many objects that have no functional change.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-12 10:50:46 -05:00
Josh Poimboeuf
78afb8f999 Merge pull request #353 from spartacus06/group-section-support
Group section support
2014-08-11 22:47:41 -05:00
Seth Jennings
e1e694db4b review fixups
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-11 22:41:09 -05:00
Seth Jennings
a0e6dce9af cleanup kpatch_correlate_symbols()
This commit inverts some logic to reduce the max indentation

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-11 17:24:05 -05:00
Seth Jennings
bf86555e06 add correlation and compare support for GROUP sections
GROUP section are rare and are a mechanism in the ELF to indicated that
certain groups of section must be included or excluded (stripped)
together.

It is valid to have more than one of these section with the same
".group" name.  This currently messes up the section correlation code
with correlates based solely on name.

This commit adds additional correlation criteria for GROUP sections;
namely, the section content must be the same.  Changing of groups
sections (i.e. reindexing of the section indexes the GROUP section
includes in their section data) is not supported and will result in a
"new/changed section not included" error.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-11 17:24:05 -05:00
Seth Jennings
2990bb790a Merge pull request #346 from flaming-toast/testmod
testmod/doit.sh: set KBUILD_EXTRA_SYMBOLS to include core module's symbols
2014-08-08 16:56:18 -05:00
Josh Poimboeuf
4a72525e0d Merge pull request #350 from spartacus06/support-unbundled-mangled-functions
support renaming of mangled functions in unbundled sections
2014-08-08 15:26:24 -05:00
Seth Jennings
e483cda793 support renaming of mangled functions in unbundled sections
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-08 15:20:31 -05:00
Seth Jennings
41615c9b9c Merge pull request #349 from jpoimboe/system_certificates
upstream kernel fixes
2014-08-08 14:49:54 -05:00
Josh Poimboeuf
a600f1d117 kpatch-build: don't link unchanged objects
The FILES variable can contain unchanged objects, so don't use it to
determine which objects to link.  Instead, just use all the objects that
were placed in the output directory by create-diff-object.
2014-08-08 14:22:17 -05:00
Josh Poimboeuf
1b9868ed33 kpatch-gcc: exclude system_certificates.o
Fixes the following issue when running kpatch-build against the latest
upstream kernel:

    system_certificates.o: no changed functions were found
2014-08-08 14:18:46 -05:00
Josh Poimboeuf
e7cf064c62 kpatch-gcc: split up object exclusion list 2014-08-08 14:18:27 -05:00
Josh Poimboeuf
c5f138f88d Merge pull request #348 from spartacus06/allow-unchanged-object
allow for unchanged objects
2014-08-08 11:15:09 -05:00
Seth Jennings
fb5dbc2fc5 allow for unchanged objects
There are situations in which an object may be rebuilt but have no
functional changes, such as a change to an included header file.

This commit changes kpatch-build to tolerate individual unchanged
objects so long as there is, in the end, at least one changed object.

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-08 10:26:36 -05:00
Josh Poimboeuf
ad407d992e Merge pull request #347 from spartacus06/change-build
restructure building process
2014-08-07 17:40:16 -05:00
Seth Jennings
b98fafcfb2 restructure building process
Right now, we do three build passes: one to build the original tree
(full) build, one to build the patch tree (diff build), then one to
rebuild original objects that where changed by the patch (diff build).

This is going to be a problem when we try to support (near) full tree
rebuilds due to changes in commonly included header files.

This commit changes the build process to intercept calls to gcc by make
using the CROSS_COMPILE environment variable and, during the patched
build phase, copies the original object for any object that is about to
rebuilt due to a change.

This reduces the number of build passes to the minimum possible (two).

Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-07 17:25:05 -05:00
Seth Jennings
191e389b43 fix bad Module.symvers path
Signed-off-by: Seth Jennings <sjenning@redhat.com>
2014-08-07 17:24:53 -05:00
Jessica Yu
6933181c12 test/testmod/doit.sh: set KBUILD_EXTRA_SYMBOLS to include core module
symbols
2014-08-05 18:51:47 -07:00
Josh Poimboeuf
1cfe29213a Merge pull request #345 from jpoimboe/test-macro-printk
test: add KPATCH_PRINTK test
2014-08-04 17:03:46 -05:00
Josh Poimboeuf
e2f706877d test: add KPATCH_PRINTK test 2014-08-04 17:03:23 -05:00
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