From patchwork Wed May 11 21:03:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Huang X-Patchwork-Id: 778222 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4BL4K4V028974 for ; Wed, 11 May 2011 21:04:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755412Ab1EKVET (ORCPT ); Wed, 11 May 2011 17:04:19 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:46165 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755301Ab1EKVES (ORCPT ); Wed, 11 May 2011 17:04:18 -0400 Received: by gxk21 with SMTP id 21so312973gxk.19 for ; Wed, 11 May 2011 14:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=nr7tnUCon5HobXOi8KRqkpgm1a9q0SNOfZU6hIuDksk=; b=JwRT7Agl4B/c15sKjGEjtFM/h182ZBQH4Jjl1mYlg+OJKYQaZ/M8clpCfYA6d0cyuD EBb6/tgiCPP9+SXSjncEQxg+RbZ+HDTt+spekVpULxcwcTU9Ue9Zp6J8jyh7RmeFdNwR y5hvEE4PoXTfeTXDc6Ho9rPBwDHOwTpW5YjdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=dw/dNcd/0JiUafkfukKHgXMY6Ojwng8f6lA/AriUimHgDkU/+20BxNPgBD680L6HrN ckLPzHeWBRxdop+jKSSit/OdJS/bWE+c2cQBUhv8QWl7+QP9R5Zoi6614PDZgdaQ2i+g sjrM4tFlatuU1tG8XQoytAwNzg25rLQ0X1N2A= Received: by 10.236.190.98 with SMTP id d62mr11043148yhn.74.1305147857429; Wed, 11 May 2011 14:04:17 -0700 (PDT) Received: from penghuang.wat.corp.google.com (penghuang.wat.corp.google.com [172.23.176.2]) by mx.google.com with ESMTPS id u29sm271269yhn.69.2011.05.11.14.04.15 (version=SSLv3 cipher=OTHER); Wed, 11 May 2011 14:04:16 -0700 (PDT) From: Peng Huang To: Trond Myklebust , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Peng Huang Subject: [PATCH] nfs: check a crash in nfs_lookup_revalidate Date: Wed, 11 May 2011 17:03:25 -0400 Message-Id: <1305147805-5756-1-git-send-email-shawn.p.huang@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 11 May 2011 21:04:20 +0000 (UTC) lookup_one_len() may call nfs_loopup_revalidate() with nd == NULL indirectly, that causes the kernel crash. RIP: 0010:[] [] nfs_lookup_revalidate+0x21/0x4a0 [nfs] RSP: 0018:ffff88018f00fae8 EFLAGS: 00010286 Call Trace: [] do_revalidate+0x17/0x60 [] __lookup_hash+0xcb/0x140 [] lookup_one_len+0x94/0xe0 [] ecryptfs_lookup+0x91/0x1d0 [] d_alloc_and_lookup+0x45/0x90 [] ? d_lookup+0x35/0x60 [] do_lookup+0x192/0x2d0 [] ? vfsmount_lock_local_unlock+0x1e/0x30 [] ? security_inode_permission+0x1c/0x30 [] link_path_walk+0x597/0xae0 [] ? vfsmount_lock_local_lock+0x1e/0x30 [] ? path_init_rcu+0xa5/0x210 [] do_path_lookup+0x5b/0x140 [] user_path_at+0x57/0xa0 [] ? do_page_fault+0x1e8/0x4e0 [] vfs_fstatat+0x46/0x80 [] ? filldir+0x0/0xe0 [] vfs_lstat+0x1e/0x20 [] sys_newlstat+0x24/0x50 [] ? page_fault+0x25/0x30 [] system_call_fastpath+0x16/0x1b Signed-off-by: Peng Huang --- fs/nfs/dir.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 2c3eb33..9452aa5 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1028,7 +1028,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) struct nfs_fattr *fattr = NULL; int error; - if (nd->flags & LOOKUP_RCU) + if (nd != NULL && nd->flags & LOOKUP_RCU) return -ECHILD; parent = dget_parent(dentry);