CPER FRU text occupies a fixed 20-byte field and need not contain a NUL terminator. Using __string() can read past the field and, for a short nonstandard section, past the end of the firmware record.
Bound FRU text in the legacy memory and nonstandard trace events with __string_len() and strnlen(), as already done for the Section 2 event. Signed-off-by: Pierre Gondois <[email protected]> --- include/ras/ras_event.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h index ce759ee1cf4cc..069c7b3a5e6c0 100644 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -39,7 +39,7 @@ TRACE_EVENT(extlog_mem_event, __field(u64, pa) __field(u8, pa_mask_lsb) __field_struct(guid_t, fru_id) - __string(fru_text, fru_text) + __string_len(fru_text, fru_text, strnlen(fru_text, 20)) __field_struct(struct cper_mem_err_compact, data) ), @@ -370,7 +370,7 @@ TRACE_EVENT(non_standard_event, TP_STRUCT__entry( __array(char, sec_type, UUID_SIZE) __array(char, fru_id, UUID_SIZE) - __string(fru_text, fru_text) + __string_len(fru_text, fru_text, strnlen(fru_text, 20)) __field(u8, sev) __field(u32, len) __dynamic_array(u8, buf, len) -- 2.43.0
