Skip to content

Conversation

erfrimod
Copy link
Contributor

netvsp should be validating the LSO packets coming from the guest

  • There should be at least two SGEs.
  • The first SGE should only be the header, and therefore less than 256 bytes.

@erfrimod erfrimod requested a review from a team as a code owner October 10, 2025 23:15
@Copilot Copilot AI review requested due to automatic review settings October 10, 2025 23:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds LSO (Large Send Offload) packet validation logic to the netvsp driver's packet handling function to ensure guest-provided LSO packets meet required constraints.

Key changes:

  • Adds validation for LSO packets to verify they have at least two SGEs (Scatter-Gather Elements)
  • Validates that the first SGE is no larger than 256 bytes (header size constraint)
  • Introduces a new error type for invalid LSO packets

"LSO requires at least two SGEs",
));
}
let first_segment_size = segments.first().unwrap().len;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

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

Using unwrap() is unsafe here even though the length check exists above. If segments is empty, this will panic. Consider using segments[0].len instead since the length check guarantees at least 2 elements, or use a safer pattern like let first_segment = &segments[0];.

Suggested change
let first_segment_size = segments.first().unwrap().len;
let first_segment_size = segments[0].len;

Copilot uses AI. Check for mistakes.

Copy link

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.

2 participants