This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 880b84ea61f fs/v9fs: Do not release the directory fid twice in unlink.
880b84ea61f is described below
commit 880b84ea61f9ebc8821ffbc743ee7515638dc4e1
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 19 13:28:43 2026 +0100
fs/v9fs: Do not release the directory fid twice in unlink.
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 <[email protected]>
---
fs/v9fs/client.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/fs/v9fs/client.c b/fs/v9fs/client.c
index ec375216a7c..eb693393bc8 100644
--- a/fs/v9fs/client.c
+++ b/fs/v9fs/client.c
@@ -1427,7 +1427,6 @@ int v9fs_client_unlink(FAR struct v9fs_client_s *client,
uint32_t fid,
struct iovec wiov[1];
struct iovec riov[1];
int flags = isdir ? V9FS_REMOVEDIR : 0;
- int ret;
/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4]
* size[4] Runlinkat tag[2]
@@ -1448,14 +1447,8 @@ int v9fs_client_unlink(FAR struct v9fs_client_s *client,
uint32_t fid,
riov[0].iov_base = &response;
riov[0].iov_len = V9FS_HDRSZ + V9FS_BIT32SZ;
- ret = v9fs_client_rpc(client->transport, wiov, 1, riov, 1,
- request.header.tag);
- if (ret < 0)
- {
- return ret;
- }
-
- return v9fs_client_clunk(client, fid);
+ return v9fs_client_rpc(client->transport, wiov, 1, riov, 1,
+ request.header.tag);
}
/****************************************************************************