Skip to content

Support modules with a lot of sections #280

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stoeckmann
Copy link
Contributor

It seems that it's possible to compile modules with more than 0xFF00 sections. This leads to different fields in ELF files used to handle such a large amount of sections.

Parse proper fields if necessary.

A module might contain more than 65535 sections. Prepare support
for such module files by turning relevant fields into uint32_t.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Read extra fields from section header 0 if needed.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
@stoeckmann stoeckmann marked this pull request as draft February 15, 2025 21:10
Copy link

codecov bot commented Feb 15, 2025

Codecov Report

Attention: Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libkmod/libkmod-elf.c 50.00% 5 Missing and 2 partials ⚠️
testsuite/init_module.c 66.66% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
testsuite/init_module.c 70.10% <66.66%> (ø)
libkmod/libkmod-elf.c 49.76% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

idx, elf->header.section.count);
return 0;
}
return elf->header.section.offset +
(uint64_t)(idx * elf->header.section.entry_size);
(uint64_t)idx * elf->header.section.entry_size;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how easy is for the uint16_t * uint16_t overflow to trigger, but let's keep this change as separate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since idx is changed in this PR to a uint32_t and the C standard would therefore use unsigned int for the result, it would be possible.

@evelikov
Copy link
Collaborator

Not 100% sure about the second commit but the first one looks solid. @stoeckmann can you address my minor comment and undraft?

@stoeckmann
Copy link
Contributor Author

I've kept it as a draft because the linux kernel itself cannot support such modules either (as confirmed in #277). I have used this PR for easier testing/reference to the linked issue.

If we want to support possible features of future kernels we could merge this, but right now it's just a possible way of introducing bugs for no practical gain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants