Skip to content
View in the app

A better way to browse. Learn more.

Kaspersky Support Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VfsRamFs crashes (NULL dereference in inode_destructor) under concurrent stat/readdir/unlink — KasperskyOS CE 1.4.0.102

Summary

- On KasperskyOS Community Edition 1.4.0.102 (QEMU, aarch64), the prebuilt VfsRamFs takes an unhandled page fault (a NULL pointer dereference) when several threads of one client create, stat, list and unlink files in /tmp at the same time.

- The kernel then terminates VfsRamFs, so its client loses its file system [VFS_CLIENT] Connection to vfs lost. on every later call).

- A reproducer in plain C (https://github.com/caraioniurie47/kos-vfsramfs-repro) needs only the SDK. With THREADS=4 (12 worker threads) it faulted in the first round in 3 of 3 runs; with THREADS=1 (3 worker threads) both runs completed.

- The call trace points to the release of an inode: _vfs_unlinkat → dentry_free → KosPutObject → inode_destructor, which follows a NULL list node.

Reproducer: https://github.com/caraioniurie47/kos-vfsramfs-repro

One program, repro.Stress, whose file system is the SDK's prebuilt precompiled_vfs::VfsRamFs; the security policy grants everything. In each of 20 rounds it creates 3000 files in each of THREADS directories under /tmp, then per directory one thread stats 6000 names (half never exist), one lists the directory 20 times, and one unlinks the files (every 7th while holding it open). Clone it, then build and run with the SDK's CMake:

```

git clone https://github.com/caraioniurie47/kos-vfsramfs-repro.git

cd kos-vfsramfs-repro

$SDK/toolchain/bin/cmake -B build -D CMAKE_TOOLCHAIN_FILE=$SDK/toolchain/share/toolchain-aarch64-kos.cmake -D THREADS=4

$SDK/toolchain/bin/cmake --build build --target sim

```

THREADS (1-4) is the number of directories stressed at once; each adds three threads (stat, readdir, unlink). The program prints [stress] round N: ... as it goes and [stress] DONE at the end.

Fault report (first THREADS=4 run; some header lines, registers and stack words trimmed):

```

[stress] 4 directories, 3000 files, 12 threads during stat/readdir/unlink

[stress] round 1: create

[stress] round 1: stat + readdir + unlink

[VMM ] Unhandled Page Fault, address: 0x88

Exception class: Data Abort from a lower Exception level

Access type: read

Fault type: L3 Translation fault

EIID : kl.VfsRamFs

Path : VfsRamFs

TID : 30

pc : 0xd2a74

sp: 0x000000000192ac40, lr: 0x00000000000d290c, pc: 0x00000000000d2a74

Relocation base: <0x0000000000010000>

Call Trace (User Mode):

[<0x00000000000d2a74>] ???

[<0x00000000000d2e74>] ???

[<0x00000000000df790>] ???

[<0x00000000000f9094>] ???

[<0x00000000000f902c>] ???

[<0x00000000000cf598>] ???

[<0x00000000000d7bb0>] ???

[<0x0000000000093ba8>] ???

[<0x00000000000af9c8>] ???

[<0x00000000000ae55c>] ???

[<0x00000000001b31e4>] ???

Terminating task.

Terminating thread.

[2026-09-23T21:40:38.060][Error][repro.Stress][16:34][VFS_CLIENT] Connection to vfs lost.

```

Call trace, named. The shipped sysroot-aarch64-kos/bin/VfsRamFs is stripped, so I named the frames by matching the instructions before each return address against the SDK's static libraries, which keep their symbols. Addresses are as the fault report prints them (the relocation base is 0x10000); where a sequence occurs in more than one function, all candidates are listed:

| Address | Function (library) |

|---|---|

| 0xd2a18 … 0xd2ae0 (fault) | inode_destructor (libvfs_fs, libvfs_imp; same instructions as dentry_lru_get) |

| 0xd2e74 | inside inode_new (libvfs_fs) |

| 0xdf790 | near vfs_object_allocator_init (libvfs_local_common): an object's release callback |

| 0xf9094, 0xf902c | KosPutObject (libkos) |

| 0xcf598 | dentry_free (or _vfs_getdents_filldir, dentry_read_root) (libvfs_fs) |

| 0xd7bb0 | _vfs_unlinkat (libvfs_fs) |

| 0x93ba8, 0xaf9c8 | request dispatch (libvfs_server) |

The faulting loop walks a list linked at offset 0x80 of each node and reads offsets 0x70 and 0x88; the fault addresses were 0x70 and 0x88, so a node pointer in that list was NULL. The faulting pc varied between runs 0xd2a18, 0xd2a24, 0xd2a74, 0xd2ae0), always inside the same function. In one run the destructor was reached from a different caller 0xdf508, near vfs_notice_init in libvfs_local_common) instead of _vfs_unlinkat. It looks like a race on the inode or dentry lists when the last reference to an inode is dropped, but I can only see it from outside.

Simpler cases did not fault: unlink or rmdir of an open, empty or non-empty directory from one thread, and four threads doing mkdir/open/unlink/close 300 times each. In one run of an earlier version of the stress program (1500 files per directory), there was no fault report; instead the program made no progress for 600 seconds.

Thread limit. The SDK 1.4 page "Limitations and known issues" (https://support.kaspersky.com/kos-community-edition/1.4/limitations_and_known_problems) states: "The libc library API supported by VFS has a limit of 30 VFS clients and 5 threads per client." With THREADS=1 the process has 4 threads, within that limit, and both runs completed all 20 rounds; I have not seen the fault within the limit. With THREADS=4 it has 13. Even so, a client over the limit takes the file system server down rather than getting an error.

Context

Found while running the .NET runtime's System.IO.FileSystem test suite on a KasperskyOS port of .NET (NativeAOT; latest release: https://github.com/caraioniurie47/runtime-kos/releases/tag/release_v03): one of six full runs lost its file system when VfsRamFs faulted with the call trace above. The .NET runtime starts threads of its own (a finalizer thread, and thread pool threads on demand), so a managed app does not control how many of its threads call into VFS, and a limit of 5 threads per VFS client is hard for it to stay within; if a client goes over it, an error would be much easier to handle than a server fault.

Is this a known issue, and is there a workaround until a fix, for example a VfsRamFs setting or a way to serialize requests on the client side?

Thanks!

Solved by HQCS

Featured Replies

Hello!

Upon your request, INC000018614209 has been registered with the technical support service. We will provide a response as soon as possible.

BR

Raised issue to the RnD team. Please wait for their responce.

BR

  • Solution

Hello!

Thank you for finding the bug!

As a workaround you can make the VfsRamFs server single‑threaded by limiting the number of threads through the environment variables VFS_SERVER_MAX_THREADS_PER_CLIENT and VFS_SERVER_MAX_THREADS_PER_PROCESS.

Applied as a patch to the shown repository, it would look like this:

```diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b40e31..6c7e749 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,11 @@ target_link_libraries (Stress vfs::client)
# vfs::client would add the SDK's default VFS program; VfsRamFs serves Stress instead (init.yaml.in).
set_target_properties (Stress PROPERTIES vfs::entity_REPLACEMENT "")
+set_target_properties (precompiled_vfs::VfsRamFs PROPERTIES EXTRA_ENV
+ "VFS_SERVER_MAX_THREADS_PER_CLIENT: 1
+ VFS_SERVER_MAX_THREADS_PER_PROCESS: 1
+ VFS_FILESYSTEM_BACKEND: server:kl.VfsRamFs")
+
build_kos_qemu_image (kos-qemu-image
EINIT_ENTITY EinitQemu
CONNECTIONS_CFG "einit/init.yaml.in"
```

In the next release of the KasperskyOS Community Edition SDK, this issue will be resolved.
Thanks!

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.