Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3369443imu; Mon, 28 Jan 2019 03:45:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN4fWt64A6raPUKwKnNHS50ucopqAzEfSe+5OO+2/OK9JJZjPPfzVfxmSKXluU2+WdwhpCyI X-Received: by 2002:a62:e704:: with SMTP id s4mr21844369pfh.124.1548675944699; Mon, 28 Jan 2019 03:45:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548675944; cv=none; d=google.com; s=arc-20160816; b=HM29zrAwGGwf7V2Y+KLSfL0A5tV1IBoOzQqxNJvLH22FqXtoH4n55o7XUzoZSH+Ov0 nxc6E21fnjFomgKWDWmsWbso4azo10R+3GL316fYVTJe2PbU0fZONBb8OO8VYkap52Z3 LehKQmIV9GFpVYtvM5EuK4FBG9DhkPVpvnN0JvQpLDHIHeUv6eeK6DKOWCyuiskYW7gQ gKw9xVn5rIdZKQmPT47mE8sePQzwv20e3biXo4Wl3IwnBoTDkExX3CPej8+kfYCLMjXz i6a1iA/a6o5oI//PdT10FgiFD4p0dQ1A8dHNtAhK4bGgGWOPWQiHGCi0oHGyfrC1JdGm o/aw== 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=mJCguVNKc+8bQ+/BGoDzkXyNxoJPZ0J6oJrPAbBJLg8=; b=wV9XdkqgQaHJ8JWlCJt4jiMdVD21RbcbJVOj8iN/cBaLEQnBq2toweC0f/n37DfLDx 2Qea02OscicyyFl7hXgoH0jDiJ7QV4IrGtElC/CtGcsA14Mj8Z7Bdb/BxTbJH6nB6q/v xYG9ZOQAMkxTopCie6ei6iIuLS5h7SpoQQzzc6wfw1oo1zKMDsexNbZ3S8U50WJ301f1 DqpbyGi0sovNPejZSlvmlih2IqUSHNsSIjjISdTUJMfnNTBQozXLGl0T/01nUvrcJ62o S5y8XMKWlqcrsO1Etg0TgS7rJLptekkw8kq8uGj+Cxk5NzUxES3BlgjkhQ+FyZawmpzp I0FQ== 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 r59si35665512plb.247.2019.01.28.03.45.29; Mon, 28 Jan 2019 03:45:44 -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 S1726783AbfA1LoY (ORCPT + 99 others); Mon, 28 Jan 2019 06:44:24 -0500 Received: from m97179.mail.qiye.163.com ([220.181.97.179]:32235 "EHLO m97179.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbfA1LoY (ORCPT ); Mon, 28 Jan 2019 06:44:24 -0500 Received: from kernel_test2.localdomain (unknown [120.132.1.243]) by m97179.mail.qiye.163.com (Hmail) with ESMTPA id 63EAAE01276; Mon, 28 Jan 2019 19:44:20 +0800 (CST) From: Yao Liu To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Yao Liu Subject: [PATCH] nfs: Fix NULL pointer dereference of dev_name Date: Mon, 28 Jan 2019 19:44:14 +0800 Message-Id: <1548675854-19556-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: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OD46AQw*DzlCNxdJEikDTDlW CQ0wFEJVSlVKTk9DTUxOQ01LTUhLVTMWGhIXVQIUDw8aVRcSDjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSU9IWVdZCAFZQUlLSUk3Bg++ X-HM-Tid: 0a689446484720bdkuqy63eaae01276 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 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 --- fs/nfs/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 22ce3c8..0570391 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1895,6 +1895,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, ']'); -- 1.8.3.1