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

Fail early in case of too big a frame in the TX path #4526

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

bchalios
Copy link
Contributor

@bchalios bchalios commented Mar 27, 2024

Changes

Introduce a check that the size of a frame in the TX queue is not bigger than the one the device can handle.

Reason

We do not handle malformed packets that the driver might send to us. Also, we avoid big allocations when copying from guest memory to Firecracker memory when handling MMDS frames.

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.

@bchalios bchalios added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Mar 27, 2024
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.02%. Comparing base (b4224b2) to head (835e965).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4526   +/-   ##
=======================================
  Coverage   82.01%   82.02%           
=======================================
  Files         253      253           
  Lines       31026    31035    +9     
=======================================
+ Hits        25447    25456    +9     
  Misses       5579     5579           
Flag Coverage Δ
4.14-c5n.metal 79.48% <100.00%> (?)
4.14-c7g.metal ?
4.14-m5d.metal ?
4.14-m5n.metal 79.47% <100.00%> (?)
4.14-m6a.metal 78.69% <100.00%> (+<0.01%) ⬆️
4.14-m6g.metal 76.66% <100.00%> (+<0.01%) ⬆️
4.14-m6i.metal 79.47% <100.00%> (+<0.01%) ⬆️
4.14-m7g.metal 76.66% <100.00%> (?)
5.10-c5n.metal 82.02% <100.00%> (?)
5.10-c7g.metal ?
5.10-m5d.metal ?
5.10-m5n.metal 82.01% <100.00%> (?)
5.10-m6a.metal 81.31% <100.00%> (+<0.01%) ⬆️
5.10-m6g.metal 79.44% <100.00%> (+<0.01%) ⬆️
5.10-m6i.metal 82.01% <100.00%> (+<0.01%) ⬆️
5.10-m7g.metal 79.44% <100.00%> (?)
6.1-c5n.metal 82.02% <100.00%> (?)
6.1-m5n.metal 82.01% <100.00%> (?)
6.1-m6a.metal 81.31% <100.00%> (+<0.01%) ⬆️
6.1-m6g.metal 79.44% <100.00%> (+<0.01%) ⬆️
6.1-m6i.metal 82.01% <100.00%> (+<0.01%) ⬆️
6.1-m7g.metal 79.44% <100.00%> (?)

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.

@bchalios bchalios changed the title Avoid vector allocation in MMDS code path Fail early in case of too big a frame in the TX path Mar 27, 2024
@bchalios bchalios force-pushed the limit_net_tx_packet_size branch 4 times, most recently from e2d67d3 to 5728a51 Compare March 27, 2024 16:31
src/vmm/src/devices/virtio/net/device.rs Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
When we switched to using writev for copying a network packet from guest
memory to the tap device we dropped an (implicit) check for the size of
the TX frame.

Reintroduce that check since we should be handling only frames of up to
MAX_BUFFER_SIZE.

This, also, controls the amount of memory we allocate in the Firecracker
process for copying frames that are destined for MMDS from guest memory
to Firecracker memory.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
@zulinx86 zulinx86 self-requested a review March 28, 2024 09:17
@bchalios bchalios merged commit 8a1719f into firecracker-microvm:main Mar 28, 2024
7 checks passed
@bchalios bchalios deleted the limit_net_tx_packet_size branch March 28, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants