Re: [PATCH v2] EDAC/thunderx: Fix some potential buffer overflow in thunderx_ocx_com_threaded_isr()

From: Kees Cook
Date: Thu Oct 26 2023 - 13:18:40 EST


On Tue, Oct 24, 2023 at 04:39:36PM -0700, Kees Cook wrote:
> As the replacements get longer, I would encourage you to use seq_buf
> instead -- it does all the length math internally. For example:

There's some ongoing work to make seq_buf easier to use:
https://lore.kernel.org/lkml/20231026170722.work.638-kees@xxxxxxxxxx/

Perhaps we can add an "alloc" and "free" pair too, to handle this case:

> msg = kmalloc(OCX_MESSAGE_SIZE, GFP_KERNEL);
> seq_buf_init(&s, msg, OCX_MESSAGE_SIZE);

But perhaps it's overkill...

--
Kees Cook