Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp74950ybi; Thu, 20 Jun 2019 18:09:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEzs685Yu12a9r+qemfxmkEvrCyqRY6grE6NsMEuJdH3HnBDXhSenpBRfv04PlJ3dx3N/S X-Received: by 2002:a63:df46:: with SMTP id h6mr15164283pgj.181.1561079353395; Thu, 20 Jun 2019 18:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561079353; cv=none; d=google.com; s=arc-20160816; b=b6jzs+5ZStUL8ht7kqTqxyJ2H38xkT7QzLdrMcIRxlxkxt7zfBpjDScGS2rrirEPJC bk/L8hXeX/b4gC51YT5uQYPOfZT86U+uwofJOcEXXJ2RzvTO7t+ZrR6/KxFGaPzG2rGO +8zF3gLjfPp6HxgAaVwGNsTyzeZsnFNqzG2Ji+5ZCzdUKbpOhjOu/2nEDP11/i7YQcTw SjrOt3rqn/jOqM8QAXsdzrkFiuC0tiqubHbwOx0BOxXHVjd6ZQJ6cAzGR/y/rUYq9e0Z B7cupec4ppD5iPMQUYRGy3fX8fgXsoX64XxSXXS6DZxZnbkcgRC4vNAVLNpH+u49WHe2 zAdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:dkim-signature; bh=OQMetjZyUoUPsTFn8SOJEsiqJU03SCmw6h6Ex7ggGOM=; b=oywwAXe83G6bU/RUczEO3R19IZTeQw83Lj9ASJN5e+9PWmdzR78kmZi6YEzf6mmMFF WhFLMsDmkr2dBQJcLGUC5IfXl1l8bW0Ay4PwF/Exf+FArVhpg+gRCwabWcfUdJYDCIOy Lu9N5J/P7P7UxTFA84L+50+Ky1yKNF9tqJIYWrqKIgxgnXVkSRbSnY8Sn7pi2tpY4C7V 3ksZ4SpWlOZGBy75nAvJid1JKB6yTGPRBVkexGIrbJVAwlSVme0nU3OCGA2I/hiYPl2a ni23JgIwUwIXVddF0To2d1ON0JC5k3MAJjN3NNa0x1hV44mi71Vk9MdsSDRvg5WwABYn GP7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aK6rakns; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si1032024pgm.140.2019.06.20.18.08.50; Thu, 20 Jun 2019 18:09:13 -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=@gmail.com header.s=20161025 header.b=aK6rakns; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726070AbfFUBIr (ORCPT + 99 others); Thu, 20 Jun 2019 21:08:47 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:33909 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbfFUBIq (ORCPT ); Thu, 20 Jun 2019 21:08:46 -0400 Received: by mail-io1-f68.google.com with SMTP id k8so820983iot.1; Thu, 20 Jun 2019 18:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:thread-index :content-language; bh=OQMetjZyUoUPsTFn8SOJEsiqJU03SCmw6h6Ex7ggGOM=; b=aK6raknsrvrRPolS7lAcqPknBT9z1hipNuKzyvLgR3QnZ+e6JJzskUaz2NL64NxNPX /E3oo8PJrp2AEByUrirS3wV/u8hFtoJA+WQm9LJWpA9muaKz6OFQhLwfeG9jRIRll5N6 C3ca7J9kFjfye3zcsxF/heZC/+7vdhMvrXxpq8U3D6QDDPF3ElF9uUKyXQLWwrhDpSEh RVMBDCBtlihfE4gTshXd07ghhcSWAaHkyBhALm8iDmdijS6uu9UBKHmgkpWc1s2FlJ/m 9T9iE+C+JJ8/E1IfgaeQtF/RIJMJu0A9pyZbOT1NrYBoyAxSbAM2TZuiI+PlhBHGVEdo ZrTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=OQMetjZyUoUPsTFn8SOJEsiqJU03SCmw6h6Ex7ggGOM=; b=LJOzaxTTcr4u68F7SosvHO3QVzPn57n7Ma07Sq1UsZ1Qn9z5s2K5/n6+v56ersIE/W SU6b/lNRbdd3g75+L6fJ456xwfRCT7xYmLfQybg8fu5qS1FDmlgm7wCc8H//hiUmTPge EiDu9kbdZTlJHqOQRuckti5e8+m2vsb5QB0U4G3uFwfuucoBgdHiVJpr0XOlsPhX/8wH OP5lmIweWV3sWgrIgEHup9DiLNj4kufISmm5wwrIfUq/7howTEBaigJlr9dYVtme9uWb ow2ITsg7dVQ7s2aYA5aeUEoAlqCnSX7HXCrYXb1d0ukFKJAGyo/vAL6wAF4HmSeWuEWG sl8Q== X-Gm-Message-State: APjAAAW1+MPG1QCChCWxlEoyWh+LOxUifJjq3iQOHv11HsIUBwcHt5Rz f663i+SN8C70xMhICaarkD0= X-Received: by 2002:a02:aa8f:: with SMTP id u15mr95274817jai.39.1561079325719; Thu, 20 Jun 2019 18:08:45 -0700 (PDT) Received: from AlexPC (CPEac9e17937810-CM64777dd8e660.cpe.net.cable.rogers.com. [174.112.199.101]) by smtp.gmail.com with ESMTPSA id t133sm2863100iof.21.2019.06.20.18.08.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 18:08:44 -0700 (PDT) From: To: "'Dan Carpenter'" , "'Andrew Morton'" Cc: "'Ira Weiny'" , , , "'Matt Porter'" References: <20190529110601.GB19119@mwanda> In-Reply-To: <20190529110601.GB19119@mwanda> Subject: RE: [PATCH] rapidio/mport_cdev: NUL terminate some strings Date: Thu, 20 Jun 2019 21:08:43 -0400 Message-ID: <001101d527cd$e03b0180$a0b10480$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQHqSTig6vd4VCxw0340JcsQqG4IG6Z7CPbw Content-Language: en-us Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Acked-by: Alexandre Bounine -----Original Message----- From: Dan Carpenter Sent: Wednesday, May 29, 2019 7:06 AM 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 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