-
Notifications
You must be signed in to change notification settings - Fork 336
create-diff-object: Use .rela.toc as list head in kpatch_correlate_st… #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The static local variable correlation has been (and continues to be) tricky to get right, and I think that just looking at the .toc section isn't going to be enough information for more complex situations, for example where there are multiple static variables with the same name (but used in different functions). How about this instead, would this work? |
|
Thanks for the review. It fails with Reason being section is My understanding of kpatch_correlate_static_local_variables(), might be wrong. I ran testcases, And all of the reference in Do you think, its good idea to add a testcase, which trigger this issue: |
Is that not a bug in kpatch_mangled_strcmp()? When comparing the relas, shouldn't it also compare the toc_relas?
But with -mcmodel=large, isn't .rela.toc going to be the only section that will access static local variables? If the intent was to iterate through all the sections, list_for_each_entry() isn't the right way to do that. It can't start in the middle of the list unless you use something like list_for_each_entry_continue(), but even then it wouldn't loop around the begining.
Yes, very good idea. |
Agree, toc_rela() makes |
|
From a quick glance, I think it looks ok. BTW, when I said
I meant to say:
So I think rela_equal() needs to do something similar, where it compares both relas and toc_relas. |
I have a refactored rela_equal() to use toc_rela(), will post the patch for review. |
bcf35ac to
2c123b4
Compare
|
v2 Changes:
|
|
Hi @kamalesh-babulal , Do you mind if I let @jpoimboe review v2 when he gets back? I don't have the PPC64 .toc stuff fresh in my head and he can probably do a better job continuing his review. Thanks for adding the test case, one very small nit: "kpatch-macros.h" shouldn't be necessary if all the patch it doing is a trivial modification to get those functions included. |
|
@joe-lawrence no, not at all. Thanks for the review. Agree, will remove |
kpatch-build/create-diff-object.c
Outdated
| } | ||
|
|
||
| patched_sym = kpatch_find_static_twin(sec, sym); | ||
| patched_sym = kpatch_find_static_twin(toc_sec, sym); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not quite right. It's comparing the .rela.toc section relas. Instead it should be comparing the original .rela.data.* section relas. Otherwise it may get confused and correlate the wrong variables. For example, if there are multiple static locals with the same name, but in different .data.* sections, they should not be correlated. But this code might accidentally correlate them, because they're both referenced in .rela.toc.
Instead I think the original .data.* section should be passed to kpatch_find_static_twin(), and kpatch_find_static_twin() should be fixed to compare toc_rela-based symbols.
The static local variable correlation is a bit confusing (and actually needs to be simplified). If you want, I can try to take a pass at fixing this bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not quite right. It's comparing the .rela.toc section relas. Instead it should be comparing the original .rela.data.* section relas.
This stuff is really hard to communicate precisely, it might be easier if I write a patch to communicate it :-)
On ppc64le, the static local variable correlation doesn't take into account the .toc rela indirection for data references, meaning that it's basically broken in many cases. Fix it by making the code .toc-aware. Fixes dynup#793. Reported-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This patch adds a reproducer testcase for correlating static local variables added in .rodata* section, ahead of .toc section. This testcase is for issue seen on PowerPC. For more details on the issue refer pull request: 793 and 817. It add's the testcase for: - Fedora-27 Kernel version 4.15.10-300 - Centos-7 Kernel version 3.10.0-693 and - Ubuntu-16.04 Kernel version 4.13.0-25.29 Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2c123b4 to
63d81e2
Compare
|
@jpoimboe Thanks for working on making kpatch_correlate_static_local_variables() |
…atic_local_variables
kpatch_correlate_static_local_variables() assumes that the .text
sections are parsed ahead of .rodata sections and the references to
static local variable are correlated by the .text section rela
referring them. This assumption is not true on PowerPC, as all data
loads for -mcmodel=large are loaded from .toc section + offset and
fails with the error:
ERROR: netfilter.o: reference to static local variable fake_pinfo.63552 in fake_sk.63553 was removed
As per PPC64le ABIv2:
"TOC may straddle the boundary between initialized and uninitialized
data in the data segment."
$ readelf -s ./net/ipv6/netfilter.o
...
[16] .rodata.func.63533
[17] .rodata.fake_sk.63553
[18] .rela.rodata.fake_sk.63553
...
[28] .toc PROGBITS
[29] .rela.toc RELA
[30] .data PROGBITS
[31] .data.rel.ro.ipv6ops PROGBITS
fix this issue by looping .toc as section head if available, creating
the correlation by referring to section twin of .rela.toc.
Signed-off-by: Kamalesh Babulal kamalesh@linux.vnet.ibm.com