公司内部对 5.10 的 syzkaller KCSAN 测试发现如下问题:
==================================================================
BUG: KCSAN: data-race in __seccomp_filter / copy_process
read-write to 0xffff9e20d0a3b308 of 4 bytes by task 25128 on cpu 3:
copy_process+0x18ce/0x1db0 kernel/fork.c:2320
kernel_clone+0x155/0x600 kernel/fork.c:2495
__do_sys_clone kernel/fork.c:2612 [inline]
__se_sys_clone kernel/fork.c:2596 [inline]
__x64_sys_clone+0xc8/0xf0 kernel/fork.c:2596
do_syscall_64+0x37/0x50 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
read to 0xffff9e20d0a3b308 of 4 bytes by task 25131 on cpu 0:
get_nr_threads include/linux/sched/signal.h:655 [inline]
__seccomp_filter+0xc9b/0xdc0 kernel/seccomp.c:1263
__secure_computing+0x8f/0x140 kernel/seccomp.c:1311
syscall_trace_enter kernel/entry/common.c:58 [inline]
__syscall_enter_from_user_work kernel/entry/common.c:81 [inline]
syscall_enter_from_user_mode+0xd6/0x1b0 kernel/entry/common.c:99
do_syscall_64+0x11/0x50 arch/x86/entry/common.c:41
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 25131 Comm: syz-executor.3 Not tainted 5.10.0+ #6
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
==================================================================
Hi raverstern, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @yangyingliang , @gatieme , @jiaoff , @zhengzengkai , @LiuYongQiang0816 , @wangxiongfeng , @kevinzhu1 , @jentlestea , @lujialin2 , @wuxu_buque , @xukuohai , @lengchao , @alvin-ling , @yuzenghui , @yuehaibing , @juntianlinux , @chenguangli , @gasonchen , @whoisxxx , @koulihong , @kailiu42 , @hanjun-guo , @woqidaideshi , @chiqijun , @wkfxxx , @thundertown , @guohaocs2c , @kylin-mayukun , @oskernel0719 , @liuxinux , @newbeats , @zhujianwei001 , @zhenpengzheng , @SuperSix173 , @colyli , @zhangyi089 , @htforge , @xiexiuqi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
经检查,数据竞争发生在 current->signal->nr_threads
变量上:
copy_process()
中的 current->signal->nr_threads++
__seccomp_filter()
中的 get_nr_threads(current)
经确认,同一进程下的不同线程会共享 current->signal
结构体。数据竞争可能出现的场景为:存在同进程下两个线程 Ta、Tb,Ta 正在创建创建新线程;而 Tb 正处于系统调用执行过程中,且在使用 seccomp 对当前系统调用进行过滤。
我们注意到内核主线已有相关补丁:d21918e5a94a ("signal/seccomp: Dump core when there is only one live thread")。根据补丁所属补丁集的描述,该补丁集是为了处理一系列与内核任务退出相关的数据竞争问题。补丁集主旨与当前问题相符。因此决定回合该补丁至 hulk-5.10。
登录 后才可以发表评论