From: Alexey Dobriyan Date: Thu, 7 May 2026 09:01:43 +0000 (+0300) Subject: sysfs: upgrade OOB write by buggy .show hook into WARNing X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=f71cc65c01bdac1bc7705b1aad34f0023b41ec4d;p=thirdparty%2Fkernel%2Flinux.git sysfs: upgrade OOB write by buggy .show hook into WARNing Buggy .show hook will get just 1 line of dmesg: fill_read_buffer: ext4_attr_show+0x0/0x600 returned bad count It may or may not oops later in some unrelated process. But buggy .show hook most likely is corrupting random memory past sysfs buffer therefore deserving more. WARN, make it more visible and let QA machines panic earlier. Also, delete useless cast -- "count" is >=0 at this point. Signed-off-by: Alexey Dobriyan Reviewed-by: Danilo Krummrich Link: https://patch.msgid.link/3cc3e8c6-c6e8-4625-a88f-f5708b935dab@p183 Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 5709cede1d756..6b3a8f62fa89c 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -70,9 +70,8 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v) * The code works fine with PAGE_SIZE return but it's likely to * indicate truncated result or overflow in normal use cases. */ - if (count >= (ssize_t)PAGE_SIZE) { - printk("fill_read_buffer: %pS returned bad count\n", - ops->show); + if (count >= PAGE_SIZE) { + WARN(1, "OOB write or bad count %zd at %pS\n", count, ops->show); /* Try to struggle along */ count = PAGE_SIZE - 1; }