2023-06-02 00:01:54

by Erhard Furtner

[permalink] [raw]
Subject: KCSAN reports several races at boot in timekeeping_get_ns, set_nlink, kernfs_refresh_inode, kernfs_refresh_inode (kernel 6.4-rc4, KCSAN_STRICT)

Greetings!

As there are several data races in different subsystems I am reporting here as [email protected] is listed for LKMM in MAINTAINERS. If more appropriate please add specific maintainers.

I get these races on every boot with KCSAN selected until I reach desktop, e.g:

==================================================================
BUG: KCSAN: data-race in set_nlink / set_nlink

read to 0xffff90d50fc177c0 of 4 bytes by task 716 on cpu 1:
set_nlink+0x25/0x80
kernfs_refresh_inode+0xf4/0x110
kernfs_iop_permission+0x71/0xb0
inode_permission+0x10c/0x1e0
link_path_walk+0x191/0x5b0
path_openat+0x14a/0x12b0
do_filp_open+0xdc/0x140
do_sys_openat2+0x90/0x200
do_sys_open+0x6b/0x90
__x64_sys_openat+0x58/0x80
do_syscall_64+0x62/0xa0
entry_SYSCALL_64_after_hwframe+0x4b/0xb5

write to 0xffff90d50fc177c0 of 4 bytes by task 727 on cpu 4:
set_nlink+0x5e/0x80
kernfs_refresh_inode+0xf4/0x110
kernfs_iop_permission+0x71/0xb0
inode_permission+0x10c/0x1e0
link_path_walk+0x191/0x5b0
path_lookupat+0x61/0x1d0
filename_lookup+0xf3/0x170
user_path_at_empty+0x43/0x70
do_faccessat+0x2ac/0x440
__x64_sys_faccessat+0x44/0x60
do_syscall_64+0x62/0xa0
entry_SYSCALL_64_after_hwframe+0x4b/0xb5

Reported by Kernel Concurrency Sanitizer on:
CPU: 4 PID: 727 Comm: (udev-worker) Not tainted 6.4.0-rc4-bdver2 #5
Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./970-GAMING, BIOS F2 04/06/2016
==================================================================

Some reliably happen more often than others:

$ grep KCSAN dmesg_64-rc4_bdver2
[ 0.012086] BUG: KCSAN: data-race in wq_watchdog_touch / wq_watchdog_touch
[ 8.285432] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 8.368764] BUG: KCSAN: data-race in wq_watchdog_touch / wq_watchdog_touch
[ 9.538829] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 11.867629] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 14.723475] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 16.431943] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 20.633945] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 20.908824] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 24.004984] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 25.913675] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 29.478839] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 30.315492] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 30.349322] BUG: KCSAN: data-race in kernfs_refresh_inode / kernfs_refresh_inode
[ 32.476264] BUG: KCSAN: data-race in set_nlink / set_nlink
[ 32.725498] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 33.093884] BUG: KCSAN: data-race in d_alloc_parallel / d_alloc_parallel
[ 33.632176] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 33.772667] BUG: KCSAN: data-race in generic_permission / kernfs_refresh_inode
[ 35.844855] BUG: KCSAN: data-race in kernfs_refresh_inode / kernfs_refresh_inode
[ 36.098850] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 36.490808] BUG: KCSAN: data-race in generic_fillattr / kernfs_refresh_inode
[ 36.532227] BUG: KCSAN: data-race in __hrtimer_run_queues / hrtimer_active
[ 36.612581] BUG: KCSAN: data-race in set_nlink / set_nlink
[ 36.629559] BUG: KCSAN: data-race in generic_fillattr / set_nlink
[ 36.688606] BUG: KCSAN: data-race in __fput / kernfs_refresh_inode
[ 47.528845] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 48.885486] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 52.818843] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 56.355483] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 57.018848] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 60.652186] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 63.688828] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 64.185511] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 66.775499] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 71.638848] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 74.808910] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 75.172163] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 78.105499] BUG: KCSAN: data-race in timekeeping_get_ns+0x138/0x1d0
[ 78.635498] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 79.302043] BUG: KCSAN: data-race in xas_clear_mark / xas_find_marked
[ 82.015496] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 89.365427] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0
[ 89.388778] BUG: KCSAN: data-race in __hrtimer_run_queues / hrtimer_active
[ 89.403648] BUG: KCSAN: data-race in tick_nohz_idle_got_tick / tick_nohz_stop_idle
[ 94.855379] BUG: KCSAN: data-race in timekeeping_get_ns+0x148/0x1d0

Some data about the system:

# inxi -bZ
System:
Kernel: 6.3.5-gentoo-bdver2 arch: x86_64 bits: 64
Desktop: MATE v: 1.26.0 Distro: Gentoo Base System release 2.13
Machine:
Type: Desktop Mobo: Gigabyte model: 970-GAMING v: x.x serial: N/A
UEFI: American Megatrends v: F2 date: 04/06/2016
CPU:
Info: 8-core AMD FX-8370 [MT MCP] speed (MHz): avg: 1400 min/max: 1400/4000
Graphics:
Device-1: AMD Turks XT [Radeon HD 6670/7670] driver: radeon v: kernel
Display: x11 server: X.Org v: 21.1.8 driver: X: loaded: modesetting
unloaded: fbdev,radeon gpu: radeon resolution: 1920x1080~60Hz
OpenGL: renderer: AMD TURKS (DRM 2.50.0 / 6.3.5-gentoo-bdver2 LLVM
15.0.7) v: 4.5 Mesa 23.1.1
Network:
Device-1: Qualcomm Atheros Killer E2400 Gigabit Ethernet driver: alx

Kernel dmesg and .config attached.

Regards,
Erhard F.


Attachments:
(No filename) (5.74 kB)
config_64-rc4_bdver2 (123.24 kB)
dmesg_64-rc4_bdver2 (126.20 kB)
Download all attachments