Kernel-Janitors Archive on
 help / color / Atom feed
From: Dan Carpenter <>
To: Matt Porter <>
Cc: Alexandre Bounine <>,
	Andrew Morton <>,
	Ira Weiny <>,,
Subject: [PATCH] rapidio/mport_cdev: NUL terminate some strings
Date: Wed, 29 May 2019 11:06:01 +0000
Message-ID: <20190529110601.GB19119@mwanda> (raw)

The[] array has space for RIO_MAX_DEVNAME_SZ + 1
characters.  But the problem here is that we don't ensure that the user
put a NUL terminator on the end of the string.  It could lead to an out
of bounds read.

Fixes: e8de370188d0 ("rapidio: add mport char device driver")
Signed-off-by: Dan Carpenter <>
 drivers/rapidio/devices/rio_mport_cdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 4a4a75fa26d5..3440b3e8e578 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -1690,6 +1690,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
 	if (copy_from_user(&dev_info, arg, sizeof(dev_info)))
 		return -EFAULT;
+[sizeof( - 1] = '\0';
 	rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x",,
 		   dev_info.comptag, dev_info.destid, dev_info.hopcount);
@@ -1821,6 +1822,7 @@ static int rio_mport_del_riodev(struct mport_cdev_priv *priv, void __user *arg)
 	if (copy_from_user(&dev_info, arg, sizeof(dev_info)))
 		return -EFAULT;
+[sizeof( - 1] = '\0';
 	mport = priv->md->mport;

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 11:06 Dan Carpenter [this message]
2019-06-21  1:08 ` alex.bou9

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:

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

  git send-email \
    --in-reply-to=20190529110601.GB19119@mwanda \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Kernel-Janitors Archive on

Archives are clonable:
	git clone --mirror kernel-janitors/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernel-janitors kernel-janitors/ \
	public-inbox-index kernel-janitors

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone