Status: Prototype on-hold
Documentation: Documentation/ktsan.txt (somewhat outdated)
Found bugs: here
Contacts: Dmitry Vyukov <@dvyukov>, Andrey Konovalov <@xairy>
Kernel Thread Sanitizer (KTSAN) is a happens-before dynamic data-race detector for the Linux kernel.
KTSAN adapts the data-race detection algorithm of the userspace ThreadSanitizer (version 2; don't confuse with version 1) to the Linux kernel.
Due to a significant complexity of the bug-detection algorithm when adapted to the Linux kernel and large CPU and RAM overheads, the project was put on-hold.
See Kernel Concurrency Sanitizer (KCSAN) for an alternative approach that uses watchpoints.
The latest KTSAN version based on 5.3 can be found in the ktsan branch. The original prototype based on 4.2 can be found under the tag ktsan_v4.2-with-fixes (also includes fixes for found data-races).
For more details about KTSAN, see:
KernelThreadSanitizer (KTSAN): a data race detector for the Linux kernel
Автоматический поиск состояний гонок в ядре ОС Linux [in Russian]
See this for unresolved issues in KTSAN.
Make some internal structures per CPU instead of per thread (VC cache, what else?). VCs themselves stay per thread.
Monitor some kernel thread scheduler events (thread execution started/stopped on CPU).
Disable interrupts during TSAN events (kernel scheduler events, synchronization events) (CLI, STI).
Use 4 bytes per slot: 1 for thread id, 2 for clock, 1 for everything else (flags, ...).
Different threads might have the same thread id (only 256 different values available).
When clock overflows it is possible to change thread id and connect "old" and "new" threads with a happens-before relation.
Find races in both kmalloc and vmalloc ranges.
Use two-level shadow memory mapping scheme for now.
Do a flush when we run out of clocks. The flush might work as follows. There is a global epoch variable which is increased during each flush. Each thread have a local epoch variable. When a thread is starting it will flush itself if the thread local epoch is less than the global one.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。