[PATCH 1/1] cr: fix use of __d_path()

From: Serge Hallyn
Date: Tue Nov 04 2008 - 16:28:01 EST


__d_path():
1. should be used under dcache_lock
2. can change root->{mnt,dentry} without changing refcounts
The second point was the cause of my BUGs. The ctx->root was passed
in, and do_checkpoint() had taken a path_get on the vfsroot. So now
at cleanup it was doing path_put() using another mnt+dentry.

(Why they are different, I'm not sure - but my guess would be that
stdin or stdout is inherited from the parent task in parent mntns,
hence file->mnt is different from root->mnt as it's a different
namespace.)

Signed-off-by: Serge Hallyn <serue@xxxxxxxxxx>
---
checkpoint/checkpoint.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
index 173b637..7f0c1e7 100644
--- a/checkpoint/checkpoint.c
+++ b/checkpoint/checkpoint.c
@@ -70,9 +70,20 @@ static char *
cr_fill_fname(struct path *path, struct path *root, char *buf, int *n)
{
char *fname;
+ struct path root2;
+
+ root2.mnt = root->mnt;
+ root2.dentry = root->dentry;

BUG_ON(!buf);
- fname = __d_path(path, root, buf, *n);
+ spin_lock(&dcache_lock);
+ fname = __d_path(path, &root2, buf, *n);
+ spin_unlock(&dcache_lock);
+ if (root2.mnt != root->mnt)
+ printk(KERN_NOTICE "%s: mnt changed\n", __func__);
+ if (root2.dentry != root->dentry)
+ printk(KERN_NOTICE "%s: dentry changed\n", __func__);
+ fname = buf+10;
if (!IS_ERR(fname))
*n = (buf + (*n) - fname);
return fname;
--
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/