Comments (8)
I also met this problem, but the problematic section kpatch_verify_patchability complained is '__bug_table', rather than '.rela.smp_locks'.
[ryan@localhost kpatch]$ ./kpatch-build/kpatch-build -r ./kernel-3.13.6-200.fc20.src.rpm ~/workspace/mlock.patch -d
DEBUG mode enabled
Using cache at /home/ryan/.kpatch/3.13.6-200.fc20.x86_64/src
Testing patch file
patching file mm/mlock.c
Building original kernel
Building patched kernel
Detecting changed objects
Rebuilding changed objects
Extracting new and modified ELF sections
changed function: mlock_vma_page
kpatch_verify_patchability:730: changed section __bug_table not selected for inclusion
/home/ryan/workspace/upstream/kpatch/kpatch-build/create-diff-object: unreconcilable difference
ERROR: kpatch build failed. Check /tmp/kpatch-build-1396494986.log for more details.
from kpatch.
I know of the __bug_table issue and am working to fix it
from kpatch.
I had compared two mlock.o:
[ryan@localhost kpatch]$ readelf -S /tmp/tmp.0TM37HJNqd/orig/mm/mlock.o
...
[10] __bug_table PROGBITS 0000000000000000 00000197
00000000000000c0 0000000000000000 A 0 0 1
...
[16] .rela.smp_locks RELA 0000000000000000 00005730
0000000000000108 0000000000000018 97 15 8
...
[ryan@localhost kpatch]$ readelf -S /tmp/tmp.0TM37HJNqd/patched/mm/mlock.o
...
[10] __bug_table PROGBITS 0000000000000000 00000197
00000000000000b4 0000000000000000 A 0 0 1
...
[16] .rela.smp_locks RELA 0000000000000000 000056e0
0000000000000108 0000000000000018 97 15 8
...
the size of the __bug_table section is changed after patching.
but for .rela.smp_locks section, the size is same.
from kpatch.
Saw this again with the following patch:
Index: src/net/unix/af_unix.c
===================================================================
--- src.orig/net/unix/af_unix.c
+++ src/net/unix/af_unix.c
@@ -1921,6 +1921,8 @@ static int unix_stream_recvmsg(struct ki
long timeo;
int skip;
+ printk_once("foo\n");
+
err = -EINVAL;
if (sk->sk_state != TCP_ESTABLISHED)
goto out;
$ kpatch-build unix_stream_recvmsg.patch
Using cache at /home/jpoimboe/.kpatch/3.13.10-200.fc20.x86_64/src
Testing patch file
patching file net/unix/af_unix.c
Building original kernel
Building patched kernel
Detecting changed objects
Rebuilding changed objects
Extracting new and modified ELF sections
changed function: unix_stream_recvmsg
kpatch_verify_patchability:736: changed section .rela.smp_locks not selected for inclusion
/usr/local/libexec/kpatch/create-diff-object: unreconcilable difference
ERROR: kpatch build failed. Check /tmp/kpatch-build-1398089722.log for more details.
from kpatch.
Each use of an atomic variable or spinlock (any instruction using the x86 "lock" prefix) results in the instruction's address getting added to the .smp_lock section, for potential future code modification (removing or adding the x86 "lock" instruction prefix). Each entry in the section contains only a 4-byte address which is placed there via relocation (.rela.smp.locks).
To support this I think we need to do something similar to what was done with the bug table, except both the .smp_locks and its rela section will need to be regenerated. Only those entries for which the rela refers to an included function should be kept. Regenerating .smp_locks shouldn't be hard since it's just all zeros.
Since this looks like it could be a common pattern emerging, maybe we can replace kpatch_regenerate_bug_table_rela_section with something more generic that covers both cases (and probably more cases we will discover). I think as long as it knows the entry size, that should be enough information for it to examine each of the relas within each entry and copy the needed base and rela entries.
from kpatch.
This is next in my queue. Thanks for the analysis @jpoimboe
from kpatch.
@madper after this fix, i was able to build your patch. Please confirm.
@jpoimboe with your patch, i feel through to a .rela.init.text not included error. I think it is because of the BUILD_BUG_ON in the __init function. however, it does fix the smp_locks failure.
from kpatch.
@Spartacus06 Thanks, when I get a chance I'll take a closer look at the .rela.init.text error. I'm going to go ahead and merge this fix now. @madper , please open a new issue if you still see the same error.
from kpatch.
Related Issues (20)
- Do we need more robust archeticture protection HOT 4
- kpatch-build: verify_patch_files might miss a parameter HOT 2
- ERROR in find_local_syms, couldn't find matching XXX local symbols in vmlinux symbol table HOT 14
- Can you add support for Rocky and Alma? HOT 1
- relocation with type R_X86_64_GOTPCREL is not supported HOT 5
- Arch Compile kpatch-git test failed HOT 4
- Regarding "statically allocated data" again HOT 2
- kpatch-build error when modifying an object file's only syscall
- nowhere to find the definition of klp_register_patch HOT 5
- x86 paravirt code uses alternatives v6.8+ HOT 1
- special-static.patch can fail to build on s390x / upstream v6.8 HOT 6
- CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY not supported on ppc64le HOT 6
- function __pfx_new_sync_read has no fentry/mcount call, unable to patch HOT 6
- Unchanged and unpatchable function moves from .text to .text.unlikely HOT 5
- Why did the kpatch-build script export the KPATCH-BUILD environment variable from the BUILD directory to the SOURCE directory? HOT 3
- CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build HOT 2
- linux 6.9.0-rc6 can't find special struct paravirt_patch_site size HOT 6
- fair.o: changed section .data..read_mostly not selected for inclusion HOT 11
- find_local_syms: 218: couldn't find matching cm.c local symbols in ib_mad symbol table HOT 7
- Kernel Warning: Unpatched return thunk in use. This should not happen! HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kpatch.