WARNING: suspicious RCU usage in memfd_fcntl

9 views
Skip to first unread message

syzbot

unread,
Oct 29, 2019, 6:03:07 AM10/29/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: ef244c30 Linux 4.19.81
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=131415bce00000
kernel config: https://syzkaller.appspot.com/x/.config?x=a3e67c0671e5c5e7
dashboard link: https://syzkaller.appspot.com/bug?extid=b5b42e3bd0551159cf1b
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

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

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+b5b42e...@syzkaller.appspotmail.com

=============================
WARNING: suspicious RCU usage
4.19.81 #0 Not tainted
-----------------------------
include/linux/radix-tree.h:241 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz-executor.0/4012:
#0: 00000000fd75658d (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock
include/linux/fs.h:747 [inline]
#0: 00000000fd75658d (&sb->s_type->i_mutex_key#12){+.+.}, at:
memfd_add_seals mm/memfd.c:199 [inline]
#0: 00000000fd75658d (&sb->s_type->i_mutex_key#12){+.+.}, at:
memfd_fcntl+0x235/0x1750 mm/memfd.c:249
#1: 000000004f77ba10 (&(&(&mapping->i_pages)->xa_lock)->rlock){-.-.}, at:
spin_lock_irq include/linux/spinlock.h:354 [inline]
#1: 000000004f77ba10 (&(&(&mapping->i_pages)->xa_lock)->rlock){-.-.}, at:
memfd_tag_pins mm/memfd.c:42 [inline]
#1: 000000004f77ba10 (&(&(&mapping->i_pages)->xa_lock)->rlock){-.-.}, at:
memfd_wait_for_pins mm/memfd.c:83 [inline]
#1: 000000004f77ba10 (&(&(&mapping->i_pages)->xa_lock)->rlock){-.-.}, at:
memfd_add_seals mm/memfd.c:217 [inline]
#1: 000000004f77ba10 (&(&(&mapping->i_pages)->xa_lock)->rlock){-.-.}, at:
memfd_fcntl+0x4bc/0x1750 mm/memfd.c:249

stack backtrace:
CPU: 1 PID: 4012 Comm: syz-executor.0 Not tainted 4.19.81 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
lockdep_rcu_suspicious+0x153/0x15d kernel/locking/lockdep.c:4539
radix_tree_deref_slot include/linux/radix-tree.h:241 [inline]
radix_tree_deref_slot include/linux/radix-tree.h:239 [inline]
memfd_tag_pins mm/memfd.c:44 [inline]
memfd_wait_for_pins mm/memfd.c:83 [inline]
memfd_add_seals mm/memfd.c:217 [inline]
memfd_fcntl+0xfdf/0x1750 mm/memfd.c:249
do_fcntl+0x200/0x1020 fs/fcntl.c:421
__do_sys_fcntl fs/fcntl.c:463 [inline]
__se_sys_fcntl fs/fcntl.c:448 [inline]
__x64_sys_fcntl+0x16d/0x1e0 fs/fcntl.c:448
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459f49
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007efc3f0c4c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000048
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459f49
RDX: 0000000000000008 RSI: 0000000000000409 RDI: 0000000000000004
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007efc3f0c56d4
R13: 00000000004c0904 R14: 00000000004d31f0 R15: 00000000ffffffff
kauditd_printk_skb: 20 callbacks suppressed
audit: type=1804 audit(1572343300.910:378): pid=4128 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=ToMToU comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1129/file0"
dev="sda1" ino=17493 res=1
audit: type=1804 audit(1572343300.970:379): pid=4128 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1129/file0"
dev="sda1" ino=17493 res=1
audit: type=1804 audit(1572343301.180:380): pid=4288 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=ToMToU comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1130/file0"
dev="sda1" ino=16609 res=1
audit: type=1804 audit(1572343301.180:381): pid=4288 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1130/file0"
dev="sda1" ino=16609 res=1
audit: type=1804 audit(1572343301.450:382): pid=4365 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=ToMToU comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1131/file0"
dev="sda1" ino=16596 res=1
audit: type=1804 audit(1572343301.500:383): pid=4365 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1131/file0"
dev="sda1" ino=16596 res=1
audit: type=1804 audit(1572343301.860:384): pid=4391 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=ToMToU comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1132/file0"
dev="sda1" ino=17508 res=1
audit: type=1804 audit(1572343301.880:385): pid=4391 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1132/file0"
dev="sda1" ino=17508 res=1
audit: type=1804 audit(1572343302.070:386): pid=4405 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=ToMToU comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1133/file0"
dev="sda1" ino=17519 res=1
audit: type=1804 audit(1572343302.070:387): pid=4405 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1133/file0"
dev="sda1" ino=17519 res=1
device nr0 entered promiscuous mode
nf_conntrack: default automatic helper assignment has been turned off for
security reasons and CT-based firewall rule not found. Use the iptables CT
target to attach helpers instead.
syz-executor.3 (4718) used greatest stack depth: 21456 bytes left
selinux_nlmsg_perm: 5 callbacks suppressed
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
TCP: request_sock_TCPv6: Possible SYN flooding on port 20002. Sending
cookies. Check SNMP counters.
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=5780 comm=syz-executor.1
kauditd_printk_skb: 13 callbacks suppressed
audit: type=1400 audit(1572343307.630:401): avc: denied { setopt } for
pid=6331 comm="syz-executor.1"
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tclass=netlink_generic_socket permissive=1
netlink: 'syz-executor.1': attribute type 3 has an invalid length.
audit: type=1400 audit(1572343307.670:402): avc: denied { map } for
pid=6332 comm="blkid" path="/sbin/blkid" dev="sda1" ino=16128
scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:file_t:s0
tclass=file permissive=1
audit: type=1804 audit(1572343308.590:403): pid=6761 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.2"
name="/root/syzkaller-testdir759209128/syzkaller.R0F6DQ/1154/bus"
dev="sda1" ino=17577 res=1
audit: type=1804 audit(1572343308.600:404): pid=6775 uid=0 auid=4294967295
ses=4294967295 subj=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
op=invalid_pcr cause=open_writers comm="syz-executor.0"
name="/root/syzkaller-testdir650014770/syzkaller.zL3PHl/1312/bus"
dev="sda1" ino=17563 res=1


---
This bug 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 syzk...@googlegroups.com.

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

syzbot

unread,
Oct 29, 2019, 6:51:08 AM10/29/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: ef244c30 Linux 4.19.81
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12bad420e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=a3e67c0671e5c5e7
dashboard link: https://syzkaller.appspot.com/bug?extid=b5b42e3bd0551159cf1b
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=142f134ce00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=158ef86ce00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+b5b42e...@syzkaller.appspotmail.com

audit: type=1800 audit(1572345580.154:33): pid=7445 uid=0 auid=4294967295
ses=4294967295 subj=system_u:system_r:kernel_t:s0 op=collect_data
cause=failed(directio) comm="startpar" name="rc.local" dev="sda1" ino=2465
res=0
kauditd_printk_skb: 2 callbacks suppressed
audit: type=1400 audit(1572345588.004:36): avc: denied { map } for
pid=7630 comm="syz-executor615" path="/root/syz-executor615681230"
dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
=============================
WARNING: suspicious RCU usage
4.19.81 #0 Not tainted
-----------------------------
include/linux/radix-tree.h:241 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz-executor615/7630:
#0: 00000000b659d878 (&sb->s_type->i_mutex_key#12){+.+.}, at: inode_lock
include/linux/fs.h:747 [inline]
#0: 00000000b659d878 (&sb->s_type->i_mutex_key#12){+.+.}, at:
memfd_add_seals mm/memfd.c:199 [inline]
#0: 00000000b659d878 (&sb->s_type->i_mutex_key#12){+.+.}, at:
memfd_fcntl+0x235/0x1750 mm/memfd.c:249
#1: 000000002aa6086e (&(&(&mapping->i_pages)->xa_lock)->rlock){-...}, at:
spin_lock_irq include/linux/spinlock.h:354 [inline]
#1: 000000002aa6086e (&(&(&mapping->i_pages)->xa_lock)->rlock){-...}, at:
memfd_tag_pins mm/memfd.c:42 [inline]
#1: 000000002aa6086e (&(&(&mapping->i_pages)->xa_lock)->rlock){-...}, at:
memfd_wait_for_pins mm/memfd.c:83 [inline]
#1: 000000002aa6086e (&(&(&mapping->i_pages)->xa_lock)->rlock){-...}, at:
memfd_add_seals mm/memfd.c:217 [inline]
#1: 000000002aa6086e (&(&(&mapping->i_pages)->xa_lock)->rlock){-...}, at:
memfd_fcntl+0x4bc/0x1750 mm/memfd.c:249

stack backtrace:
CPU: 1 PID: 7630 Comm: syz-executor615 Not tainted 4.19.81 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
lockdep_rcu_suspicious+0x153/0x15d kernel/locking/lockdep.c:4539
radix_tree_deref_slot include/linux/radix-tree.h:241 [inline]
radix_tree_deref_slot include/linux/radix-tree.h:239 [inline]
memfd_tag_pins mm/memfd.c:44 [inline]
memfd_wait_for_pins mm/memfd.c:83 [inline]
memfd_add_seals mm/memfd.c:217 [inline]
memfd_fcntl+0xfdf/0x1750 mm/memfd.c:249
do_fcntl+0x200/0x1020 fs/fcntl.c:421
__do_sys_fcntl fs/fcntl.c:463 [inline]
__se_sys_fcntl fs/fcntl.c:448 [inline]
__x64_sys_fcntl+0x16d/0x1e0 fs/fcntl.c:448
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4401b9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffedef331e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000048
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004401b9
RDX: 0000000000000009 RSI: 0000000000000409 RDI: 0000000000000003
RBP: 00000000006ca

syzbot

unread,
Nov 26, 2019, 10:50:01 PM11/26/19
to syzkaller...@googlegroups.com
syzbot has bisected this bug to:

commit 99b45e7a1ba17548fd95420dce36346956d04564
Author: Matthew Wilcox (Oracle) <wi...@infradead.org>
Date: Fri Oct 25 16:58:34 2019 +0000

memfd: Fix locking when tagging pins

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=167e575ae00000
start commit: ef244c30 Linux 4.19.81
git tree: linux-4.19.y
final crash: https://syzkaller.appspot.com/x/report.txt?x=157e575ae00000
console output: https://syzkaller.appspot.com/x/log.txt?x=117e575ae00000
Reported-by: syzbot+b5b42e...@syzkaller.appspotmail.com
Fixes: 99b45e7a1ba1 ("memfd: Fix locking when tagging pins")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Dec 20, 2019, 5:56:01 PM12/20/19
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit e4cc9c81e2305aabfa9a0e46e17d3895a10ba3d8
Author: zhong jiang <zhong...@huawei.com>
Date: Mon Nov 18 03:26:08 2019 +0000

memfd: Use radix_tree_deref_slot_protected to avoid the warning.

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1474943ee00000
start commit: ef244c30 Linux 4.19.81
git tree: linux-4.19.y
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15c85ac8e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1645f68ae00000

If the result looks correct, please mark the bug fixed by replying with:

#syz fix: memfd: Use radix_tree_deref_slot_protected to avoid the warning.
Reply all
Reply to author
Forward
0 new messages