Repository navigation
Conversation
v9fs_client_unlink() clunked the fid of the directory after Tunlinkat, and v9fs_vfs_unlink() and v9fs_vfs_rmdir() then released the same fid again with v9fs_fid_put(). After the clunk the fid number is free, and another thread can get it for a new walk at once. The second release then dropped the reference of that thread: its fid was clunked and freed while the thread still used it. v9fs_client_open() and v9fs_client_create() then wrote the iounit into the freed memory, which broke the free list of the kernel heap (a fault in mm_malloc() or mm_free() at address 0x10018), and later requests used a fid that the server did not know any more. Three threads that create and remove files in one directory on 4 CPUs did this within seconds. Tunlinkat does not change the directory fid. v9fs_client_unlink() now only sends the request, and the callers release the fid, as they do after the other requests. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
xiaoxiang781216
approved these changes
Nov 19, 2026
|
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.
Summary
v9fs_client_unlink()clunks the fid of the directory afterTunlinkat, and its callersv9fs_vfs_unlink()andv9fs_vfs_rmdir()then release the same fid again withv9fs_fid_put().After the clunk the fid number is free, and another thread of the mount can get it at once for a new walk. The second release then finds the fid of that thread: it drops its reference, clunks it and frees it while the thread still uses it.
v9fs_client_open()andv9fs_client_create()then write the iounit into the freed memory. That breaks the free list of the kernel heap, and the nextmalloc()orfree()faults at address 0x10018 (the iounit is 0x10000). Later requests of that thread use a fid that the server does not know any more. With only one thread, the second release finds no fid and does nothing, so this happens only when threads use the mount at the same time; on SMP it happens within seconds.Tunlinkatdoes not change the directory fid. This PR makesv9fs_client_unlink()only send the request. Its callers release the fid, as they do after the other requests.Impact
fs/v9fsonly, one function. No API, ABI or Kconfig change. The same in flat, protected and kernel builds, on every architecture and transport.Testing
qemu-armv8a:knsh under HVF (Apple M-series),
CONFIG_MM_FILL_ALLOCATIONS=y, the root file system on virtio-9p. A test program starts 3 threads that each open (O_CREAT), write, close and unlink files in one directory of the 9p mount, for 30 s; then the same for 30 s in rounds where a child process does it for up to 100 ms and joins its threads.CONFIG_SMP)mm_malloc()fromv9fs_vfs_open()v9fs_client_create()uses is freed during its request, byv9fs_vfs_unlink()of another thread, afterv9fs_client_unlink()of that thread had clunked its own fid with the same numberWith this PR,
mkdir,rmandrmdiron the 9p mount work as before, and the kernel heap does not grow over the runs (a fid that is not released would stay in the heap).tools/checkpatch.sh -c -u -m -gpasses. Documentation: no change.