Skip to contentSkip to conversation

KCSAN: data-race in selinux_inode_permission / selinux_task_to_inode

syzbot syzbot 1 participant 1 message Dec 3 SELinux security module

lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    693c2e04e3f1 mm: kvmalloc: Bail if called with soft or har..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10fa3cff980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=12de098a40e11adc
dashboard link: https://syzkaller.appspot.com/bug?extid=3857e9743aa17a4cd369
compiler:       Debian clang version 22.1.8 (1~deb13u5), Debian LLD 22.1.8

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b3a16c393bfd/disk-693c2e04.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c61ebd019448/vmlinux-693c2e04.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e2fe6263b1c5/bzImage-693c2e04.xz

AI-generated root cause summary:
selinux_task_to_inode() in security/selinux/hooks.c updates isec->sid (and isec->sclass) on /proc inodes under isec->lock using plain writes during pid_revalidate() / pid_update_inode(). Concurrently, selinux_inode_permission() (and its inlined helpers task_avdcache_search() and task_avdcache_update()) reads isec->sid and isec->sclass locklessly and without READ_ONCE() or data_race() during VFS path lookup. Because isec->sid is also read multiple times across avc_has_perm_noaudit() and task_avdcache_update(), a concurrent update can also pair an av_decision computed for the old SID with the new SID in the task's avdcache.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=3857e9743aa17a4cd369

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

==================================================================

BUG: KCSAN: data-race in selinux_inode_permission / selinux_task_to_inode

write to 0xffff88810d82b7d4 of 4 bytes by task 4030 on cpu 0:

 selinux_task_to_inode+0x160/0x1a0 security/selinux/hooks.c:4740
 security_task_to_inode+0x39/0x50 security/security.c:3374
 pid_update_inode fs/proc/base.c:2035 [inline]
 pid_revalidate+0x82/0xb0 fs/proc/base.c:2057
 d_revalidate fs/namei.c:1041 [inline]
 lookup_fast+0x232/0x320 fs/namei.c:1874
 walk_component fs/namei.c:2284 [inline]
 link_path_walk+0x528/0xde0 fs/namei.c:2662
 path_openat+0x142/0x11e0 fs/namei.c:5012
 do_file_open+0x16c/0x290 fs/namei.c:5045
 do_sys_openat2+0xa1/0x140 fs/open.c:1443
 do_sys_open fs/open.c:1449 [inline]
 __do_sys_openat fs/open.c:1465 [inline]
 __se_sys_openat fs/open.c:1460 [inline]
 __x64_sys_openat+0xf2/0x120 fs/open.c:1460
 x64_sys_call+0x1f72/0x2550 arch/x86/include/generated/asm/syscalls_64.h:258
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff88810d82b7d4 of 4 bytes by task 4029 on cpu 1:

 selinux_inode_permission+0x3e6/0x740 security/selinux/hooks.c:-1
 security_inode_permission+0x73/0xb0 security/security.c:1865
 inode_permission+0x1e3/0x3c0 fs/namei.c:661
 lookup_inode_permission_may_exec fs/namei.c:-1 [inline]
 may_lookup fs/namei.c:1967 [inline]
 link_path_walk+0x881/0xde0 fs/namei.c:2610
 path_openat+0x142/0x11e0 fs/namei.c:5012
 do_file_open+0x16c/0x290 fs/namei.c:5045
 do_sys_openat2+0xa1/0x140 fs/open.c:1443
 do_sys_open fs/open.c:1449 [inline]
 __do_sys_openat fs/open.c:1465 [inline]
 __se_sys_openat fs/open.c:1460 [inline]
 __x64_sys_openat+0xf2/0x120 fs/open.c:1460
 x64_sys_call+0x1f72/0x2550 arch/x86/include/generated/asm/syscalls_64.h:258
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:

CPU: 1 UID: 0 PID: 4029 Comm: syz.4.97 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup