From cddec1584fa1019e89311aae3f293b372937bfa0 Mon Sep 17 00:00:00 2001 From: Jeff Riegel Date: Tue, 5 Jun 2001 15:16:10 +0000 Subject: [PATCH] cachemgr-dont-leak-stat-info-to-clients-not-entitled-to-it-20010605 if you only have lookup don't leak stat information from cache, which normally requires read --- src/afs/VNOPS/afs_vnop_create.c | 3 +++ src/afs/VNOPS/afs_vnop_lookup.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index b8deaf2..0d42f57 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -177,6 +177,9 @@ tagain: if ((amode & VWRITE) || len != 0xffffffff) #endif { + /* needed for write access check */ + tvc->parentVnode = adp->fid.Fid.Vnode; + tvc->parentUnique = adp->fid.Fid.Unique; /* need write mode for these guys */ if (!afs_AccessOK(tvc, PRSFS_WRITE, &treq, CHECK_MODE_BITS)) { afs_PutVCache(tvc, READ_LOCK); diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 7df8f04..289c15b 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -883,6 +883,7 @@ afs_lookup(adp, aname, avcp, acred) extern afs_int32 afs_mariner; /*Writing activity to log?*/ OSI_VC_CONVERT(adp) afs_hyper_t versionNo; + int no_read_access = 0; AFS_STATCNT(afs_lookup); #ifdef AFS_OSF_ENV @@ -990,6 +991,10 @@ afs_lookup(adp, aname, avcp, acred) else adp->last_looker = treq.uid; } + /* Check for read access as well. We need read access in order to + stat files, but not to stat subdirectories. */ + if (!afs_AccessOK(adp, PRSFS_READ, &treq, CHECK_MODE_BITS)) + no_read_access = 1; /* special case lookup of ".". Can we check for it sooner in this code, * for instance, way up before "redo:" ?? @@ -1011,25 +1016,30 @@ afs_lookup(adp, aname, avcp, acred) tvc = osi_dnlc_lookup (adp, tname, WRITE_LOCK); *avcp = tvc; /* maybe wasn't initialized, but it is now */ -#ifdef AFS_LINUX22_ENV if (tvc) { - if (tvc->mvstat == 2) { /* we don't trust the dnlc for root vcaches */ - AFS_RELE(tvc); - *avcp = 0; - } - else { + if (no_read_access && vType(tvc) != VDIR) { + /* need read access on dir to stat non-directory */ + afs_PutVCache(tvc, WRITE_LOCK); + *avcp = (struct vcache *)0; + code = EACCES; + goto done; + } +#ifdef AFS_LINUX22_ENV + if (tvc->mvstat == 2) { /* we don't trust the dnlc for root vcaches */ + AFS_RELE(tvc); + *avcp = 0; + } + else { + code = 0; + hit = 1; + goto done; + } +#else /* non - LINUX */ code = 0; hit = 1; goto done; - } - } -#else /* non - LINUX */ - if (tvc) { - code = 0; - hit = 1; - goto done; - } #endif /* linux22 */ + } { register struct dcache *tdc; -- 1.9.4