Re: [PATCH 1/1] params: array: stage element output before concatenation

From: Petr Pavlu

Date: Thu May 28 2026 - 03:34:15 EST


On 5/28/26 7:22 AM, Ren Wei wrote:
> From: Wyatt Feng <bronzed_45_vested@xxxxxxxxxx>
>
> param_array_get() builds one sysfs string from a parameter array, but
> the individual get callbacks are defined to format into a full PAGE_SIZE
> buffer. Passing buffer + off directly to those callbacks can overrun the
> remaining space once the concatenated output approaches PAGE_SIZE.
>
> Fix this in the array helper by formatting each element into a temporary
> PAGE_SIZE buffer before copying only the bytes that still fit into the
> sysfs buffer. This keeps the existing callback interface unchanged and
> prevents both the element formatter and the final terminator write from
> stepping past the end of the page.

This issue was reported before, along with a similar fix [1].
Additionally, another series has been proposed to convert
kernel_param_ops::get() to seq_buf [2].

[1] https://lore.kernel.org/all/20260417075042.26632-1-pengpeng@xxxxxxxxxxx/
[2] https://lore.kernel.org/linux-modules/20260521133315.work.845-kees@xxxxxxxxxx/

--
Thanks,
Petr