From patchwork Wed Jan 7 00:28:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Haynes X-Patchwork-Id: 5578481 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B7CF9F507 for ; Wed, 7 Jan 2015 00:30:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C62A2010B for ; Wed, 7 Jan 2015 00:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B5E3201EF for ; Wed, 7 Jan 2015 00:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754624AbbAGA3e (ORCPT ); Tue, 6 Jan 2015 19:29:34 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:52812 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754487AbbAGA3a (ORCPT ); Tue, 6 Jan 2015 19:29:30 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so1066623pad.9 for ; Tue, 06 Jan 2015 16:29:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j4vcfHBC/NgZhV2B1nTJOZqVBFh8FdzsrJh2+W8pHVE=; b=jYn180r5Xae8f5LCXAB2w924nDprExwixOSMRXEV+m3QfXnTLzv7am+BGf2YlcrZB3 ABiQtssbfwxaHfRiLiDx7StsgNkysvOkCisVUvZEtG4V2FCWT3ToAXuFDLvvWVg4VfHL pi2NjFTHviommZ7l8FxpdMHFKl9ZK4Vf9iAH4guBIuPdQbx2fLW8XxIKaAFIQYYt37BW jghou9zWxRrJAWMV7Xab8psD3g/LxFp+RmMGyB9Z2VxUPyL/CQPWHUzRjOx3OW6ZZV5v 2Ix4+eA0VqtSNP4iJ0SXlXNmIeTZyClvGctPTqc8jdoOm/zFucM143xl84eXmgs6lAs0 zlBg== X-Gm-Message-State: ALoCoQncvQN3+tXMn3JpnK2V2Xco7pkvSjTatdDevXsopMpx0IMMwExBBmByq/hsEG50dv2nAqOG X-Received: by 10.66.156.229 with SMTP id wh5mr34892pab.119.1420590569953; Tue, 06 Jan 2015 16:29:29 -0800 (PST) Received: from localhost.localdomain ([50.242.95.105]) by mx.google.com with ESMTPSA id wi15sm53763pac.21.2015.01.06.16.29.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jan 2015 16:29:29 -0800 (PST) From: Tom Haynes X-Google-Original-From: Tom Haynes To: Trond Myklebust Cc: Linux NFS Mailing list Subject: [PATCH v3 18/49] nfs: set hostname when creating nfsv3 ds connection Date: Tue, 6 Jan 2015 16:28:23 -0800 Message-Id: <1420590534-84063-19-git-send-email-loghyr@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1420590534-84063-1-git-send-email-loghyr@primarydata.com> References: <1420590534-84063-1-git-send-email-loghyr@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peng Tao lockd assumes hostname exists otherwise kernel oops. It can be reproduced by following steps: 1. mount flexfile MDS 2. write some files 3. mount DS via nfsv3 BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] strlen+0x2/0x20 PGD 0 Oops: 0000 [#1] SMP Modules linked in: nfsd(F) nfs_layout_flexfiles(F) rpcsec_gss_krb5(F) auth_rpcgss(F) nfsv4(F) dns_resolver(F) nfsv3(F) nfs_acl(F) nfs(F) lockd(F) sunrpc(F) fscache(F) ebtable_nat(F) nf_conntrack_netbios_ns(F) nf_conntrack_broadcast(F) ipt_MASQUERADE(F) ip6table_nat(F) nf_nat_ipv6(F) ip6table_mangle(F) ip6t_REJECT(F) nf_conntrack_ipv6(F) nf_defrag_ipv6(F) iptable_nat(F) nf_nat_ipv4(F) nf_nat(F) iptable_mangle(F) nf_conntrack_ipv4(F) nf_defrag_ipv4(F) xt_conntrack(F) nf_conntrack(F) ebtable_filter(F) ebtables(F) ip6table_filter(F) ip6_tables(F) bnep(F) snd_ens1371(F) snd_rawmidi(F) snd_ac97_codec(F) btusb(F) ac97_bus(F) snd_seq(F) snd_seq_device(F) snd_pcm(F) ppdev(F) bluetooth(F) 6lowpan_iphc(F) rfkill(F) vmw_balloon(F) snd_timer(F) snd(F) soundcore(F) gameport(F) i2c_piix4(F) e1000(F) vmw_vmci(F) parport_pc(F) parport(F) shpchp(F) uinput(F) xfs(F) libcrc32c(F) vmwgfx(F) ttm(F) drm(F) mptspi(F) scsi_transport_spi(F) mptscsih(F) mptbase(F) i2c_core(F) CPU: 0 PID: 10397 Comm: mount.nfs Tainted: GF 3.14.7-100.pd_client.001.fc16.x86_64 #1 Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013 task: ffff880008942600 ti: ffff880007990000 task.ti: ffff880007990000 RIP: 0010:[] [] strlen+0x2/0x20 RSP: 0018:ffff880007991aa0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff880038d39c20 RCX: 0000000000000004 RDX: 0000000000000006 RSI: 0000000000000010 RDI: 0000000000000000 RBP: ffff880007991b38 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000014600 R11: 0000000000000400 R12: ffffffff81cc8580 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000004 FS: 00007f90cd2ef880(0000) GS:ffff88003f600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000001710000 CR4: 00000000001407f0 Stack: ffffffffa045f52c ffff880001782230 ffff880004141e28 0006880007991ac8 ffffffff816dc14b ffff880000000000 ffff880038d39c20 0000000000000010 0000000481cc0006 0000000000000000 ffffffffa0410be8 000000000000c014 Call Trace: [] ? nlmclnt_lookup_host+0x4c/0x2c0 [lockd] [] ? _raw_spin_unlock_bh+0x1b/0x20 [] ? svc_destroy+0xb8/0x140 [sunrpc] [] nlmclnt_init+0x53/0xc0 [lockd] [] ? nfs_get_client+0x1cc/0x340 [nfs] [] nfs_start_lockd+0xa7/0xd0 [nfs] [] nfs_create_server+0x181/0x5c0 [nfs] [] nfs3_create_server+0x13/0x30 [nfsv3] [] nfs_try_mount+0x21c/0x300 [nfs] [] ? __kmalloc_track_caller+0x1ad/0x240 [] ? nfs_fs_mount+0xc37/0xd80 [nfs] [] nfs_fs_mount+0x2c5/0xd80 [nfs] [] ? nfs_clone_super+0x140/0x140 [nfs] [] ? nfs_clone_sb_security+0x40/0x40 [nfs] [] mount_fs+0x43/0x1b0 [] ? __alloc_percpu+0x10/0x20 [] vfs_kern_mount+0x76/0x120 [] do_mount+0x237/0xa80 Signed-off-by: Peng Tao Signed-off-by: Trond Myklebust --- fs/nfs/nfs3client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c index 52e2344..9e9fa34 100644 --- a/fs/nfs/nfs3client.c +++ b/fs/nfs/nfs3client.c @@ -1,5 +1,6 @@ #include #include +#include #include "internal.h" #include "nfs3_fs.h" @@ -89,6 +90,12 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_client *mds_clp, }; struct rpc_timeout ds_timeout; struct nfs_client *clp; + char buf[INET6_ADDRSTRLEN + 1]; + + /* fake a hostname because lockd wants it */ + if (rpc_ntop(ds_addr, buf, sizeof(buf)) <= 0) + return ERR_PTR(-EINVAL); + cl_init.hostname = buf; /* Use the MDS nfs_client cl_ipaddr. */ nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);