Skip to content

Do not overflow when calculating region end in lookup#1109

Merged
iximeow merged 2 commits intomasterfrom
ixi/overflow-in-region-lookup
Apr 9, 2026
Merged

Do not overflow when calculating region end in lookup#1109
iximeow merged 2 commits intomasterfrom
ixi/overflow-in-region-lookup

Conversation

@iximeow
Copy link
Copy Markdown
Member

@iximeow iximeow commented Apr 9, 2026

This fixes a relatively boring bug I noticed in following what a particularly evil NVMe PRP could cause us to do: if a guest offers a PRP referencing the last page (i.e. u64::MAX & !0xfff) and we try to get a region covering that page, the addition in region_mappings could overflow.

Yet another win for panic-on-overflow, I wouldn't have noticed this in a release build. I say this is "boring" because there won't be memory mapped up at the end of u64 space, so to be "exciting" there would have to be a very large region being looked up. Something like a length of u64::MAX - 0x1000 where the overflow lands in the same region and we pass addr + rlen < end. Anything else and we'll fail the check and return None, just later than we really should have.

This fixes a relatively boring bug I noticed in following what a
particularly evil NVMe PRP could cause us to do: if a guest offers a PRP
referencing the last page (i.e. `u64::MAX & !0xfff`) and we try to get a
region covering that page, the addition in `region_mappings` could
overflow.

Yet another win for panic-on-overflow, I wouldn't have noticed this in a
release build. I say this is "boring" because there won't be memory
mapped up at the end of u64 space, so to be "exciting" there would have
to be a very large region being looked up. Something like a length of
`u64::MAX - 0x1000` where the overflow lands in the same region and we
pass `addr + rlen < end`. Anything else and we'll fail the check and
return `None`, just later than we really should have.
@iximeow iximeow added the bug Something that isn't working. label Apr 9, 2026
Copy link
Copy Markdown
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

nice catch! i had a couple little nitpicks.

}
}

#[test]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this file has a test submodule, shouldn't this be in there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i was on the fence about that, usually i think about mod test { ... } as more comprehensive tests for either a composition of items in super or at least pulling in "a bunch" of stuff. this is just "the function directly above this works in these ways" so moving it feels like it's easier to miss the examples?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤷‍♀️ fair enough, normally i feel like i expect to see every test in mod test but i don't actually care about this

@iximeow iximeow merged commit 82f385c into master Apr 9, 2026
12 checks passed
@iximeow iximeow deleted the ixi/overflow-in-region-lookup branch April 9, 2026 21:43
papertigers added a commit to oxidecomputer/omicron that referenced this pull request Apr 13, 2026
This bumps propolis to commit bc489dd.

This brings in the following:
- oxidecomputer/propolis#1112 **(the reason for
this PR)**
- oxidecomputer/propolis#1109
- oxidecomputer/propolis#1084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something that isn't working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants