Re: [PATCH] sysfs: clamp show() return value in sysfs_kf_read()
From: Greg Kroah-Hartman
Date: Thu May 21 2026 - 02:20:12 EST
On Wed, May 20, 2026 at 11:11:58PM +0100, David Laight wrote:
> On Wed, 20 May 2026 15:07:01 +0200
> Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> > sysfs_kf_seq_show() defends against buggy show() callbacks that return
> > larger than PAGE_SIZE by clamping the value and printing a warning.
> > sysfs_kf_read(), the prealloc variant, has no such defense.
> >
> > The only current in-tree user of __ATTR_PREALLOC is drivers/md/md.c,
> > whose show() callbacks are well-behaved, so this is hardening against
> > future drivers doing foolish things and out-of-tree code doing even more
> > foolish things.
>
> What is the rational for it using PREALLOC?
No idea, you might want to dig to find the commit that did this.
thanks,
greg k-h