Skip to content

ocp: sanitize tainted ascii_id_length before memcpy - #3786

Open
bellis-ibm wants to merge 1 commit into
linux-nvme:masterfrom
bellis-ibm:fix/coverity-tainted-scalar-ocp-telemetry
Open

ocp: sanitize tainted ascii_id_length before memcpy#3786
bellis-ibm wants to merge 1 commit into
linux-nvme:masterfrom
bellis-ibm:fix/coverity-tainted-scalar-ocp-telemetry

Conversation

@bellis-ibm

Copy link
Copy Markdown
Contributor

ascii_id_length is a __u8 field read from device-supplied telemetry
data (pstring_buffer). Passing it directly as the memcpy size without
bounds checking allows a corrupt or malicious value to write beyond
the description buffer.

Replace 'memcpy(desc, src, len + 1)' with an explicit copy of len
bytes followed by a null terminator. Since ascii_id_length is __u8
(max 255) and all callers provide a 256-byte buffer, the copy and
terminator always fit without needing an additional clamp.

The same fix is applied consistently across all three string lookup
functions: get_statistic_id_ascii_string(), get_event_id_ascii_string()
and get_vu_event_id_ascii_string().

Fixes Coverity CIDs 557416, 557331, 557323 (TAINTED_SCALAR).
Signed-off-by: Brooke Ellis Brooke.Ellis@ibm.com

ascii_id_length is a __u8 field read from device-supplied telemetry
data (pstring_buffer). Passing it directly as the memcpy size without
bounds checking allows a corrupt or malicious value to write beyond
the description buffer.

Replace 'memcpy(desc, src, len + 1)' with an explicit copy of len
bytes followed by a null terminator. Since ascii_id_length is __u8
(max 255) and all callers provide a 256-byte buffer, the copy and
terminator always fit without needing an additional clamp.

The same fix is applied consistently across all three string lookup
functions: get_statistic_id_ascii_string(), get_event_id_ascii_string()
and get_vu_event_id_ascii_string().

Fixes Coverity CIDs 557416, 557331, 557323 (TAINTED_SCALAR).

Signed-off-by: Brooke Ellis <Brooke.Ellis@ibm.com>
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.

1 participant