From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40D2EC43381 for ; Sat, 23 Feb 2019 21:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDACC2086C for ; Sat, 23 Feb 2019 21:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956074; bh=HnbKnRWz+OUBOlMk6fo+ms7MyuxIXy5k3djy9votkRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GwKqvNn6rn8u1q4qfzkqSXU6s4GkrXtPsPOkyhcDXIdEn5P8aVFlNKBjKkef4GGjl 0YWShSzq008Ne+WIrc9eeoF6Q7WwMtQ1Pej7/2h9aty2ntJ8ztzgg4wGqFaY26r0Oh +m+/+QXD01LGOEgqoXykl3DVPICZC85RTuvrtLzw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727942AbfBWVHw (ORCPT ); Sat, 23 Feb 2019 16:07:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:42984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729141AbfBWVHo (ORCPT ); Sat, 23 Feb 2019 16:07:44 -0500 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 35C2820855; Sat, 23 Feb 2019 21:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956063; bh=HnbKnRWz+OUBOlMk6fo+ms7MyuxIXy5k3djy9votkRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SieugyjymWZ/MWhj6dgU6mU7WfuIn22dhpS71t15sHG/a+cyoGF7esvsG/sm0f9VI +yboeX16NQ1AJA4gHfD3lsmEJhbTVrbwbnoM8N3VSKTyaynKLcYqhmpgKrt+Uk1n5Z xuasasdYe+qov4lYf9hcerdxrmGwaxdNYrN/C+eY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yao Liu , Anna Schumaker , Sasha Levin , linux-nfs@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 38/65] nfs: Fix NULL pointer dereference of dev_name Date: Sat, 23 Feb 2019 16:06:13 -0500 Message-Id: <20190223210640.200911-38-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190223210640.200911-1-sashal@kernel.org> References: <20190223210640.200911-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 80ff00172407e0aad4b10b94ef0816fc3e7813cb ] There is a NULL pointer dereference of dev_name in nfs_parse_devname() The oops looks something like: BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 ... RIP: 0010:nfs_fs_mount+0x3b6/0xc20 [nfs] ... Call Trace: ? ida_alloc_range+0x34b/0x3d0 ? nfs_clone_super+0x80/0x80 [nfs] ? nfs_free_parsed_mount_data+0x60/0x60 [nfs] mount_fs+0x52/0x170 ? __init_waitqueue_head+0x3b/0x50 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 dev_name Signed-off-by: Yao Liu Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index ac4b2f005778c..25bd29176053f 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1906,6 +1906,11 @@ static int nfs_parse_devname(const char *dev_name, size_t len; char *end; + if (unlikely(!dev_name || !*dev_name)) { + dfprintk(MOUNT, "NFS: device name not specified\n"); + return -EINVAL; + } + /* Is the host name protected with square brakcets? */ if (*dev_name == '[') { end = strchr(++dev_name, ']'); -- 2.19.1