All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report
@ 2026-08-05  9:27 Niklas Schnelle
  2026-08-05  9:33 ` sashiko-bot
  2026-08-05 13:40 ` Niklas Schnelle
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Schnelle @ 2026-08-05  9:27 UTC (permalink / raw)
  To: Gerd Bayer, Matthew Rosato, Farhan Ali, Peter Oberparleiter
  Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Benjamin Block,
	Sven Schnelle, Ramesh Errabolu, Julian Ruess, Tobias Schumacher,
	Halil Pasic, Gerald Schaefer, Christian Borntraeger,
	Niklas Schnelle, linux-s390, linux-kernel

While report_error_write() checks that the provided buffer is at least
as large as the header struct, it does not currently check that the
buffer is large enough to contain the report with the length claimed by
report->length. If user-space provides a short buffer, i.e. a larger
report->length than the actually written payload, unininitialized kernel
data from the page allocated in kernfs_fop_write_iter() will leak into
the SCLP report.

As the entity processing the SCLP is privileged and able to access at
least the page including the report, this does not actually leak data
that it would not already be able to access. Still, the sysfs write is
malformed so reject it as invalid.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
 arch/s390/pci/pci_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
index d98d97df792a..bbb76113a4d0 100644
--- a/arch/s390/pci/pci_sysfs.c
+++ b/arch/s390/pci/pci_sysfs.c
@@ -153,6 +153,9 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
 	if (off || (count < sizeof(*report)))
 		return -EINVAL;
 
+	if (count < (report->length + sizeof(*report)))
+		return -EINVAL;
+
 	ret = sclp_pci_report(report, zdev->fh, zdev->fid);
 
 	return ret ? ret : count;

---
base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260803-fix_pci_sclp_length_check-aa68495b1990

Best regards,
-- 
Niklas Schnelle


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report
  2026-08-05  9:27 [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report Niklas Schnelle
@ 2026-08-05  9:33 ` sashiko-bot
  2026-08-05 13:40 ` Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-05  9:33 UTC (permalink / raw)
  To: Niklas Schnelle
  Cc: Vasily Gorbik, linux-s390, Alexander Gordeev, Heiko Carstens

> While report_error_write() checks that the provided buffer is at least
> as large as the header struct, it does not currently check that the
> buffer is large enough to contain the report with the length claimed by
> report->length. If user-space provides a short buffer, i.e. a larger
> report->length than the actually written payload, unininitialized kernel
> data from the page allocated in kernfs_fop_write_iter() will leak into
> the SCLP report.
> 
> As the entity processing the SCLP is privileged and able to access at
> least the page including the report, this does not actually leak data
> that it would not already be able to access. Still, the sysfs write is
> malformed so reject it as invalid.
> 
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-fix_pci_sclp_length_check-v1-1-d125cb415bc3@linux.ibm.com?part=1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report
  2026-08-05  9:27 [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report Niklas Schnelle
  2026-08-05  9:33 ` sashiko-bot
@ 2026-08-05 13:40 ` Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Schnelle @ 2026-08-05 13:40 UTC (permalink / raw)
  To: Gerd Bayer, Matthew Rosato, Farhan Ali, Peter Oberparleiter
  Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Benjamin Block,
	Sven Schnelle, Ramesh Errabolu, Julian Ruess, Tobias Schumacher,
	Halil Pasic, Gerald Schaefer, Christian Borntraeger, linux-s390,
	linux-kernel

On Wed, 2026-08-05 at 11:27 +0200, Niklas Schnelle wrote:
> While report_error_write() checks that the provided buffer is at least
> as large as the header struct, it does not currently check that the
> buffer is large enough to contain the report with the length claimed by
> report->length. If user-space provides a short buffer, i.e. a larger
> report->length than the actually written payload, unininitialized kernel
> data from the page allocated in kernfs_fop_write_iter() will leak into
> the SCLP report.
> 
> As the entity processing the SCLP is privileged and able to access at
> least the page including the report, this does not actually leak data
> that it would not already be able to access. Still, the sysfs write is
> malformed so reject it as invalid.
> 
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
>  arch/s390/pci/pci_sysfs.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
> index d98d97df792a..bbb76113a4d0 100644
> --- a/arch/s390/pci/pci_sysfs.c
> +++ b/arch/s390/pci/pci_sysfs.c
> @@ -153,6 +153,9 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
>  	if (off || (count < sizeof(*report)))
>  		return -EINVAL;
>  
> +	if (count < (report->length + sizeof(*report)))
> +		return -EINVAL;
> +
>  	ret = sclp_pci_report(report, zdev->fh, zdev->fid);
>  
>  	return ret ? ret : count;
> 
> ---

While Sashiko is clean my own bot correctly noted that in
kernfs_fop_write_iter() it's really a kmalloc() being overrun not a
page allocated for this purpose. Also it noted that maybe s390/pci
makes more sense as a subsystem prefix. Oh, and I really should include
a check for missing Fixes tag and Cc stable in my local review skill.
Will send a v2 ;)

Thanks,
Niklas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-05 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  9:27 [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report Niklas Schnelle
2026-08-05  9:33 ` sashiko-bot
2026-08-05 13:40 ` Niklas Schnelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.