Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2749608ybh; Mon, 5 Aug 2019 06:15:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcg7Xko6nNNb+aXFIzSo1XCP3rFszLFUgnmlskF9D+c5P2CwmA5B8lC7tGxuu5WM1ktDL/ X-Received: by 2002:aa7:8711:: with SMTP id b17mr73974470pfo.234.1565010939573; Mon, 05 Aug 2019 06:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010939; cv=none; d=google.com; s=arc-20160816; b=mnFgNWSBmRCzCj2JcPMdFUVOMZ7O/oRaxehkhVsZDD7D9uQJacJe+n7xSybnlBBUD3 FLNX0oXy+Sv6xlopiFGyyTlLmNn6LH50SsqNLeKjQ4+MXSYsrPhYgxo2aa5kt2TOiSfM 3ssvo+AXfkYIftcq0zkgTqwyiKx9q7cZPok2Dfn+rBcv94MEzPtq35O8pg3r6/BKUxKh oIEjAT//0JUe6/imbCtplNwt5Dq8k08HDUflCRDj3TX8C0BIRhIXSLbTqlsusdtKEDUv 1SbzvxJ462zdOIwMIenXw1H1pfGqGHX5ZrQ3X/3Qv0yKG0gE8wLNtMiHwSBvYS13uK42 582Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8m6vwzoTrb38PxmfnyIRrz13GulsEKr4qqcWk7k0WtY=; b=ga2yyCZPqhBQvllyp/NojWJd64Tv3TiWE91LTuudFkiYRh9/3q09S32QJG5PyppSa8 6Z4eUIiFT8Lh2doCl1nru++laZ8Nn1J0sIlEfwk2zE1oGIA5Y5kZGRbKMoCz6OyaFu5v 5NPTlzVhbE1rQ8HxpzKioTlG6KjMv/j2S1QO1iRm/g5sHz4P5IQvzi1lFF2QcrwCiTNH WaiOJ6nR6D4vuL31IzaLnprcK1rsiKAd4Zx6fQ9fCGvLvwMR+pgw23jTmt9R0HcTLQ1B Ue7nwwHjEYcCkifaP34PDLrRC2l7APUZ0ffjqVX8A9S/Hq/jJ++FoAN9OILVwTGkJQOg Njow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1RNeQB+W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si39830656pls.145.2019.08.05.06.15.24; Mon, 05 Aug 2019 06:15:39 -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=@kernel.org header.s=default header.b=1RNeQB+W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbfHENHe (ORCPT + 99 others); Mon, 5 Aug 2019 09:07:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:44968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729795AbfHENH0 (ORCPT ); Mon, 5 Aug 2019 09:07:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1FFE121738; Mon, 5 Aug 2019 13:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010445; bh=6snseJvCWboeNdOF7uhd78WpgriehZ012jDqd7F3R+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1RNeQB+WCqAx7d+40DW7aRHikhVmkCD8iH4XYGmqihHauNx3Q39MGCVBANnmGulmT stjpz4c/5ACtNnKmjlIwOJCJYQYmLDbLSrrJOQPVIph+qETEKRWrqXHveHSyu50Zj2 Yg6OXMjICIGenRqCvPE3TSdI06uorOdXkXBxaEtY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Alexandre Bounine , Ira Weiny , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 26/53] drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings Date: Mon, 5 Aug 2019 15:02:51 +0200 Message-Id: <20190805124930.953644174@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124927.973499541@linuxfoundation.org> References: <20190805124927.973499541@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 156e0b1a8112b76e351684ac948c59757037ac36 ] 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. Link: http://lkml.kernel.org/r/20190529110601.GB19119@mwanda Fixes: e8de370188d0 ("rapidio: add mport char device driver") Signed-off-by: Dan Carpenter Acked-by: Alexandre Bounine Cc: Ira Weiny Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 76afe1449cab1..ecd71efe8ea00 100644 --- a/drivers/rapidio/devices/rio_mport_cdev.c +++ b/drivers/rapidio/devices/rio_mport_cdev.c @@ -1742,6 +1742,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); @@ -1873,6 +1874,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