Re: [PATCH] sysfs: clamp show() return value in sysfs_kf_read()
From: David Laight
Date: Thu May 21 2026 - 06:06:43 EST
On Thu, 21 May 2026 08:18:32 +0200
Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, May 20, 2026 at 08:19:34AM -1000, Tejun Heo wrote:
> > Hello,
> >
> > Two nits:
> >
> > - Buffer is atomic_write_len ?: PAGE_SIZE, so probably better to clamp
> > to that than hardcode PAGE_SIZE.
>
> Where is that check at? And sysfs_kf_seq_show() doesn't check it this
> way, should that change?
It would be better to always fix the 'show' buffer at PAGE_SIZE (or 4k).
The only place that uses is different value is the cgroup code and I
think it needs to support longer writes (100 + 6 * NR_CPUS).
I've not looked at how it handles the matching reads - I presume they exist.
If the data is binary, or it uses seq_printf() then it can just support
a longer dynamically allocated buffer.
-- David
>
> > - pr_warn() instead of bare printk()?
>
> This is copying the message in sysfs_kf_seq_show() that has the same
> exact format. I will send a follow-on patch to make both the same.
>
> thanks,
>
> greg k-h
>