diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-07-24 15:42:22 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-07-24 15:42:22 +0000 |
commit | 5d382e85053f498754939926fd4655bad884938a (patch) | |
tree | c9288fdce0e644576af995124a584204a01b08a7 | |
parent | b55ffaf6bb3289d5275dd34729e2e4507abbb2a1 (diff) | |
download | FreeBSD-src-5d382e85053f498754939926fd4655bad884938a.zip FreeBSD-src-5d382e85053f498754939926fd4655bad884938a.tar.gz |
Under #ifdef DIAGNOSTIC, NULL out componentname pointers if we free the
pnbuf to increase the chances of detecting use of a free'd name buffer
if SAVENAME or SAVESTART wasn't passed in. Curiously, running with these
changes doesn't panic the kernel, and should.
-rw-r--r-- | sys/kern/vfs_lookup.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 8e4af42..9c24f52 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -134,6 +134,10 @@ namei(ndp) if (error) { uma_zfree(namei_zone, cnp->cn_pnbuf); +#ifdef DIAGNOSTIC + cnp->cn_pnbuf = NULL; + cnp->cn_nameptr = NULL; +#endif ndp->ni_vp = NULL; return (error); } @@ -175,15 +179,23 @@ namei(ndp) error = lookup(ndp); if (error) { uma_zfree(namei_zone, cnp->cn_pnbuf); +#ifdef DIAGNOSTIC + cnp->cn_pnbuf = NULL; + cnp->cn_nameptr = NULL; +#endif return (error); } /* * Check for symbolic link */ if ((cnp->cn_flags & ISSYMLINK) == 0) { - if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) + if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) { uma_zfree(namei_zone, cnp->cn_pnbuf); - else +#ifdef DIAGNOSTIC + cnp->cn_pnbuf = NULL; + cnp->cn_nameptr = NULL; +#endif + } else cnp->cn_flags |= HASBUF; if (vn_canvmio(ndp->ni_vp) == TRUE && @@ -244,6 +256,10 @@ namei(ndp) dp = ndp->ni_dvp; } uma_zfree(namei_zone, cnp->cn_pnbuf); +#ifdef DIAGNOSTIC + cnp->cn_pnbuf = NULL; + cnp->cn_nameptr = NULL; +#endif vrele(ndp->ni_dvp); vput(ndp->ni_vp); ndp->ni_vp = NULL; |