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

Change iovec len from usize to u32 #4380

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarcoROG
Copy link

@MarcoROG MarcoROG commented Jan 19, 2024

Changes

Changing the type of iovec len from usize to u32

Resolves #4548

Reason

This is to better reflect the buffer size and prevent buffer overflows.

...

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following
Developer Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@MarcoROG MarcoROG closed this Jan 19, 2024
@MarcoROG MarcoROG reopened this Jan 19, 2024
@@ -68,7 +68,7 @@ impl IoVecBuffer {
iov_base,
iov_len: desc.len as size_t,
});
len += desc.len as usize;
len += desc.len;
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add a check for overflow here.

@@ -217,14 +217,14 @@ impl IoVecBufferMut {
iov_base,
iov_len: desc.len as size_t,
});
len += desc.len as usize;
len += desc.len;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4c8d541) 81.52% compared to head (0c4ec3b) 81.51%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4380      +/-   ##
==========================================
- Coverage   81.52%   81.51%   -0.01%     
==========================================
  Files         241      241              
  Lines       29249    29247       -2     
==========================================
- Hits        23844    23842       -2     
  Misses       5405     5405              
Flag Coverage Δ
4.14-c7g.metal 76.88% <100.00%> (-0.01%) ⬇️
4.14-m5d.metal 78.83% <100.00%> (-0.01%) ⬇️
4.14-m6a.metal 77.94% <100.00%> (-0.01%) ⬇️
4.14-m6g.metal 76.88% <100.00%> (-0.01%) ⬇️
4.14-m6i.metal 78.81% <100.00%> (-0.01%) ⬇️
5.10-c7g.metal 79.79% <100.00%> (-0.01%) ⬇️
5.10-m5d.metal 81.50% <100.00%> (+<0.01%) ⬆️
5.10-m6a.metal 80.70% <100.00%> (-0.01%) ⬇️
5.10-m6g.metal 79.79% <100.00%> (-0.01%) ⬇️
5.10-m6i.metal 81.48% <100.00%> (-0.01%) ⬇️
6.1-c7g.metal 79.79% <100.00%> (-0.01%) ⬇️
6.1-m5d.metal 81.50% <100.00%> (+<0.01%) ⬆️
6.1-m6a.metal 80.70% <100.00%> (-0.01%) ⬇️
6.1-m6g.metal 79.79% <100.00%> (-0.01%) ⬇️
6.1-m6i.metal 81.48% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Changing the type of IoVecBuffer's and IoVecBufferMut's len from usize
to u32 as the buffer size can only be up to 2^32 -1 bytes.

Signed-off-by: Marco Bellan <marcobll@amazon.com>
@bchalios
Copy link
Contributor

bchalios commented Apr 9, 2024

Resolves #4548

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.

Use u32 to describe descriptor chain lengths
2 participants