Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3377602imu; Mon, 28 Jan 2019 03:56:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6LRiffmUFvYNwOAUfqiY9V08R7/dMWNmpniZh3aLqMyP7WJQv0dz8qws1uX/sarwOdUfeW X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr21805665plo.50.1548676586512; Mon, 28 Jan 2019 03:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548676586; cv=none; d=google.com; s=arc-20160816; b=yEwEOg6l7FvjG6fdqoVO5B6lhUIgSlPCM015dM2fAbQBE5oxFqW7dBpeoXgqLU9CV9 62GecQTn9fF8W9rpXh7TewkCGD22BoElM71EfQupNQSxZmDW6Vs7sf7jXDwcyI7T6V3G 6/ZYgQaBbynOX0e8k7Al+fXOUnQuL2Nst1VXSZ/bb8XaiVTC4cy64NkG617WoQ9lc4tc 5sajmfyU2cmtD8K0ggppoY8bFjcz8N2wU589y8dmjCOwtZFwJ1ILr4xjvewWGjPkgfZW l+Qa1f9lDTT+IP/H6cHpCNHGdq3Itio1LqMa7qN9tSJgjxkwLJmNZV2DDgyjQQ5JkqdB Kzzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=qpL6ZyvPlls0Q1LcM1inWfea3E9R7nyzdZiSymHn9eg=; b=lBtHFwcdDZVGOA1gzYLNA1IZVAJSLfnFH2lGV1ytQkIID3kM3J/rd1LUMO5hEAeYbu TAfoLljLoVJgmE7UMEeBN3zk27mwhujubTxtpg81QSNv4S9xzSC7Q3blKVWX+srz4SWV oOUiZSblBHvgOSt85BuEjS0wiMhTOr2d3V9h3pg/YjENwu3paoAPCZemMfTr6kjM8w4I dToMyX7VCz0tFOp9yXaEMeF+H5fNCphp1lNHHl2UuFTDRXkqRzupOieGnym5J/n/H42m Z+kOjg+rGi2TCMdaSd8ANLKp+3edfNsu2MsdpvTAffnAFV5lPa9EZ+skKHhf68oR1oBQ adoQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si32700999pld.155.2019.01.28.03.56.11; Mon, 28 Jan 2019 03:56:26 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbfA1L4F (ORCPT + 99 others); Mon, 28 Jan 2019 06:56:05 -0500 Received: from m97188.mail.qiye.163.com ([220.181.97.188]:9177 "EHLO m97188.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbfA1L4F (ORCPT ); Mon, 28 Jan 2019 06:56:05 -0500 X-Greylist: delayed 511 seconds by postgrey-1.27 at vger.kernel.org; Mon, 28 Jan 2019 06:56:04 EST Received: from kernel_test2.localdomain (unknown [120.132.1.243]) by m97188.mail.qiye.163.com (Hmail) with ESMTPA id B4BFD96BC38; Mon, 28 Jan 2019 19:47:30 +0800 (CST) From: Yao Liu To: sfrench@samba.org Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, Yao Liu Subject: [PATCH] cifs: Fix NULL pointer dereference of devname Date: Mon, 28 Jan 2019 19:47:28 +0800 Message-Id: <1548676048-19626-1-git-send-email-yotta.liu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 X-HM-Spam-Status: e1kIGBQJHllBS1VLV1koWUFJQjdXWS1ZQUlXWQkOFx4IWUFZMjUtOjcyP0 FLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ORw6HRw6LjlPFRcuOC0QTC8d QyMwCTdVSlVKTk9DTUxNS05LQkxMVTMWGhIXVQIUDw8aVRcSDjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSU9IWVdZCAFZQUlKQkk3Bg++ X-HM-Tid: 0a6894492fce20bckuqyb4bfd96bc38 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/cifs/connect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 683310f..39abb18 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1465,6 +1465,11 @@ static int cifs_parse_security_flavors(char *value, 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) -- 1.8.3.1