Re: [PATCH v1 03/19] ras: Bound CPER FRU strings in trace events

From: Jonathan Cameron

Date: Wed Nov 18 2026 - 14:07:14 EST


On Tue, 17 Nov 2026 12:10:13 +0100
Pierre Gondois <pierre.gondois@xxxxxxx> wrote:

> 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.

Given the many many definitions of __string() in different parts
of the tracepoint infrastructure, might be worth a pointer here
to where it trips up. I think that's just in stage5 with other
stages ignoring the actual length.

Patch seems valid to me and not directly related to rest of the series.
So perhaps a hardening change to pull out ahead?

Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxxxxxxxx>

>
> Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
> ---
> 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)