Repository navigation
Conversation
This was referenced Oct 27, 2026
flatstik
force-pushed
the
fix-1958-key-memory
branch
from
October 28, 2026 21:22
2f9bc1b to
002cc09
Compare
SecureBuffer only erased its memory when freed. The FUSE service that holds the master keys had no locked memory and could be core dumped, and a core file of it contained both halves of the master key. Give each SecureBuffer whole pages of its own, lock them with mlock and exclude them from core dumps (MADV_DONTDUMP, or MADV_NOCORE on FreeBSD). Separate pages let a freed buffer be unlocked without affecting another one. Memory locks are not inherited by fork, so the FUSE service locks the live buffers again once FUSE has started it in the background. If RLIMIT_MEMLOCK does not allow locking, the buffers are used unlocked as before. Key material can also be copied outside SecureBuffer, so the core service and the FUSE service additionally disable core dumps: they set RLIMIT_CORE to 0 and, on Linux, clear the dumpable flag, which a core_pattern pipe does not ignore. Volume::WriteSectors encrypts each write in a buffer that is encrypted in place right after the copy. Allocating it as a SecureBuffer would lock and unlock its pages on every write and cut write throughput by about 20 to 60 percent depending on the write size, so it becomes a Buffer that is still erased when freed. Fixes veracrypt#1958
Tests/test_linux_fuse_service_memory.py checks locked memory and no core file for the FUSE service against the installed package in the Linux workflow.
flatstik
force-pushed
the
fix-1958-key-memory
branch
from
October 29, 2026 10:37
002cc09 to
49f4b39
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1958.
SecureBufferallocations get whole pages of their own, locked withmlockand excluded from core dumps (MADV_DONTDUMP,MADV_NOCOREon FreeBSD). Separate pages let a freed buffer be unlocked without affecting another one. Memory locks are not inherited byfork, so the FUSE service locks the live buffers again once FUSE has put it in the background. IfRLIMIT_MEMLOCKdoes not allow locking, the buffers are used unlocked as before.Key material can also be copied outside
SecureBuffer, so the core service and the FUSE service additionally setRLIMIT_COREto 0 and, on Linux, clear the dumpable flag, which acore_patternpipe does not ignore.Volume::WriteSectorskeeps a plainBuffer, still erased when freed: its data is encrypted in place right after the copy, and locking and unlocking its pages on every write reduced write throughput by 19 to 60 % in a benchmark (x86_64, AES-NI, 1 MiB to 4 KiB writes).Tested:
Tests/test_linux_fuse_service_memory.py(new, run in the Linux workflow): passes on ubuntu-24.04 and ubuntu-26.04, https://github.com/flatstik/VeraCrypt/actions/runs/40497963940.The new test adds lines next to
test_mount_helper.pyin.github/workflows/build-linux.yml, as do the other PRs split from #1963, so whichever is merged later conflicts there; I will rebase it.Split from #1963, with #1967 (#1959), #1966 (#1960), #1964 (#1961), #1965 (#1962).