Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

vfio_user: fix off-by-one in array bounds checking#33

Merged
rbradford merged 1 commit intorust-vmm:mainfrom
blitz:fixes
Apr 13, 2025
Merged

vfio_user: fix off-by-one in array bounds checking#33
rbradford merged 1 commit intorust-vmm:mainfrom
blitz:fixes

Conversation

@blitz
Copy link
Contributor

@blitz blitz commented Apr 9, 2025

Summary of the PR

The existing checks didn't catch the case where the other side asked for region/irq n when there are n entries in the vector. This results in ugly crashes like this:

thread 'main' panicked at .../vfio-user/src/lib.rs:1082:37: index out of bounds: the len is 0 but the index is 0 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

The existing checks didn't catch the case where the other side asked
for region/irq n when there are n entries in the vector. This results
in ugly crashes like this:

thread 'main' panicked at .../vfio-user/src/lib.rs:1082:37:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Signed-off-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
Copy link
Collaborator

@rbradford rbradford left a comment

Choose a reason for hiding this comment

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

Good work - thanks!

@rbradford rbradford merged commit 669eb6b into rust-vmm:main Apr 13, 2025
6 checks passed
@blitz blitz deleted the fixes branch April 22, 2025 20:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants