create-diff-object: Fix out of range relocation verification check#1493
Open
sumanthkorikkar wants to merge 1 commit intodynup:masterfrom
Open
create-diff-object: Fix out of range relocation verification check#1493sumanthkorikkar wants to merge 1 commit intodynup:masterfrom
sumanthkorikkar wants to merge 1 commit intodynup:masterfrom
Conversation
kpatch_check_relocations() validates relocation targets using sec->data->d_size, which doesnt reflect entire section size. Sections such as __bug_table may be represented by multiple records. In this case, data->d_size is lesser than the logical section size, leading to false out-of-range relocation errors. ERROR: kernel/fork.o: kpatch_check_relocations: .text.kernel_clone+0x2f6: out-of-range relocation __bug_table+0x1b2 sec_off: 432 sec_size: 48 The correct size of the section is sec->sh.sh_size, total size of __bug_table (480 bytes, corresponding to 30 struct bug_entry records). Fix this by using sec->sh.sh_size instead of sec->data->d_size when verifying relocation bounds. Additionally, ensure that newly rebuilt .kpatch.strings sections update sh.sh_size after the string table is finalized. Without this update, kpatch may fail with: ERROR: kernel/fork.o: kpatch_check_relocations: .kpatch.funcs+0x28: out-of-range relocation .kpatch.strings+0x8 sec_off: 8 sec_size: 0 Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Member
|
I think this is a side effect of trying to keep all the extra unneeded __bug_table entries. Instead I think the right fix is to not pull in the entire __bug_table, and instead adjust the .text.kernel_clone+0x2f6 reference to point to its bug table entry's new offset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kpatch_check_relocations() validates relocation targets using sec->data->d_size, which doesnt reflect entire section size.
Sections such as __bug_table may be represented by multiple records. In this case, data->d_size is lesser than the logical section size, leading to false out-of-range relocation errors.
ERROR: kernel/fork.o: kpatch_check_relocations:
.text.kernel_clone+0x2f6: out-of-range relocation __bug_table+0x1b2
sec_off: 432 sec_size: 48
The correct size of the section is sec->sh.sh_size, total size of __bug_table (480 bytes, corresponding to 30 struct bug_entry records).
Fix this by using sec->sh.sh_size instead of sec->data->d_size when verifying relocation bounds.
Additionally, ensure that newly rebuilt .kpatch.strings sections update sh.sh_size after the string table is finalized. Without this update, kpatch may fail with:
ERROR: kernel/fork.o: kpatch_check_relocations:
.kpatch.funcs+0x28: out-of-range relocation .kpatch.strings+0x8
sec_off: 8 sec_size: 0