From e2f29a79a7c6e385bac8cace970a5d0053b17edb Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 14 Dec 2012 15:05:53 -0600 Subject: [PATCH] volser: Check vnode length on dump Commit aadf69eabb1962496fa93745ab560a5b48cacd61 adds length checks on vnodes during fileserver read/write operations. Do the same thing when we dump volume data from the volserver, to ensure that we don't transmit incorrect data e.g. to other RO sites when releasing. FIXES 131530 Reviewed-on: http://gerrit.openafs.org/8836 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit eb938bd18d9806f3529b7a2cbccdce5340c0e39f) Change-Id: Ia49e7310f2e143d4eed965a5090e687be55864e4 Reviewed-on: http://gerrit.openafs.org/9505 Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand Tested-by: BuildBot --- src/volser/dumpstuff.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 0e1213ad9b..138949c8c1 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -1087,6 +1087,7 @@ DumpVnode(struct iod *iodp, struct VnodeDiskObject *v, int volid, VAclDiskSize(v)); } if (VNDISK_GET_INO(v)) { + afs_sfsize_t indexlen, disklen; IH_INIT(ihP, iodp->device, iodp->parentId, VNDISK_GET_INO(v)); fdP = IH_OPEN(ihP); if (fdP == NULL) { @@ -1094,6 +1095,17 @@ DumpVnode(struct iod *iodp, struct VnodeDiskObject *v, int volid, IH_RELEASE(ihP); return VOLSERREAD_DUMPERROR; } + VNDISK_GET_LEN(indexlen, v); + disklen = FDH_SIZE(fdP); + if (indexlen != disklen) { + FDH_REALLYCLOSE(fdP); + IH_RELEASE(ihP); + Log("DumpVnode: volume %lu vnode %lu has inconsistent length " + "(index %lu disk %lu); aborting dump\n", + (unsigned long)volid, (unsigned long)vnodeNumber, + (unsigned long)indexlen, (unsigned long)disklen); + return VOLSERREAD_DUMPERROR; + } code = DumpFile(iodp, vnodeNumber, fdP); FDH_CLOSE(fdP); IH_RELEASE(ihP);