Skip to content

[Bug]: Nvme:: NvmExpressMediaClear: Incorrect buffersize #1739

Description

@spbrogan

Is there an existing issue for this?

  • I have searched existing issues

Current Behavior

NvmExpressMediaClear: BufferSize passed as 1 instead of block size → function is completely non-functional

Why this is a real bug:
WriteBlocks expects BufferSize in bytes. The call passes 1:

NvmeBlockIoWriteBlocks checks (BufferSize % BlockSize) != 0. Since 1 % 512 != 0 (for any standard block size ≥ 2), this always returns EFI_BAD_BUFFER_SIZE.

Consequence:
The NIST 800-88r1 media clear operation is entirely non-functional. No overwrite data is written to any sector. A caller relying on this for data sanitization receives no actual sanitization.

Minimal fix direction:
Change 1 to Device->Media.BlockSize.

Expected Behavior

Block is overwritten

Steps To Reproduce

Trigger path:

Caller invokes NvmExpressMediaClear with valid parameters.
Inner loop calls WriteBlocks with BufferSize = 1.
NvmeBlockIoWriteBlocks returns EFI_BAD_BUFFER_SIZE.
Loop continues (no error check), every iteration fails.
Function returns last error status. No data is ever written.
Why this is NOT a false positive:
The comment says "Write one sector per write" — the intent was BlockSize bytes. The EFI_BLOCK_IO_PROTOCOL specification defines BufferSize as bytes, not sectors. There is no code path where BufferSize=1 would pass the block-alignment check.

Build Environment

NA

Version Information

All

Urgency

Medium

Are you going to fix this?

I will fix it

Do you need maintainer feedback?

No maintainer feedback needed

Anything else?

No response

Metadata

Metadata

Assignees

Labels

state:staleHas not been updated in a long timetype:bugSomething isn't workingurgency:mediumImportant with a moderate impact

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions