Skip to content

Conversation

phip1611
Copy link
Member

Fix some memory safety issues.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@phip1611 phip1611 self-assigned this Sep 11, 2025
@phip1611 phip1611 changed the title uefi: memory fixes uefi: memory safety fixes (UB!) Sep 11, 2025
@@ -533,7 +533,7 @@ pub enum BltOp<'buf> {
/// Delta must be the stride (count of bytes in a row) of the buffer.
BufferToVideo {
/// Buffer from which to copy data.
buffer: &'buf [BltPixel],
buffer: &'buf mut [BltPixel],
Copy link
Member

Choose a reason for hiding this comment

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

I'm not clear on why this buffer needs to be &mut. We're copying data from the buffer, not into it, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was misled by the underlying interface. Please recheck the new commit.

Parameter mutability was used in the wrong way.

I also double-checked everything in the specification [0].

[0] https://uefi.org/specs/UEFI/2.10/24_Network_Protocols_SNP_PXE_BIS.html#efi-simple-network-nvdata
We can't use `as_mut_ptr()` as the underlying buffer
is only readable. As we know the operation
is only reading from the buffer, this is safe.
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