mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 07:20:11 +00:00
3caee75754
Currently, afs_GetDCache contains a couple of calculations that look similar to this: if (position + size > file_length) { size = file_length - position; } if (size < 0) { size = 0; } Most of the time, this is fine. However, if 'position' is more than 2GiB greater than file_length, 'size' will calculated to be smaller than -2GiB. Since 'size' in this code is a signed 32-bit integer, this can cause 'size' to underflow, and result in a value closer to (positive) 2GiB. This has two potential effects: The afs_AdjustSize call in afs_GetDCache will cause the underlying cache file for this dcache to be very large (if our offset is around 2GiB larger than the file size). This can confuse other parts of the client, since our cache usage reporting will be incorrect (and can be even way larger than the max configured cache size). This will also cause a read request to the fileserver that is larger than necessary. Although 'size' will be capped at our chunksize, it should be 0 in this situation, since we know there is no data to fetch. At worst, this currently can just result in worse performance in rare situations, but it can also just be very confusing. Note that an afs_GetDCache request beyond EOF can currently happen in non-race conditions on at least Solaris when performing a file write. For example, with a chunksize of 256KiB, something like this will trigger the overflow in 'size' in most cases: $ printf '' > smallfile && printf b | dd of=smallfile bs=1 oseek=2147745793 But there are probably other similar scenarios. To fix this, just check if our offset is beyond the relevant file size, and do not depend on 'size' having sane values in edge cases such as this. Change-Id: Ie36f66ce11fbee905062b3a787871ec077c15354 Reviewed-on: http://gerrit.openafs.org/11828 Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Chas Williams <3chas3@gmail.com> |
||
---|---|---|
build-tools | ||
doc | ||
src | ||
tests | ||
.gitignore | ||
.splintrc | ||
acinclude.m4 | ||
CODING | ||
configure-libafs.ac | ||
configure.ac | ||
CONTRIBUTING | ||
INSTALL | ||
libafsdep | ||
LICENSE | ||
Makefile-libafs.in | ||
Makefile.in | ||
NEWS | ||
NTMakefile | ||
README | ||
README-WINDOWS | ||
regen.sh |
AFS is a distributed file system that enables users to share and access all of the files stored in a network of computers as easily as they access the files stored on their local machines. The file system is called distributed for this exact reason: files can reside on many different machines, but are available to users on every machine. OpenAFS 1.0 was originally released by IBM under the terms of the IBM Public License 1.0 (IPL10). For details on IPL10 see the LICENSE file in this directory. The current OpenAFS distribution is licensed under a combination of the IPL10 and many other licenses as granted by the relevant copyright holders. The LICENSE file in this directory contains more details, thought it is not a comprehensive statement. See INSTALL for information about building and installing OpenAFS on various platforms. See CODING for developer information and guidelines. See NEWS for recent changes to OpenAFS.