mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Gerd Bayer <gbayer@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Farhan Ali <alifm@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Benjamin Block <bblock@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Ramesh Errabolu <ramesh@linux.ibm.com>,
	Julian Ruess <julianr@linux.ibm.com>,
	Tobias Schumacher <ts@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Christian Borntraeger	 <borntraeger@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] s390/sclp: Fix leak of uninitialized kernel data in SCLP report
Date: Wed, 05 Aug 2026 15:40:30 +0200	[thread overview]
Message-ID: <5836747daf3b109e0338f8e600f10a0b7dd02602.camel@linux.ibm.com> (raw)
In-Reply-To: <20260805-fix_pci_sclp_length_check-v1-1-d125cb415bc3@linux.ibm.com>

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

      reply	other threads:[~2026-08-05 13:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  9:27 Niklas Schnelle
2026-08-05 13:40 ` Niklas Schnelle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5836747daf3b109e0338f8e600f10a0b7dd02602.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=bblock@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gbayer@linux.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=julianr@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=ramesh@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=ts@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®