From: sohu0106 <sohu0106@126.com>
To: vneethv@linux.ibm.com, oberpar@linux.ibm.com
Cc: linux-s390@vger.kernel.org
Subject: buffer overflow in vfio_ccw_async_region_write/vfio_ccw_async_region_read
Date: Tue, 12 Jul 2022 17:52:51 +0800 (CST) [thread overview]
Message-ID: <255c7ef5.6bf9.181f1d3637e.Coremail.sohu0106@126.com> (raw)
In the vfio_ccw_async_region_write/vfio_ccw_async_region_read function of drivers/s390/cio/vfio_ccw_async.c, parameter "size_t count" is pass by userland, if "count" is very large, it will bypass "if (pos + count > sizeof(*region))".(such as count=0xffffffff). Then it will lead to buffer overflow in "copy_from_user((void *)region + pos, buf, count)".
diff --git a/vfio_ccw_async.c_org b/vfio_ccw_async.c
index 7a838e3..33339ad 100644
--- a/vfio_ccw_async.c_org
+++ b/vfio_ccw_async.c
@@ -21,7 +21,7 @@ static ssize_t vfio_ccw_async_region_read(struct vfio_ccw_private *private,
struct ccw_cmd_region *region;
int ret;
- if (pos + count > sizeof(*region))
+ if (pos + count > sizeof(*region) && pos + count > pos)
return -EINVAL;
mutex_lock(&private->io_mutex);
@@ -43,7 +43,7 @@ static ssize_t vfio_ccw_async_region_write(struct vfio_ccw_private *private,
struct ccw_cmd_region *region;
int ret;
- if (pos + count > sizeof(*region))
+ if (pos + count > sizeof(*region) && pos + count > pos)
return -EINVAL;
if (!mutex_trylock(&private->io_mutex))
next reply other threads:[~2022-07-12 10:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 9:52 sohu0106 [this message]
2022-08-30 19:13 ` buffer overflow in vfio_ccw_async_region_write/vfio_ccw_async_region_read Eric Farman
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=255c7ef5.6bf9.181f1d3637e.Coremail.sohu0106@126.com \
--to=sohu0106@126.com \
--cc=linux-s390@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=vneethv@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