Fix small shared file extend-write potentially reading unallocated memory

This commit is contained in:
Vitaliy Filippov
2026-06-17 12:36:04 +03:00
parent 3becdbf5b9
commit 938ac09248
2 changed files with 33 additions and 2 deletions
+10
View File
@@ -17,6 +17,7 @@ trap "sudo umount -f $MNT"' || true; kill -9 $(jobs -p)' EXIT
chown 1000:1000 ./testdata/nfs
# check readability by root
touch ./testdata/nfs/f1
chown 1000:1000 ./testdata/nfs/f1
chmod 600 ./testdata/nfs/f1
@@ -195,4 +196,13 @@ sudo rm ./testdata/nfs/settings.jsonLGNmGn
build/src/kv/vitastor-kv --config_path $VITASTOR_CFG fsmeta get d11/settings.jsonLGNmGn 2>&1 | grep '(code -2)'
ls -l ./testdata/nfs
# check small shared file extend-write (it was reading unallocated memory but it's hard to actually make it differ from 0)
dd if=/dev/urandom of=./testdata/shared_beyond_ref bs=7k count=1
dd if=/dev/urandom of=./testdata/shared_beyond_ref seek=8 bs=1k count=1 conv=notrunc
dd if=./testdata/shared_beyond_ref of=./testdata/nfs/shared_beyond_end bs=7k count=1
dd if=./testdata/shared_beyond_ref of=./testdata/nfs/shared_beyond_end skip=8 seek=8 bs=1k count=1 conv=notrunc
cp ./testdata/nfs/shared_beyond_end ./testdata/
diff ./testdata/shared_beyond_end ./testdata/shared_beyond_ref
rm ./testdata/nfs/shared_beyond_end
format_green OK