Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2952687imm; Mon, 28 May 2018 20:48:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosQ4BuQ1LnMaHUiETvaaLWYtFi3cKZmhAQ0UapDDxshGzs+p2s2Do18J5HbQWcocC1jYUq X-Received: by 2002:a63:93:: with SMTP id 141-v6mr12738818pga.322.1527565684420; Mon, 28 May 2018 20:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527565684; cv=none; d=google.com; s=arc-20160816; b=uHQaQ+rr77u7lxXZDwhjBQGYkdQm2aUWZfLi7wQjf36nHIEevLeQBowm/ib0m7n/CC qEINztMWUcb4hI8/zGN92+PKEDHH45Ox4AduB9gmKQ49CiGttc6BiZtPBDhDQgywa4+l ueqMgt48VWLu1qYOIOyxt2RZuyQLYOuM1DvoyWlLxgv0Zjz+xIpyR+VFqS9ka9vVrorC u8+tEexe6Y3VHNEOEoWlHHyqGJumdqwMjAw4yOqw5OxLkqSwijZYzLUq73GMzyEtD3gp gNx53KEMpbnyaMAvlALMvCR6SitlX21N7CKgrnhZc3ZALMgozv3BP+qw/EmT44uxXBbR bIIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:from:subject:message-id:in-reply-to :date:mime-version:arc-authentication-results; bh=iqVlgUNgoE+o6H9YGsDoBn51jywzOMzwNEvyVuVnDpg=; b=sQ2w38wa2hJxjCbvg4Y7BbRuP2Ah68ERqCt4q9oINaEKFhmz4dwgEU3I4nGbqrRFwc NYMfv85TB7OybQyaMugNEdeZ19bHk17gzRasNhA++Z1Fl/SxTpAkhN+/8/9pDw7VyN0U FqW1oGSHYBqmI91qgSiMZl/Y3bj2Ta4DaAe4QyWHpQFmDQXEG5Ak+vjLcEAnlCGi2AXk pr54bJFS+l4xFJNMX+5ez4xQXcvk0FGO+aprTQoSkMmaH9wtAN9iZ5vIpHB4B0TNzKLy QY/yK6ZQecdFfeVlLMPdh9BGxSlLWUfvM0wBKYHss4ur3Dgm+jE5ruPpg2eugIFMx6cA wbWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k139-v6si31848768pfd.97.2018.05.28.20.47.49; Mon, 28 May 2018 20:48:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754907AbeE1RfN (ORCPT + 99 others); Mon, 28 May 2018 13:35:13 -0400 Received: from mail-io0-f200.google.com ([209.85.223.200]:41767 "EHLO mail-io0-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754772AbeE1RfD (ORCPT ); Mon, 28 May 2018 13:35:03 -0400 Received: by mail-io0-f200.google.com with SMTP id f20-v6so10958948ioc.8 for ; Mon, 28 May 2018 10:35:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id:subject :from:to; bh=iqVlgUNgoE+o6H9YGsDoBn51jywzOMzwNEvyVuVnDpg=; b=XQr6Qj2M1YTuZm5xOjbnFQeODrLXS94vBAmYBWQF8ej6ofsub2fh8VVqMXVyx9hvkH wlojXCvlh5eeZ7CgpQ6BH0Cr3VHBS91P/ggu1VqlkdHH2ZPr4zbYLN24EH84VNdfUFcC l+STrzI47z41ChLng1nVuiM9CtfddcxVSk9NfouoBq1gD+exJH8h4P4CTLlcZOGGxxL0 XkbAmRNmRC0L522bFUfC9PjUqP+4336TNw3D9FWbPTGtSDW0ppXkL5tceSiJImmyagT2 7pAZbPO8hm6vvc/X0nifWK92wIkRUwCIjMkBNMqOEE3ZgYHQSD/aDOnRTV4iKMFVr4Pr dMjw== X-Gm-Message-State: ALKqPwftputfUVjrKpYTaT4hpQGAhZST/cU03cdXHbBMLKZB/23zbVMz WDE5MtK2WnovIEukz7Jd4iV6GZujQPc/Flwt3D1y3VfRYHra MIME-Version: 1.0 X-Received: by 2002:a5e:c105:: with SMTP id v5-v6mr6886136iol.69.1527528902569; Mon, 28 May 2018 10:35:02 -0700 (PDT) Date: Mon, 28 May 2018 10:35:02 -0700 In-Reply-To: <000000000000ca8a42056d4530a5@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000009f3a1b056d478948@google.com> Subject: Re: possible deadlock in bpf_tcp_close From: syzbot To: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org syzbot has found a reproducer for the following crash on: HEAD commit: 7a1a98c171ea Merge branch 'bpf-sendmsg-hook' git tree: bpf-next console output: https://syzkaller.appspot.com/x/log.txt?x=149ae2b7800000 kernel config: https://syzkaller.appspot.com/x/.config?x=e4078980b886800c dashboard link: https://syzkaller.appspot.com/bug?extid=47ed903f50684f046b15 compiler: gcc (GCC) 8.0.1 20180413 (experimental) syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=1553b17b800000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1460be2f800000 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+47ed903f50684f046b15@syzkaller.appspotmail.com random: sshd: uninitialized urandom read (32 bytes read) random: sshd: uninitialized urandom read (32 bytes read) random: sshd: uninitialized urandom read (32 bytes read) ====================================================== WARNING: possible circular locking dependency detected 4.17.0-rc6+ #25 Not tainted ------------------------------------------------------ syz-executor800/4527 is trying to acquire lock: (ptrval) (&htab->buckets[i].lock){+...}, at: bpf_tcp_close+0x822/0x10b0 kernel/bpf/sockmap.c:285 but task is already holding lock: (ptrval) (clock-AF_INET6){++..}, at: bpf_tcp_close+0x241/0x10b0 kernel/bpf/sockmap.c:260 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (clock-AF_INET6){++..}: __raw_write_lock_bh include/linux/rwlock_api_smp.h:203 [inline] _raw_write_lock_bh+0x31/0x40 kernel/locking/spinlock.c:312 sock_hash_delete_elem+0x7c6/0xaf0 kernel/bpf/sockmap.c:2338 map_delete_elem+0x32e/0x4e0 kernel/bpf/syscall.c:815 __do_sys_bpf kernel/bpf/syscall.c:2349 [inline] __se_sys_bpf kernel/bpf/syscall.c:2317 [inline] __x64_sys_bpf+0x342/0x510 kernel/bpf/syscall.c:2317 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x49/0xbe -> #0 (&htab->buckets[i].lock){+...}: lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168 bpf_tcp_close+0x822/0x10b0 kernel/bpf/sockmap.c:285 inet_release+0x104/0x1f0 net/ipv4/af_inet.c:427 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:459 sock_release+0x96/0x1b0 net/socket.c:594 sock_close+0x16/0x20 net/socket.c:1149 __fput+0x34d/0x890 fs/file_table.c:209 ____fput+0x15/0x20 fs/file_table.c:243 task_work_run+0x1e4/0x290 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x1aee/0x2730 kernel/exit.c:865 do_group_exit+0x16f/0x430 kernel/exit.c:968 get_signal+0x886/0x1960 kernel/signal.c:2482 do_signal+0x98/0x2040 arch/x86/kernel/signal.c:810 exit_to_usermode_loop+0x28a/0x310 arch/x86/entry/common.c:162 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline] syscall_return_slowpath arch/x86/entry/common.c:265 [inline] do_syscall_64+0x6ac/0x800 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(clock-AF_INET6); lock(&htab->buckets[i].lock); lock(clock-AF_INET6); lock(&htab->buckets[i].lock); *** DEADLOCK *** 2 locks held by syz-executor800/4527: #0: (ptrval) (rcu_read_lock){....}, at: bpf_tcp_close+0x0/0x10b0 kernel/bpf/sockmap.c:2106 #1: (ptrval) (clock-AF_INET6){++..}, at: bpf_tcp_close+0x241/0x10b0 kernel/bpf/sockmap.c:260 stack backtrace: CPU: 0 PID: 4527 Comm: syz-executor800 Not tainted 4.17.0-rc6+ #25 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+0x1b9/0x294 lib/dump_stack.c:113 print_circular_bug.isra.36.cold.54+0x1bd/0x27d kernel/locking/lockdep.c:1223 check_prev_add kernel/locking/lockdep.c:1863 [inline] check_prevs_add kernel/locking/lockdep.c:1976 [inline] validate_chain kernel/locking/lockdep.c:2417 [inline] __lock_acquire+0x343e/0x5140 kernel/locking/lockdep.c:3431 lock_acquire+0x1dc/0x520 kernel/locking/lockdep.c:3920 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168 bpf_tcp_close+0x822/0x10b0 kernel/bpf/sockmap.c:285 inet_release+0x104/0x1f0 net/ipv4/af_inet.c:427 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:459 sock_release+0x96/0x1b0 net/socket.c:594 sock_close+0x16/0x20 net/socket.c:1149 __fput+0x34d/0x890 fs/file_table.c:209 ____fput+0x15/0x20 fs/file_table.c:243 task_work_run+0x1e4/0x290 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x1aee/0x2730 kernel/exit.c:865 do_group_exit+0x16f/0x430 kernel/exit.c:968 get_signal+0x886/0x1960 kernel/signal.c:2482 do_signal+0x98/0x2040 arch/x86/kernel/signal.c:810 exit_to_usermode_loop+0x28a/0x310 arch/x86/entry/common.c:162 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline] syscall_return_slowpath arch/x86/entry/common.c:265 [inline] do_syscall_64+0x6ac/0x800 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x445709 RSP: 002b:00007f36c605ddb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca RAX: fffffffffffffe00 RBX: 00000000006dac3c RCX: 0000000000445709 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000006dac3c RBP: 00000000006dac38 R08: 0000000000000000 R09: 000