Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5616383img; Wed, 27 Mar 2019 11:47:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyttt1Dn6ViianYiqXiG79i0ZeW3ofcq7vFPEKI0/UDCq4QyGv9ugSPr9Lc8bAUrn/3Cosh X-Received: by 2002:a62:26c1:: with SMTP id m184mr6743034pfm.102.1553712442117; Wed, 27 Mar 2019 11:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712442; cv=none; d=google.com; s=arc-20160816; b=itkTBvAgFpwwmgrNY769KPg/ITAVQ7qDe9CdaBKWAZSzBXZB986idGYe8exiyTxgn9 mxVUJnk7/5kpX4ZpKpjP/DfyzkXn1wtn35V5Do6fXHN0mEuuM8ugGOTCkmFZaZWlNOh/ zHSkjOQUOCWhe2EGD+RyLHttZgAYFTZwPV+s2m4pE9cSkzWRS95aCrsWntpBnOubKeBq ehd/nJ9V2WJv4CDFf0yFEEv6b9sqC+sL1B6hy25dIEloRIeu/F/Y1cf62NQyQML0NiJd YFFf2NmoWTEXGFtdOWx85Q//f64sz2e8Sdck3e0itNqxG+hbQPlxMmryFFPqU91KJ6O2 +Xyg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8vzxKgGef8vIUzs61rkFWMd08myt8Ik8pO5s8tvZeQ8=; b=p6kmpS2c7mJcJBH6Yxq8AKtzHgiPbRFQx8a2D1OvrMfcQuYwdpsM9xgaD2rSOyo2nm NFgM3FJDdda3MPuW0WZEFtaTIAUBQeSEKybycoFFHg+4BsR9JitCWKRgauFq24CyuPQj 3zDhyZoXf1z1K8YIp3JUmas6xGL6Q6IR9A90146cRPHVoK3MpMXCOvKsPj6T3liYm0y1 YGtA3YrZKS1eBVRp/SmYKPOOo4owfhgBiXHUm1CTI+IPmxvVVoS9gv3SSrsdSWyX87y2 Zm0X6V8CeDlkLKLd77G+PXkk7WbhgX1SHXoCqNiFVPwEHg+lWBQ9/mmwdycmItwy+QU4 SeGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cmJ9jCJM; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si18589197pgc.307.2019.03.27.11.47.06; Wed, 27 Mar 2019 11:47:22 -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=cmJ9jCJM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391112AbfC0SVR (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:39066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391098AbfC0SVP (ORCPT ); Wed, 27 Mar 2019 14:21:15 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDC6D217D9; Wed, 27 Mar 2019 18:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710874; bh=Do+97uAGXIRSfV9q24bcN96ipIpTYk9+VIffGp3ehxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmJ9jCJMc7q1ZZzLjKwRTkTVtBzNZiNQip6LVQ4kloyI6dr8ca83CgYjPknI8Lh0I 2PmOyv/Jostccair8wqmo5orB/dskV0wLKblM3620cu/Evo3yKTaIx+t7G0xFlBATD oDsFCqLk8Rju8SrD1z7vf2BL3NW6Ud30LrwQtJL8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yao Liu , Steve French , Sasha Levin , linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 19/87] cifs: Fix NULL pointer dereference of devname Date: Wed, 27 Mar 2019 14:19:32 -0400 Message-Id: <20190327182040.17444-19-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yao Liu [ Upstream commit 68e2672f8fbd1e04982b8d2798dd318bf2515dd2 ] There is a NULL pointer dereference of devname in strspn() The oops looks something like: CIFS: Attempting to mount (null) BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 ... RIP: 0010:strspn+0x0/0x50 ... Call Trace: ? cifs_parse_mount_options+0x222/0x1710 [cifs] ? cifs_get_volume_info+0x2f/0x80 [cifs] cifs_setup_volume_info+0x20/0x190 [cifs] cifs_get_volume_info+0x50/0x80 [cifs] cifs_smb3_do_mount+0x59/0x630 [cifs] ? ida_alloc_range+0x34b/0x3d0 cifs_do_mount+0x11/0x20 [cifs] mount_fs+0x52/0x170 vfs_kern_mount+0x6b/0x170 do_mount+0x216/0xdc0 ksys_mount+0x83/0xd0 __x64_sys_mount+0x25/0x30 do_syscall_64+0x65/0x220 entry_SYSCALL_64_after_hwframe+0x49/0xbe Fix this by adding a NULL check on devname in cifs_parse_devname() Signed-off-by: Yao Liu Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 33e65b71c49a..f291ed0c155d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1201,6 +1201,11 @@ cifs_parse_devname(const char *devname, struct smb_vol *vol) const char *delims = "/\\"; size_t len; + if (unlikely(!devname || !*devname)) { + cifs_dbg(VFS, "Device name not specified.\n"); + return -EINVAL; + } + /* make sure we have a valid UNC double delimiter prefix */ len = strspn(devname, delims); if (len != 2) -- 2.19.1