Code Monkey home page Code Monkey logo

Comments (8)

ryanmiao avatar ryanmiao commented on August 19, 2024

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.

sjenning avatar sjenning commented on August 19, 2024

I know of the __bug_table issue and am working to fix it

from kpatch.

ryanmiao avatar ryanmiao commented on August 19, 2024

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.

jpoimboe avatar jpoimboe commented on August 19, 2024

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.

jpoimboe avatar jpoimboe commented on August 19, 2024

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.

sjenning avatar sjenning commented on August 19, 2024

This is next in my queue. Thanks for the analysis @jpoimboe

from kpatch.

sjenning avatar sjenning commented on August 19, 2024

@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.

jpoimboe avatar jpoimboe commented on August 19, 2024

@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)

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.