drivers/virtio/fs: Avoid VLA on stack for sg segments#1766
Open
andutu0 wants to merge 1 commit intounikraft:stagingfrom
Open
drivers/virtio/fs: Avoid VLA on stack for sg segments#1766andutu0 wants to merge 1 commit intounikraft:stagingfrom
andutu0 wants to merge 1 commit intounikraft:stagingfrom
Conversation
Replace runtime-sized sg segment VLAs in virtiofs_do_request() and virtiofs_do_request_vec() with heap allocations. This avoids large stack allocations, preventing potential crashes with large queues. Signed-off-by: Andrei <andu.lng05@gmail.com>
Contributor
|
@andutu0 , could you please clarify what issue can stack allocation cause? Could you provide a demo / PoC of that issue? |
Author
SummaryDuring further investigation, I found out that in QEMU the queue-size is capped at 1024, even though virtio allows queue sizes up to 32768. As a result, the maximum size of the VLAs is limited to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Replace runtime-sized sg segment VLAs in virtiofs_do_request() and virtiofs_do_request_vec() with heap allocations.
This avoids large stack allocations, preventing potential crashes with large virtqueue lengths.
Related Work
N/A
PR Checklist
checkpatch.ukon your commit series before opening this PR;Note:
The fix was only tested with mocks, because Unikraft’s virtio-pci transport only supports the legacy interface for now, while QEMU exposes virtio-fs using a modern virtio PCI device ID, and I could not find a way to make it work.