1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

Fix v_cache_dd handling for negative entries. v_cache_dd pointer was

not populated in parent directory if negative entry was being
created, yet entry itself was added to the nc_neg list. It was
possible for parent vnode to get discarded later, leaving negative
entry pointing to now unused memory block.

Reported by:	dho
Revewed by:	kib
This commit is contained in:
Alexander Kabaev 2009-04-11 20:23:08 +00:00
parent efbbe93e56
commit 9d75482f99
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190945

View File

@ -678,15 +678,20 @@ cache_enter(dvp, vp, cnp)
}
}
if (flag == NCF_ISDOTDOT) {
/*
* See if we are trying to add .. entry, but some other lookup
* has populated v_cache_dd pointer already.
*/
if (flag == NCF_ISDOTDOT && dvp->v_cache_dd != NULL) {
if (dvp->v_cache_dd != NULL) {
CACHE_WUNLOCK();
cache_free(ncp);
return;
}
KASSERT(vp == NULL || vp->v_type == VDIR,
("wrong vnode type %p", vp));
dvp->v_cache_dd = ncp;
}
numcache++;
if (!vp) {
@ -694,11 +699,7 @@ cache_enter(dvp, vp, cnp)
if (cnp->cn_flags & ISWHITEOUT)
ncp->nc_flag |= NCF_WHITE;
} else if (vp->v_type == VDIR) {
if (flag == NCF_ISDOTDOT) {
KASSERT(dvp->v_cache_dd == NULL,
("dangling v_cache_dd"));
dvp->v_cache_dd = ncp;
} else {
if (flag != NCF_ISDOTDOT) {
if ((n2 = vp->v_cache_dd) != NULL &&
(n2->nc_flag & NCF_ISDOTDOT) != 0)
cache_zap(n2);