Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp997041yba; Thu, 4 Apr 2019 02:03:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwwPXABK5+HaWPyfxdlxPD5hY5tbZiJdBuS64zBuHj4zq/ufKxmvC1ZqmV6MGjK8wIGQDg X-Received: by 2002:a17:902:9a83:: with SMTP id w3mr5196745plp.241.1554368606796; Thu, 04 Apr 2019 02:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368606; cv=none; d=google.com; s=arc-20160816; b=XCMY4H5Tu2IOnaxpyZmP7cMmyd+NnzvDi/5ZNpnHylesdyfNeD/lxexJAv9fXtebMf Zojz9SkNkdVShH0uZI+o0bI7oetngcS8L5UdVF61ZHMGzt7es3qD+5UibLqF5cyAZfmc wIhElvZV7C3w8rg88yh6oZVV4tl4T7c1Va2xL0m71CiUFJCPov9jBhWs2QfsTPDZdwiJ 8J+FIUD/2iVzHSL7S0FYSdl6zZWsTbiIuLcKZMys+G9QJKSDr/8yZ1ZpdaS5tIsltzpI Npz1WZTgb9ZUyy+B8MhMfs3fknuR1FaKHjf7/yKGyjtfLgXDcqx1q+h0jY84kiWfI8Dx H2vQ== 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=m2AC3lQTPvjnTvp1MMDZR1or0JwwxmEoVm9vpLBDShs=; b=T1vuoRGFRkv7AuIojbZTx01vhzlzZ4oNGY9esr3ZOd26jo2eHR2VcJMDcnr8p1OLbg iwy7FCEynsuICeh3lp5Zeo2TPjfcElLSfal1vis3DRALNnefZeAzZO7LHSeETj/VZWTH I5yN5YFOepKTJnHNZCXo0ucis/cRTYv/RbF66mKH6zqZTQGdlnU2HGX5VKfz9RQ2fJ8x ziwIu8zWc/kstBZso++hBrnX6iyfM9rr8K+8UGDhw7SHQ3SaHZKDvzE2paz45QdzNgeg XRqx/KYUa4GmbYHiVwvTg0mqcXaI7EdLdgqxAFgc0kG8wtYjcqIR/hMKevqQpFCT2LHj MRLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wL6XcU6a; 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 137si15958214pge.63.2019.04.04.02.03.11; Thu, 04 Apr 2019 02:03:26 -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=wL6XcU6a; 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 S1729517AbfDDJBZ (ORCPT + 99 others); Thu, 4 Apr 2019 05:01:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:38522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731418AbfDDJBX (ORCPT ); Thu, 4 Apr 2019 05:01:23 -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 9CC042147C; Thu, 4 Apr 2019 09:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368483; bh=XrQnYt81Zq2ahedLObMLXsySvOVaacpfBebvvfUS6OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wL6XcU6a1KA0OZUTaa6fHg3A5nJshnktGiL/Y2YHrWvv0jL86PrgkdmIyZf4aJqTN cYyiAYSZaxEA4XskL9pYkrpRKMnVHotd/rB4Gs9jZr5uJ7fdv6yF1s9Wp+TemqahNR reeR+P46D150honIZnFjX4vlcEN6BcHXgNN/SHgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yao Liu , Steve French , Sasha Levin Subject: [PATCH 4.19 040/187] cifs: Fix NULL pointer dereference of devname Date: Thu, 4 Apr 2019 10:46:17 +0200 Message-Id: <20190404084604.963447087@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 a5ea742654aa..f31339db45fd 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1347,6 +1347,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