Skip to content
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

sbpf: undo rodata footprint optimization #1058

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Conversation

ripatel-fd
Copy link
Contributor

This commit increases the ELF loader's rodata_footprint to be equal
to the ELF file size. This increases memory usage by 5-10% for most
contracts.

The ELF loader made an incorrect assumption that relocations outside
of the rodata segment are invisible to the virtual machine. The
loader therefore reduced the rodata segment size and skipped those
relocations.

This is problematic for two reasons:

  1. R_BPF_64_32 can read ~15 bytes past the end of the rodata region
    and conditionally fails loading depending on the content that was
    read.
  2. Some relocations move information from high bits to low bits
    within a 64-bit value. Chaining those relocations thus allows
    moving information from outside the rodata segment into the
    rodata segment.

fd_sbpf_loader would have the wrong execution result in both cases.

This commit increases the ELF loader's rodata_footprint to be equal
to the ELF file size.  This increases memory usage by 5-10% for most
contracts.

The ELF loader made an incorrect assumption that relocations outside
of the rodata segment are invisible to the virtual machine.  The
loader therefore reduced the rodata segment size and skipped those
relocations.

This is problematic for two reasons:

  1) R_BPF_64_32 can read ~15 bytes past the end of the rodata region
     and conditionally fails loading depending on the content that was
     read.
  2) Some relocations move information from high bits to low bits
     within a 64-bit value. Chaining those relocations thus allows
     moving information from outside the rodata segment into the
     rodata segment.

fd_sbpf_loader would have the wrong execution result in both cases.
@ripatel-fd ripatel-fd added this pull request to the merge queue Dec 12, 2023
Merged via the queue into main with commit 2e27ed1 Dec 12, 2023
9 checks passed
@ripatel-fd ripatel-fd deleted the ripatel/sbpf-loader-shadow branch December 12, 2023 22:30
@ripatel-fd ripatel-fd added this to the [M2.1] Async Replay milestone Jan 5, 2024
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.

3 participants