From f69aaf6914096077108b534aff8fd147cd6a65ae Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 13 Dec 2012 16:36:20 -0600 Subject: [PATCH] LINUX: Avoid infinite d_invalidate loop If a reference is grabbed after we d_invalidate() a dentry, but before we dput() that dentry, the dentry can still be on the alias list for its inode. This will cause us to loop forever, since we'll get the same dentry back from d_find_alias, and d_invalidate() will return success, since it is a no-op. Avoid this by just limiting the number of times we loop. Leaving dentry aliases around is non-critical as long as we clear some each time. This change is not applicable to master, which will get a more robust fix for this issue. This change was discussed during the 19 Dec 2012 release-team meeting. Change-Id: Ief22ae9f8f6de62518604383c421772c25c5dc26 Reviewed-on: http://gerrit.openafs.org/8795 Reviewed-by: Paul Smeddle Reviewed-by: Stephan Wiesand Tested-by: BuildBot --- src/afs/LINUX/osi_vnodeops.c | 3 ++- src/afs/LINUX24/osi_vnodeops.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 1344d0ca0..1366b9637 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1294,8 +1294,9 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) if (ip && S_ISDIR(ip->i_mode)) { int retry = 1; struct dentry *alias; + int safety; - while (retry) { + for (safety = 0; retry && safety < 64; safety++) { retry = 0; /* Try to invalidate an existing alias in favor of our new one */ diff --git a/src/afs/LINUX24/osi_vnodeops.c b/src/afs/LINUX24/osi_vnodeops.c index 87f7e37aa..6c0589b76 100644 --- a/src/afs/LINUX24/osi_vnodeops.c +++ b/src/afs/LINUX24/osi_vnodeops.c @@ -1304,8 +1304,9 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) if (ip && S_ISDIR(ip->i_mode)) { int retry = 1; struct dentry *alias; + int safety; - while (retry) { + for (safety = 0; retry && safety < 64; safety++) { retry = 0; /* Try to invalidate an existing alias in favor of our new one */ -- 2.39.5