From: sashiko-bot@kernel.org
To: "Mete Durlu" <meted@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 3/3] s390/diag: Add diag204 IOCTL to diag misc device
Date: Wed, 21 Oct 2026 11:13:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-180156@kernel.org> (raw)
In-Reply-To: <20261021-diag204ioctl-v1-3-25645b97bf4e@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] s390/diag: broken copy_to_user() error check in diag204_buf()
--
commit bc2db0b15c4152f85ed3a637d54a7ba9099ebe1e
Author: Mete Durlu <meted@linux.ibm.com>
s390/diag: Add diag204 IOCTL to diag misc device
This commit adds the DIAG204_GET_LEN and DIAG204_GET_BUF ioctl commands
to the /dev/diag misc device to allow userspace with CAP_SYS_ADMIN to
query and retrieve diag204 data.
> diff --git a/arch/s390/kernel/diag/diag204.c b/arch/s390/kernel/diag/diag204.c
> index 8e1909e6caf90..967b6e0bc667a 100644
> --- a/arch/s390/kernel/diag/diag204.c
> +++ b/arch/s390/kernel/diag/diag204.c
[ ... ]
> +long diag204_buf(unsigned long arg)
> +{
> + struct diag204_request __user *udata;
> + int rc, allow_busy, allow_busy_wait;
> + u64 address;
> + void *buf;
> +
> + if (!diag204_is_available())
> + return -EOPNOTSUPP;
> + udata = (struct diag204_request __user *)arg;
> + if (get_user(address, &udata->address))
> + return -EFAULT;
> + if (get_user(allow_busy, &udata->allow_busy))
> + return -EFAULT;
> + if (get_user(allow_busy_wait, &udata->allow_busy_wait))
> + return -EFAULT;
> + buf = diag204_allocate_buffer();
> + if (!buf)
> + return -ENOMEM;
> + rc = diag204_store(buf, allow_busy, allow_busy_wait);
> + if (rc < 0) {
> + diag204_free_buffer(buf);
> + return rc;
> + }
> + rc = copy_to_user((void __user *)address, buf,
> + diag204_get_buf_size());
> + if (rc < 0)
> + rc = -EFAULT;
[Severity: Medium]
Since copy_to_user() returns the positive number of uncopied bytes on a
fault rather than a negative error code, will this check miss faults when
copying to address in diag204_buf() via diag_ioctl() (DIAG204_GET_BUF) and
return a positive byte count instead of -EFAULT?
Should this check if (rc) (or if (copy_to_user(...))) instead?
> + diag204_free_buffer(buf);
> + return rc;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-diag204ioctl-v1-0-25645b97bf4e@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-10-21 11:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 10:28 [PATCH 0/3] s390: Diag204 Rework Mete Durlu
2026-10-21 10:28 ` [PATCH 1/3] s390/diag204: Introduce diag204 rework Mete Durlu
2026-10-21 10:52 ` sashiko-bot
2026-10-21 10:28 ` [PATCH 2/3] s390/diag204: Replace diag204 users with new implementation Mete Durlu
2026-10-21 11:09 ` sashiko-bot
2026-10-21 10:28 ` [PATCH 3/3] s390/diag: Add diag204 IOCTL to diag misc device Mete Durlu
2026-10-21 11:13 ` sashiko-bot [this message]
2026-10-21 14:01 ` Hendrik Brueckner
2026-10-21 14:12 ` Mete Durlu
2026-10-22 7:04 ` [PATCH 0/3] s390: Diag204 Rework Mete Durlu
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=sashiko-outbox-180156@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=meted@linux.ibm.com \
--cc=sashiko-reviews@lists.linux.dev \
/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