Git Product home page Git Product logo

Comments (14)

jpoimboe avatar jpoimboe commented on July 30, 2024

Please try the latest kpatch code

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024

Hi, thanks for advice.

I upgrade kpatch to latest version but still fail to make kpatch.
It seems that this is caused by new kernel 6.4.0 ?

My environment:

kpatch version: latest version 0.9.9 downloaded from github
kernel version: 6.4.0
architecture: x86_64
linux: openEuler
[root@openEuler patch_workspace]# ./make_hotpatch -i testklp -d .v1 -j 32
kernel version:6.4.0-6.0.0.14.oe2309.x86_64
grep: warning: stray \ before -
grep: warning: stray \ before -
grep: warning: stray \ before -
detect change files:/usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64/kernel/time/ntp.c.v1
make patch /tmp/klp_testklp/testklp.patch
Using source directory at /usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64
Testing patch file(s)
Reading special section data
Building original source
Building patched source
Extracting new and modified ELF sections
create-diff-object: ERROR: ntp.o: kpatch_bundle_symbols: 251: czy symbol ntp_update_frequency at offset 16 within section .text.ntp_update_frequency, expected 0
ERROR: 1 error(s) encountered. Check /root/.kpatch/build.log for more details.
error: invoke kpatch-build shell script to build patch failed

from kpatch.

jpoimboe avatar jpoimboe commented on July 30, 2024

Might be a problem with the handling of CONFIG_PREFIX_SYMBOLS. This should have been handled by 3e54c63 but maybe there's a gap somewhere. Please post the output of readelf -Ws /usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64/kernel/time/ntp.o.

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024

[root@openEuler ~]# readelf -Ws /usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64/kernel/time/ntp.o

Symbol table '.symtab' contains 88 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS ntp.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .text.ntp_update_frequency
     3: 0000000000000010   108 FUNC    LOCAL  DEFAULT    4 ntp_update_frequency

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024

I compare the ELF data of ntp.o produced by kernel-5.10, the st_value is differenet

readelf -Ws /usr/src/kernels/linux-5.10.0-xxxxx/kernel/time/ntp.o

Symbol table '.symtab' contains 105 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS ntp.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 .text
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    2 .data
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    3 .bss
     5: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .text.ntp_update_frequency
     7: 0000000000000000   136 FUNC    LOCAL  DEFAULT    4 ntp_update_frequency


from kpatch.

jpoimboe avatar jpoimboe commented on July 30, 2024

Yes, the 16 byte offset is expected, and should be dealt with by 3e54c63, are you sure you have that commit?

Can you also post the output of readelf -Ws /usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64/kernel/time/ntp.o |grep ntp_update_frequency (lower case "s" this time)?

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024
  1. I am sure my current kpatch have commit 3e54c6 by adding debug log.
  2. There is no _pfx symbol of ntp_update_frequency
[root@openEuler patch_workspace]# readelf -Ws /usr/src/linux-6.4.0-6.0.0.14.oe2309.x86_64/kernel/time/ntp.o | grep ntp_update_frequency
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .text.ntp_update_frequency
     3: 0000000000000010   108 FUNC    LOCAL  DEFAULT    4 ntp_update_frequency


  1. I belive the problem occurs in sym->pfx code:
	list_for_each_entry(sym, &kelf->symbols, list) {
		if (is_bundleable(sym)) {
			if (sym->pfx)
				expected_offset = 16;
			else if (is_gcc6_localentry_bundled_sym(kelf, sym))

In my case, when iterating ntp_update_frequency symbol, sym->pfx returns false and results mismatch between st_value and expected_offset

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024

Maybe this error is releated to this PR :#1350

from kpatch.

ziyangc97 avatar ziyangc97 commented on July 30, 2024

I comment out CONFIG_X86_KERNEL_IBT and the error is gone, a new one come up:
image
Maybe this error is found or fix before?

from kpatch.

he7850 avatar he7850 commented on July 30, 2024

I comment out CONFIG_X86_KERNEL_IBT and the error is gone, a new one come up: image Maybe this error is found or fix before?

this error comes from making this patch:

diff --git a/fs/proc/version.c b/fs/proc/version.c.new
index 02e3c3c..47445f9 100644
--- a/fs/proc/version.c
+++ b/fs/proc/version.c.new
@@ -13,6 +13,7 @@ static int version_proc_show(struct seq_file *m, void *v)
 		utsname()->sysname,
 		utsname()->release,
 		utsname()->version);
+	seq_printf(m, "hotpatched\n");
 	return 0;
 }
 

/root/.kpatch/tmp/vmlinux.symtab:
image

rreadelf -sW /root/.kpatch/tmp/orig/fs/proc/version.o:
image

readelf -sW /usr/src/linux-6.4.0-1.0.1.4.oe2309.x86_64/vmlinux:
image

from kpatch.

he7850 avatar he7850 commented on July 30, 2024

so find_local_syms error happens because vmlinux.symtab does not contains __pfx_ symbols but version.o contains them, and local symbols cannot match.

maybe maybe_discarded_sym() should add __pfx_ pattern?

from kpatch.

he7850 avatar he7850 commented on July 30, 2024

so find_local_syms error happens because vmlinux.symtab does not contains "_pfx" symbols but version.o contains them, and local symbols cannot match.

maybe maybe_discarded_sym() should add "_pfx" pattern?

seems that this patch can solve the find_local_syms error:

diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c
index bd2b732..2008cce 100644
--- a/kpatch-build/lookup.c
+++ b/kpatch-build/lookup.c
@@ -83,6 +83,7 @@ static bool maybe_discarded_sym(const char *name)
            !strncmp(name, "__brk_reservation_fn_", 21) ||
            !strncmp(name, "__func_stack_frame_non_standard_", 32) ||
            strstr(name, "__addressable_") ||
+           strstr(name, "__pfx_") ||
            strstr(name, "__UNIQUE_ID_") ||
            !strncmp(name, ".L.str", 6) ||
            is_ubsan_sec(name))

from kpatch.

github-actions avatar github-actions commented on July 30, 2024

This issue has been open for 30 days with no activity and no assignee. It will be closed in 7 days unless a comment is added.

from kpatch.

github-actions avatar github-actions commented on July 30, 2024

This issue was closed because it was inactive for 7 days after being marked stale.

from kpatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.