Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 261

kernel-2.6.18-238.el5.src.rpm

From: Ian Kent <ikent@redhat.com>
Date: Tue, 12 Aug 2008 12:25:02 +0800
Subject: [autofs4] check for invalid dentry in getpath
Message-id: 20080812042500.15842.64392.stgit@web.messagingengine.com
O-Subject: [RHEL 5.3 PATCH 01/20] autofs4 - check for invalid dentry in getpath [Related: bz452139]
Bugzilla: 452139

This patch is an upstream bug fix and shoud be associated with
bug 452139.

Catch invalid dentry when calculating its path.

When autofs4_getpath() is called without the BKL (as it is when called
via ->unlocked_ioctl) it is possible to encounter a dentry that is in
the process of being freed which has a zero length name.

diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 1e4a539..78c62b6 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -167,7 +167,7 @@ static int autofs4_getpath(struct autofs_sb_info *sbi,
 	for (tmp = dentry ; tmp != root ; tmp = tmp->d_parent)
 		len += tmp->d_name.len + 1;
 
-	if (--len > NAME_MAX) {
+	if (!len || --len > NAME_MAX) {
 		spin_unlock(&dcache_lock);
 		return 0;
 	}