Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5579995img; Wed, 27 Mar 2019 11:04:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxu9DiGeINJPVOGW7/ExIyEK/G+x/XOyaPkKgxNflSq9XbU8POMXtZnQU/ys0lKxrRS+nrs X-Received: by 2002:a17:902:44a4:: with SMTP id l33mr38431227pld.292.1553709895840; Wed, 27 Mar 2019 11:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709895; cv=none; d=google.com; s=arc-20160816; b=uOOlq9z18oblTPFcVjk1pmrc5DTDI3MfmuZLwxH0+4SjlEUCGZY1/GniOU+XMP4jzW EHFNaXKmQc3cv8/RYU0O15EoypabzrSL26evsFxoWg1w6LvXO1pEtczTXVZE3k48vcAA nBJ+7BibVjWgM/zY0DzDm1ANsRaBs4XQskVT6AYZdfl5wclC8d8NMS4D4auYRqWcMEEj 3uAIWXrSnqe5I3nuqOJlTkQLQx9DjUEtAl+1smvjx3+amcyNwCVcgzwLC1pOpeVaqweO LIyxFB9Z9LKmtPbcoEi4EnsyAYckXmw2AjpFF1VTXRpzHLFuORON5HEVsZuLOyCytVKQ UzPg== 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=8412auz/fjGKvUJKYfaR4X1mlxax59L1qCeurrdgZow=; b=CoyiEJrXjh8KXUHEGXq4BmNFa7f1/pKi2dWsfJenel0HTaKbpQJZxR8tatTY2BlzfM YoOkIt+FsYVlYICbvCYd0IZ3pMx51Fj5yAd2LEISL+wlIj7E48uYJ8pWARYUWWjkmdIO buChwStWo11i12yxnLwUrQv/fwuD75iEG/8hfGWwrolY9B6JPldmdm3L8aefKR35YqO1 4GsloLbxP8/nPASx1iTLvuj2NgHa+5xSb6HzNbuTnr3ZWMbHIbOGowg4/3dIBVauU+gO ngqaV+dIDMiJK3k8qjqStgrpG2XQE9mGfj8jOcbh1XhmjdrKnaGVPlBKBGjLbDzH2Vfj HDVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oN7iWcaO; 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 a90si20660639pla.401.2019.03.27.11.04.40; Wed, 27 Mar 2019 11:04:55 -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=oN7iWcaO; 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 S1728929AbfC0SDd (ORCPT + 99 others); Wed, 27 Mar 2019 14:03:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:43784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732498AbfC0SD3 (ORCPT ); Wed, 27 Mar 2019 14:03:29 -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 0603E2075C; Wed, 27 Mar 2019 18:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709808; bh=Ii7mdWLM0X85/ZxY9kH/FvQqPRcWFcHxIESPoDg5v24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oN7iWcaO8+SviWcrISm9Memxy8Qn/T4xjZPgIA3UzfQcGWvFl4Y8BRrOlER2k6LFU cEUAqyxBmmlVGJ/hubJO2jYNhFsxUWPLR3/cshVsLn94I1A/aJoUqXtH5nZtLZaI+2 FHDZM8Cto4YfcOPgvy/7yb3M31qSQxAcFlkt6hlU= 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 5.0 050/262] cifs: Fix NULL pointer dereference of devname Date: Wed, 27 Mar 2019 13:58:25 -0400 Message-Id: <20190327180158.10245-50-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 e61cd2938c9e..9d4e60123db4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1487,6 +1487,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