Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6176689ybi; Wed, 29 May 2019 04:07:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwoMvu7DpyvqMnOPqwyO7a2FTr3uEshBlF+l3l8kU8vGd2ZpZrUGYF8GYLam6BklDnOP+K X-Received: by 2002:a17:902:5c6:: with SMTP id f64mr139308951plf.208.1559128077225; Wed, 29 May 2019 04:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559128077; cv=none; d=google.com; s=arc-20160816; b=iQOWa9i85N5uyCRWKrOo/3+dP8aNP0iMwNfqNDvNV7a42PuQwHJ/Fi1hbMPVsxSg8X 3MMB9ERp6+dhTtudg7TjRITl3pKC13vzRLoRZ90zg+XyLevvKINkKrMBDmKBA8EThXq8 R3yoXjElShokCa+JMtjUG79yjZKXUfhZgbCzHDcQKRwPMTt1jmWq5diIzJGQVvmSYa4A TDR+A4dq67c78gjDP44qEleC2E4j+dr0+LVyex7TLh5p8kypeQem7NMCELgBx/RXtW5q NSpOu61VEMRMRqBvFjBQyj+vG4M0SEq2TOtc17CiiD4Oan19kwOj6jzbNUY9lQArqENl G6UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=YsLSH87kGhD3EoOg93XkIPoYdR2SttgsnC5i7XVabKw=; b=BzHSkOyu1Cfeyl5Es9DMfs5Ywyf16nojRA/U381RrXNoRJK1YpAGUuU88Kic6anyFu ww7RM1IoNKeN/GZQxWMTjSIuBFuRwxvkdlMQ2CsDPTOSe2+Kg79QlFvwsC9IPgTh6nQN MUtycMZNBnkw4YC0ohn7jrFWHWWIYpC4gBceBLMHKWOcvtjDUALLRgPDNI3RVZJqJKdV smVybxm0INg5Byo/SddOlGo5BTEeGnSzL+tZp02D5YAAXUloA+6SRBqxdvaJJe3NgDdD O2+H+BLJcyJ7h0XRXKde77fkEyxW7daDS0BBGO0So0Y9xr1U7eGpIKTzbUMunV4MhDHS oypA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=elHaOVv7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y62si7218541pgy.362.2019.05.29.04.07.39; Wed, 29 May 2019 04:07:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=elHaOVv7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726612AbfE2LG0 (ORCPT + 99 others); Wed, 29 May 2019 07:06:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59534 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbfE2LG0 (ORCPT ); Wed, 29 May 2019 07:06:26 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4TB3o6Q041065; Wed, 29 May 2019 11:06:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=YsLSH87kGhD3EoOg93XkIPoYdR2SttgsnC5i7XVabKw=; b=elHaOVv7LQeXuPh4utXiTks9jTpxcDHyskAPz+fCW91PlhRlpnfArfzkmcWWCCdDbtHA 2pHr0qHl11MHg7fxjcXGfm0Dn8L+KP4i3iAh01wCu1qemK8Y4luGxeFx5VOW4Q9YCuXI JnH4f36BKFj13d9gBUykaTugqEK2UDSZM4or8FnDBu0MAOa7JXUPXREYv4+9N6wWj/xe b7TUODT+8wGVa/pxoZmI2j0d9WmEYmdiHyG8XQrH87YRyGHV79VVfdzfdrzVhS6z9aqj cOV7c2h2B2X5z/sYUEsDiXpejbe4gfInDcYZFBkwrvIAPNtvb0lxHWW2avdVC5AgKzFS GQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2spxbq8u04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2019 11:06:17 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4TB4NtL007754; Wed, 29 May 2019 11:06:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2sqh73mwsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2019 11:06:16 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4TB69Ma012745; Wed, 29 May 2019 11:06:09 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 May 2019 04:06:08 -0700 Date: Wed, 29 May 2019 14:06:01 +0300 From: Dan Carpenter To: Matt Porter Cc: Alexandre Bounine , Andrew Morton , Ira Weiny , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] rapidio/mport_cdev: NUL terminate some strings Message-ID: <20190529110601.GB19119@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9271 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905290074 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9271 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905290075 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dev_info.name[] 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; + dev_info.name[sizeof(dev_info.name) - 1] = '\0'; rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name, 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; + dev_info.name[sizeof(dev_info.name) - 1] = '\0'; mport = priv->md->mport; -- 2.20.1