Commit Graph

1335 Commits

Author SHA1 Message Date
Juerg Haefliger
7770c18f93 kpatch-build: Fix the logfile checks for 'undefined'
The current checks never fail, because the first grep in the pipeline
doesn't write anything to stdout.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-10 08:51:41 +01:00
Juerg Haefliger
1950c193ec kpatch-build: Add -a, --archversion commandline option
This can be used for building a kpatch module for a non-running
kernel. Note that the correct kernel and debug packages still need
to be installed.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-10 08:50:22 +01:00
Juerg Haefliger
862327db3e kpatch-build: Fix indentation
Replace stray spaces with tabs, except in the usage output where tabs
don't make much sense.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-09 15:03:19 +01:00
Juerg Haefliger
15cdcc8b5f kpatch-build: Add -n, --name to the usage
Fixes: 8dc25d79d1b0 ('kpatch-build: let user specify kpatch module name')
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-09 15:03:19 +01:00
Juerg Haefliger
c33adf0ff2 kpatch-build: Remove unnecessary 'make prepare'
This was introduced in commit 5352d8b01a ('build objects in separate
directory to fix caching') but is no longer necessary.

Fixes: 2e99d6b7a4 ('kpatch-build: build the kernel in ~/.kpatch/src again')
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-09 15:03:06 +01:00
Josh Poimboeuf
d6bcffe954
Merge pull request #756 from juergh/fix-clean-rule
kpatch-build: Fix clean rule (remove insn/*.o)
2017-11-07 11:36:09 -06:00
Juerg Haefliger
b6ba60f740 kpatch-build: Fix clean rule (remove insn/*.o)
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
2017-11-07 13:18:42 +01:00
Joe Lawrence
64ba06606f Merge pull request #750 from jpoimboe/rhel75
Fix livepatch version checks for RHEL
2017-10-18 14:11:13 -04:00
Josh Poimboeuf
2e85ec5672 kpatch-build: add support for CONFIG_LIVEPATCH on RHEL
Fix the version checks for when we enable CONFIG_LIVEPATCH on RHEL.  It
will be based on the latest upstream code.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-10-18 06:33:27 -05:00
Josh Poimboeuf
d44a4b9df5 livepatch-patch-hook: clean up version checks
Clean up the kernel version checks a little bit.  Use 'HAVE_*' naming
everywhere for consistency.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-10-18 06:32:53 -05:00
Joe Lawrence
ae074693e0 Merge pull request #749 from jpoimboe/special-struct-padding
create-diff-object: handle missing padding at end of special section
2017-10-17 20:55:07 -04:00
Josh Poimboeuf
c2dc3836e8 create-diff-object: handle missing padding at end of special section
The paravirt_patch_site struct has 12 bytes of data and 4 bytes of
padding, for a total of 16 bytes.  However, when laying out the structs
in the .parainstructions section, the vmlinux script only aligns before
each struct's data, not after.  So the last entry doesn't have the
4-byte padding, which breaks kpatch_regenerate_special_section()'s
assumption of a 16-byte struct, resulting in a memcpy past the end of
the section.

Fixes #747.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-10-17 11:09:01 -05:00
Josh Poimboeuf
7d99acf6ad Merge pull request #744 from rudis/master
Shell quoting improvements and additional cleanup
2017-10-16 09:39:49 -05:00
Joe Lawrence
064f32ca4f Merge pull request #745 from jpoimboe/backwards-compatibility
kpatch: add ABI backwards compatibility
2017-10-13 13:28:59 -04:00
Josh Poimboeuf
9eed5d4bac kpatch: add ABI backwards compatibility
When running a kernel for a long period of time without rebooting, it's
possible that newer versions of the kpatch script may get installed.  So
new versions of the kpatch script need to support old versions of
kpatch.ko.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-10-13 10:30:23 -05:00
Simon Ruderich
70aa26a0c0 kpatch-build: always use spaces around pipes 2017-10-13 11:59:59 +02:00
Simon Ruderich
8173d35a15 kpatch-build: use grep -F to match plain strings
The pattern contains dots which are treated as any character but in this
case should only match a dot.
2017-10-13 11:57:07 +02:00
Simon Ruderich
c2a7f2449a kpatch-build: ignore false positives detected by shellcheck 2017-10-13 11:47:56 +02:00
Simon Ruderich
223c65015c kpatch-build: further shell code cleanup
Replace find * with find ./* to prevent treating files with dashes as
options. The leading ./ is later used in comparisons and thus must be
removed before that.

Found by shellcheck.
2017-10-13 11:45:06 +02:00
Simon Ruderich
73cf473a21 kpatch/kpatch: silence shellcheck warning
Hiding the return value isn't an issue here, but lets keep shellcheck
happy.
2017-10-13 08:53:06 +02:00
Simon Ruderich
554e8839e3 Makefile: add check target to run shellcheck 2017-10-13 08:52:16 +02:00
Simon Ruderich
14706bcd4d Makefile: add missing .PHONY targets 2017-10-13 08:51:23 +02:00
Josh Poimboeuf
3081c8874c Merge pull request #746 from rudis/doc
Documentation updates
2017-10-12 23:46:09 -05:00
Simon Ruderich
a51f9de534 README.md: use https:// for YouTube links 2017-10-12 17:32:12 +02:00
Simon Ruderich
b58c84fed0 README.md: add instructions for Debian 9 (Stretch) 2017-10-12 17:27:04 +02:00
Simon Ruderich
3507e30781 README.md: add release names to Debian versions
Also remove inconsistent minor version.
2017-10-12 17:27:04 +02:00
Simon Ruderich
c8fbe85d7f README.md: fix minor typo 2017-10-12 17:27:04 +02:00
Simon Ruderich
0b8a53163d kpatch-build: make gcc version check distribution independent
gcc --version varies too much for sane comparisons with vmlinux's
.comment section. Therefore compile a test file and compare its .comment
section.

Also fix gcc 4.8 check which used a lexicographically comparison which
will break for gcc versions >= 10. Instead check for the required
compiler options.

Closes #565.
2017-10-12 17:17:56 +02:00
Simon Ruderich
c06d17f020 doc: patch-author-guide: fix minor typo 2017-10-12 09:15:18 +02:00
Simon Ruderich
fa6a6dd821 kpatch-build: further shell code cleanup
- Replace grep | wc -l with grep -c.
- Use find -print0 and xargs -0 to handle non-alphanumeric filenames
  (shouldn't be an issue for us but it's good practice).
- Replace expr with $(( )).

Found by shellcheck.
2017-10-11 09:36:05 +02:00
Simon Ruderich
f796dc6014 kpatch-build: cleanup quoting of $UBUNTU_ABI
The double quotes are confusing as they don't quote $UBUNTU_ABI and thus
have no real effect. As $UBUNTU_ABI is a number simply remove them and
put $UBUNTU_ABI into the surrounding quotes.

Found by shellcheck.
2017-10-10 12:19:29 +02:00
Simon Ruderich
60e5125cb0 kpatch, kpatch-build: further shell code cleanup
- Replace echo $(cmd) with just cmd.
- Replace $@ inside quotes with $*.
- Always die if cd fails.
- Ensure rm -rf "$TEMPDIR"/* never expands to rm -rf /*.

Found by shellcheck.
2017-10-07 10:12:40 +02:00
Simon Ruderich
08fa04bb0d kpatch, kpatch-build, kpatch-gcc: quote all variables
Without proper quoting kpatch fails if the argument contains spaces, the
other scripts might be affected as well.

Not all new quotes are strictly necessary but they were added for
consistency with the existing code and to prevent copy & paste errors in
the future.

There's one conversion which is not straight-forward:

-       grepname=$grepname\\\.o
+       grepname="$grepname\.o"

There are different quoting rules with and without the double quotes.
2017-10-07 10:12:40 +02:00
Josh Poimboeuf
9017bfd32d Merge pull request #743 from joe-lawrence/valgrind_create_klp_module
kpatch-build: create-klp-module: set default arguments.no_klp_arch
2017-10-06 10:02:15 -05:00
Joe Lawrence
edfdaedd48 kpatch-build: create-klp-module: set default arguments.no_klp_arch
Valgrind complains about an uninitialized variable in
create-klp-module.c:

 ==4412== Conditional jump or move depends on uninitialised value(s)
 ==4412==    at 0x402846: main (create-klp-module.c:497)

This warning refers to main()'s struct arguments stack variable,
precisely its .no_klp_arch member.  Initialize the entire structure to
zero to avoid complaint.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-10-06 10:51:52 -04:00
Josh Poimboeuf
f4271491af Merge pull request #742 from joe-lawrence/valgrind_elf_update
kpatch-build: clear Elf_Data d_buf buffer on allocation
2017-10-04 11:54:56 -05:00
Joe Lawrence
321bbf9417 kpatch-build: clear Elf_Data d_buf buffer on allocation
Valgrind complains about uninitialized bytes passed to pwrite64(buf)
from kpatch_write_output_elf()'s call to elf_update():

  ==32378== Syscall param pwrite64(buf) points to uninitialised byte(s)
  ==32378==    at 0x5141A03: __pwrite_nocancel (in /usr/lib64/libc-2.23.so)
  ==32378==    by 0x4E46846: ??? (in /usr/lib64/libelf-0.168.so)
  ==32378==    by 0x4E42B88: elf_update (in /usr/lib64/libelf-0.168.so)
  ==32378==    by 0x40C57A: kpatch_write_output_elf (kpatch-elf.c:895)
  ==32378==    by 0x40926F: main (create-diff-object.c:2851)
  ==32378==  Address 0x28d52300 is 0 bytes inside a block of size 56 alloc'd
  ==32378==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
  ==32378==    by 0x40B86A: create_section_pair (kpatch-elf.c:707)
  ==32378==    by 0x406CAE: kpatch_create_patches_sections (create-diff-object.c:2109)
  ==32378==    by 0x4090C5: main (create-diff-object.c:2815)

These are fields which we don't need to populate (like a
funcs[index].new_addr value that will be filled by relocation).  The
easiest way to appease valgrind and not clutter the code is to just
zero-out this entire buffer on allocation.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-10-03 16:42:28 -04:00
Josh Poimboeuf
c194d6f44f Merge pull request #741 from joe-lawrence/discarded_sections
kpatch-build: ignore .discard sections
2017-10-03 14:50:09 -05:00
Joe Lawrence
9b2e37baf7 kpatch-build: ignore .discard sections
Fixes #711.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-10-03 15:28:52 -04:00
Josh Poimboeuf
7460abd932 Merge pull request #740 from joe-lawrence/testing_updates
Testing updates
2017-09-25 12:30:39 -05:00
Joe Lawrence
eda8357743 testing: simplify combined integration test
Now that kpatch-build can accept multiple patches on the command line,
ditch the combinediff and associated logic in the integration test
script.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-09-25 09:17:07 -04:00
Joe Lawrence
2f8170e962 testing: rebase patches for CentOS 7.4 kernel-3.10.0-693.el7
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-09-22 17:02:33 -04:00
Joe Lawrence
d580ffd71b Merge pull request #739 from jpoimboe/printk_once
doc: document workaround for printk_once() and friends
2017-09-22 16:09:55 -04:00
Josh Poimboeuf
8bc0b5cf39 doc: document workaround for printk_once() and friends
I couldn't find a good place in the document for this, so I just added
an "Other issues" section at the end.

Fixes #738.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-09-22 14:52:09 -05:00
Joe Lawrence
10b37a16a4 Merge pull request #737 from jpoimboe/bundling
kpatch-build: do symbol/section bundling in create-diff-object
2017-09-21 10:32:19 -04:00
Josh Poimboeuf
b72027c44e kpatch-build: do symbol/section bundling in create-diff-object
kpatch-elf.c is used by binaries other than create-diff-object, but
create-diff-object is the only one that cares about "bundling".  Move
the bundling to create-diff-object.

Fixes #700.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-09-20 23:57:31 -05:00
Josh Poimboeuf
5888f316e6 create-klp-module: support unbundled symbols
The create_klp_relasecs_and_syms() function assumes that all dest
symbols are bundled, i.e. each symbol is located at offset 0 in its own
section.

However that may not always be the case.  Unbundled symbols can occur,
for example, when combining two .o files which have the same bundled
symbol.  They will be combined into the same section and will no longer
be considered "bundled".

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-09-20 23:57:31 -05:00
Josh Poimboeuf
6c8e90e640 create-kpatch-module: support unbundled symbols
The create_dynamic_rela_sections() function assumes that all dest
symbols are bundled, i.e. each symbol is located at offset 0 in its own
section.

However that may not always be the case.  Unbundled symbols can occur,
for example, when combining two .o files which have the same bundled
symbol.  They will be combined into the same section and will no longer
be considered "bundled".

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2017-09-20 23:57:24 -05:00
Josh Poimboeuf
b8d5f479fd Merge pull request #733 from joe-lawrence/multiple_patches
kpatch-build: support multiple .patch files
2017-09-20 17:18:02 -05:00
Joe Lawrence
c0105ea467 kpatch-build: set default module prefix accordingly
Use kpatch-<modname>.ko or livepatch-<modname>.ko depending on the type
of module we're building.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2017-09-20 16:30:00 -04:00