From: Benjamin Kaduk Date: Mon, 7 Nov 2016 05:29:22 +0000 (-0600) Subject: afs: do not leak stale data in buffers X-Git-Tag: upstream/1.6.20^2~1 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=27515016cf92d0456b2a6e8a90758a02729f7407;p=packages%2Fo%2Fopenafs.git afs: do not leak stale data in buffers Similar to the previous commit, zero out the buffer when fetching a new slot, to avoid the possibility of leaving stale data in a reused buffer. We are not supposed to write such stale data back to a fileserver, but this is an extra precaution in case of bugs elsewhere -- memset is not as expensive as it was in the 1980s. Reviewed-on: https://gerrit.openafs.org/12459 Reviewed-by: Mark Vitale Tested-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk (cherry picked from commit a26c5054ee501ec65db3104f6a6a0fef634d9ea7) Change-Id: Id60559ed84581e2f6a50cd4313f64780b8a0bafd Reviewed-on: https://gerrit.openafs.org/12464 Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Tested-by: Mark Vitale Reviewed-by: Stephan Wiesand --- diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c index 7d856c2d2..83a30fc68 100644 --- a/src/afs/afs_buffer.c +++ b/src/afs/afs_buffer.c @@ -368,6 +368,8 @@ afs_newslot(struct dcache *adc, afs_int32 apage, struct buffer *lp) AFS_STATS(afs_stats_cmperf.bufFlushDirty++); } + /* Zero out the data so we don't leak something we shouldn't. */ + memset(lp->data, 0, AFS_BUFFER_PAGESIZE); /* Now fill in the header. */ lp->fid = adc->index; afs_copy_inode(&lp->inode, &adc->f.inode);