• Eric Dumazet's avatar
    kcm: disable preemption in kcm_parse_func_strparser() · 0355d6c1
    Eric Dumazet authored
    After commit a2c11b03 ("kcm: use BPF_PROG_RUN")
    syzbot easily triggers the warning in cant_sleep().
    
    As explained in commit 6cab5e90 ("bpf: run bpf programs
    with preemption disabled") we need to disable preemption before
    running bpf programs.
    
    BUG: assuming atomic context at net/kcm/kcmsock.c:382
    in_atomic(): 0, irqs_disabled(): 0, pid: 7, name: kworker/u4:0
    3 locks held by kworker/u4:0/7:
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: __write_once_size include/linux/compiler.h:226 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: atomic64_set include/asm-generic/atomic-instrumented.h:855 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: atomic_long_set include/asm-generic/atomic-long.h:40 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: set_work_data kernel/workqueue.c:620 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline]
     #0: ffff888216726128 ((wq_completion)kstrp){+.+.}, at: process_one_work+0x88b/0x1740 kernel/workqueue.c:2240
     #1: ffff8880a989fdc0 ((work_completion)(&strp->work)){+.+.}, at: process_one_work+0x8c1/0x1740 kernel/workqueue.c:2244
     #2: ffff888098998d10 (sk_lock-AF_INET){+.+.}, at: lock_sock include/net/sock.h:1522 [inline]
     #2: ffff888098998d10 (sk_lock-AF_INET){+.+.}, at: strp_sock_lock+0x2e/0x40 net/strparser/strparser.c:440
    CPU: 0 PID: 7 Comm: kworker/u4:0 Not tainted 5.3.0+ #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Workqueue: kstrp strp_work
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x172/0x1f0 lib/dump_stack.c:113
     __cant_sleep kernel/sched/core.c:6826 [inline]
     __cant_sleep.cold+0xa4/0xbc kernel/sched/core.c:6803
     kcm_parse_func_strparser+0x54/0x200 net/kcm/kcmsock.c:382
     __strp_recv+0x5dc/0x1b20 net/strparser/strparser.c:221
     strp_recv+0xcf/0x10b net/strparser/strparser.c:343
     tcp_read_sock+0x285/0xa00 net/ipv4/tcp.c:1639
     strp_read_sock+0x14d/0x200 net/strparser/strparser.c:366
     do_strp_work net/strparser/strparser.c:414 [inline]
     strp_work+0xe3/0x130 net/strparser/strparser.c:423
     process_one_work+0x9af/0x1740 kernel/workqueue.c:2269
    
    Fixes: a2c11b03 ("kcm: use BPF_PROG_RUN")
    Fixes: 6cab5e90 ("bpf: run bpf programs with preemption disabled")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    0355d6c1
kcmsock.c 45 KB