From 8234cc254406173a7ada9fb1b4a63ca8aa626bca Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 24 Mar 2011 10:22:52 -0500 Subject: [PATCH] DAFS: Correct FSYNC_VOL_QUERY_VOP checks Check that the given partition matches the vp partition, and ensure the vp is not in an exclusive state when we check the state. Otherwise, we may return pending vol ops for a volume on a different partition, or we may incorrectly return that there is no pending vol op when in fact the volume does not exist at all. Change-Id: I3e28c0b7b372360d181a3310eb1fb7fce223ae59 Reviewed-on: http://gerrit.openafs.org/4308 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/fssync-server.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index a5786b77b..839dd2c4d 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -1552,10 +1552,20 @@ FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res) vp = VLookupVolume_r(&error, vcom->vop->volume, NULL); + if (vp) { + VCreateReservation_r(vp); + VWaitExclusiveState_r(vp); + } + if (vp && vp->pending_vol_op) { - osi_Assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len); - memcpy(res->payload.buf, vp->pending_vol_op, sizeof(FSSYNC_VolOp_info)); - res->hdr.response_len += sizeof(FSSYNC_VolOp_info); + if (!FSYNC_partMatch(vcom, vp, 1)) { + res->hdr.reason = FSYNC_WRONG_PART; + code = SYNC_FAILED; + } else { + osi_Assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len); + memcpy(res->payload.buf, vp->pending_vol_op, sizeof(FSSYNC_VolOp_info)); + res->hdr.response_len += sizeof(FSSYNC_VolOp_info); + } } else { if (!vp || V_attachState(vp) == VOL_STATE_DELETED) { res->hdr.reason = FSYNC_UNKNOWN_VOLID; @@ -1566,6 +1576,10 @@ FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res) } code = SYNC_FAILED; } + + if (vp) { + VCancelReservation_r(vp); + } return code; } -- 2.39.5