Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1005703pxa; Wed, 19 Aug 2020 23:14:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6ba6A0nvRJZqGe9F7pvoT1qatyXNce9Z11v33INVskbDsQAAeODpY8yTgMXwGlxg5w3d5 X-Received: by 2002:a17:906:49a:: with SMTP id f26mr1764988eja.266.1597904070637; Wed, 19 Aug 2020 23:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597904070; cv=none; d=google.com; s=arc-20160816; b=ginkvuTk5pk8xwNnxGbKCGp17Ugzu7h/kocWj2wWn25NVRWkFlUu82Y4uITrYyOTDD /2tXTZ0BwZaukaastFZ7UxLuLZO65brTlqhwQGaZy0ihgeAFknSMgUA8siaR7kJa63iI 1nK/m+GrTCoUqxrZKXshQ155d/Hphz44+SqW5y3dUvhmgMtztA10NnEVny8/yce0hT7w gHBMsEmVexDEmMgUBBJViQqLtnyN1M3EBwydpZSKo/u2Z2vFHxty5Ch2DJawVUr6bMtM oRtPVKarJcsx2VGs3hOAybrQbmHfWXktC+J8x9vcKY/lY4TJCYYVhRgFsMjJixHXFt/r 6ThA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jfZ8AEDo5b6yM2W8sFrMWFRKou8veGh90s+SGjERmgE=; b=SSWWzt++l552xmIfTAND5ZcO9gc1VILw+rHEm7GhhxCMAm/UwOi6zauC9tfpuPAM/F y+Lk522wX/5rM0G6ETI6KKuh+mqM0TolB5laVzpMHBf3pFnHxZgBXDVG/xUQOo7rJ4ki kDLuHDgFv1c79LZ12f0t+/YwTk0VIaVR0a6/tGWVnlrsqZy9u95tGh+NB5C+DyBiBea3 QAojWwLocU59FMrxSj5K0Nmko/0sEZGbt3Ywy4SgXhH8NxNJf6lxFzBE0nyRlkJK1h6i AD9eF1BDmUOAWu9s+9TZAb6oV0NrTRsK1yWhejIr0cJdK4X3z8zogRg6CShWRLG1o8xn b4kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Pg0Vt16U; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck8si825728edb.82.2020.08.19.23.14.05; Wed, 19 Aug 2020 23:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Pg0Vt16U; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725793AbgHTGOB (ORCPT + 99 others); Thu, 20 Aug 2020 02:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgHTGOB (ORCPT ); Thu, 20 Aug 2020 02:14:01 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BEDC061757 for ; Wed, 19 Aug 2020 23:14:00 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id y11so477221qvl.4 for ; Wed, 19 Aug 2020 23:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jfZ8AEDo5b6yM2W8sFrMWFRKou8veGh90s+SGjERmgE=; b=Pg0Vt16UN94wMHwX8Jg15yh0TnJwz1aiilNhssiuaeTm0HKGqIGsaYga/FvxwXWYV+ 8QhbzNpU5JawQJp6GPpBksX3QCgXdnfiSu3RsPgTPeK+OIyedumsfAZ7n8J10ZbcVITz 0fCka7CdNIGbKT9ccOCr/QyhLNH2no0Z2WGRgq6KD4H12y+8/k7gXzacrN+S//8eGX6I fBcsrhgtA9b7/lfo1XwLXfS4e2kIsVtIZfm54JTL7pHTmakJAWHvclNGelzXqd03orKN Xnx/Qpru1ozi49919sz5XYbSRT2VeTiHQuW+CB86FFkt95k0c3Ha145MbV8DpLHNgkIu 86DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jfZ8AEDo5b6yM2W8sFrMWFRKou8veGh90s+SGjERmgE=; b=Lw1YikJvbr5ppSqyl5TYwWzAJB+Z4jPAaVlyjcm0ulvILD+6tpNjQWJaGfmfXk0bax nwotDhW8zNMyN0k/WzIeqr27ekDljBphqNFllOPLNDyhFL5g89RdAG3eWsJGw6gQRPnO N11A8e+LZ61RvDvF/jMH9ZmdMpTZccvE9N+9bCUcJ+z3nC1CUxlqhsEeeFlU6LkzEafv oGnUSjqHm08AyF0PbvaeG4lctBzYDn2/83UYLzmfWqRnIIAJJjUITUc8I/tQH6iUoIn7 Ifw60UcxcODZVNS4uY0iidgg3FarFkH05ziapFJMnxpukE+wo+NhX4E7rHo1R8mw5MiK HR+w== X-Gm-Message-State: AOAM531I/a6mxa8gQr3mm9S8rwifrWNlmyB51p653TKAhuoVxU53jHaV NimJVRsPsfy89OD2hwp4xL9y+o/NHpGPMQz1smHjKQ== X-Received: by 2002:a0c:8d4a:: with SMTP id s10mr1745746qvb.34.1597904039193; Wed, 19 Aug 2020 23:13:59 -0700 (PDT) MIME-Version: 1.0 References: <000000000000c57f2d05ac4c5b8e@google.com> <20200820060713.smilfw3otuunnepe@Rk> In-Reply-To: <20200820060713.smilfw3otuunnepe@Rk> From: Dmitry Vyukov Date: Thu, 20 Aug 2020 08:13:47 +0200 Message-ID: Subject: Re: BUG: corrupted list in kobject_add_internal To: Coiby Xu Cc: syzbot , abhishekpandit@chromium.org, David Miller , Greg Kroah-Hartman , Johan Hedberg , Jakub Kicinski , linux-bluetooth , LKML , Marcel Holtmann , netdev , Rafael Wysocki , syzkaller-bugs , linux-kernel-mentees@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Thu, Aug 20, 2020 at 8:07 AM Coiby Xu wrote: > > On Fri, Aug 07, 2020 at 09:47:20AM -0700, syzbot wrote: > >Hello, > > > >syzbot found the following issue on: > > > >HEAD commit: 5a30a789 Merge tag 'x86-urgent-2020-08-02' of git://git.ke.. > >git tree: upstream > >console output: https://syzkaller.appspot.com/x/log.txt?x=1660c858900000 > >kernel config: https://syzkaller.appspot.com/x/.config?x=c0cfcf935bcc94d2 > >dashboard link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 > >compiler: gcc (GCC) 10.1.0-syz 20200507 > >syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b73afc900000 > >C reproducer: https://syzkaller.appspot.com/x/repro.c?x=124893a4900000 > > > >The issue was bisected to: > > > >commit 4f40afc6c76451daff7d0dcfc8a3d113ccf65bfc > >Author: Abhishek Pandit-Subedi > >Date: Wed Mar 11 15:54:01 2020 +0000 > > > > Bluetooth: Handle BR/EDR devices during suspend > > > >bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11cb1e0a900000 > >final oops: https://syzkaller.appspot.com/x/report.txt?x=13cb1e0a900000 > >console output: https://syzkaller.appspot.com/x/log.txt?x=15cb1e0a900000 > > > >IMPORTANT: if you fix the issue, please add the following tag to the commit: > >Reported-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com > >Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > > > >debugfs: Directory '200' with parent 'hci0' already present! > >list_add double add: new=ffff88808e9b6418, prev=ffff88808e9b6418, next=ffff8880a973ef00. > >------------[ cut here ]------------ > >kernel BUG at lib/list_debug.c:29! > >invalid opcode: 0000 [#1] PREEMPT SMP KASAN > >CPU: 1 PID: 6882 Comm: kworker/u5:1 Not tainted 5.8.0-rc7-syzkaller #0 > >Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > >Workqueue: hci0 hci_rx_work > >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 > >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b > >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 > >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 > >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 > >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 > >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 > >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 > >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 > >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >CR2: 00007ffdcd6db747 CR3: 000000009ba09000 CR4: 00000000001406e0 > >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > >Call Trace: > > __list_add include/linux/list.h:67 [inline] > > list_add_tail include/linux/list.h:100 [inline] > > kobj_kset_join lib/kobject.c:196 [inline] > > kobject_add_internal+0x18d/0x940 lib/kobject.c:246 > > kobject_add_varg lib/kobject.c:390 [inline] > > kobject_add+0x150/0x1c0 lib/kobject.c:442 > > device_add+0x35a/0x1be0 drivers/base/core.c:2633 > > hci_conn_add_sysfs+0x84/0xe0 net/bluetooth/hci_sysfs.c:53 > > hci_conn_complete_evt net/bluetooth/hci_event.c:2607 [inline] > > hci_event_packet+0xe0b/0x86f5 net/bluetooth/hci_event.c:6033 > > hci_rx_work+0x22e/0xb10 net/bluetooth/hci_core.c:4705 > > process_one_work+0x94c/0x1670 kernel/workqueue.c:2269 > > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 > > kthread+0x3b5/0x4a0 kernel/kthread.c:291 > > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 > >Modules linked in: > >---[ end trace b1bcc552c32d25e9 ]--- > >RIP: 0010:__list_add_valid.cold+0x26/0x3c lib/list_debug.c:29 > >Code: 57 ff ff ff 4c 89 e1 48 c7 c7 20 92 93 88 e8 b1 f1 c1 fd 0f 0b 48 89 f2 4c 89 e1 48 89 ee 48 c7 c7 60 93 93 88 e8 9a f1 c1 fd <0f> 0b 48 89 f1 48 c7 c7 e0 92 93 88 4c 89 e6 e8 86 f1 c1 fd 0f 0b > >RSP: 0018:ffffc90001777830 EFLAGS: 00010282 > >RAX: 0000000000000058 RBX: ffff8880a973ef00 RCX: 0000000000000000 > >RDX: ffff888094f1c200 RSI: ffffffff815d4ef7 RDI: fffff520002eeef8 > >RBP: ffff88808e9b6418 R08: 0000000000000058 R09: ffff8880ae7318e7 > >R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a973ef00 > >R13: ffff888087315270 R14: ffff88808e9b6430 R15: ffff88808e9b6418 > >FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000 > >CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >CR2: 00007ffdcd6db747 CR3: 0000000009a79000 CR4: 00000000001406e0 > >DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > >DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > > > > > >--- > >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 syzkaller@googlegroups.com. > > > >syzbot will keep track of this issue. See: > >https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > >For information about bisection process see: https://goo.gl/tpsmEJ#bisection > >syzbot can test patches for this issue, for details see: > >https://goo.gl/tpsmEJ#testing-patches > > > >-- > >You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group. > >To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com. > >To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000c57f2d05ac4c5b8e%40google.com. > > This problem occurs because the HCI_EV_CONN_COMPLETE event packet is sent > twice for the same HCI connection, > > struct hci_ev_conn_complete complete; > memset(&complete, 0, sizeof(complete)); > complete.status = 0; > complete.handle = HCI_HANDLE_1; > memset(&complete.bdaddr, 0xaa, 6); > *(uint8_t*)&complete.bdaddr.b[5] = 0x10; > complete.link_type = ACL_LINK; > complete.encr_mode = 0; > hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, > sizeof(complete)); > > which leads to kobject_add being called twice. Thus duplicate > (struct hci_conn *conn)->dev.kobj.entry is inserted into > (struct hci_conn *conn)->dev.kobj.kset->list. > > But if it's the HCI connection creator's responsibility to > not send the HCI_EV_CONN_COMPLETE event packet twice, then it's not a > valid bug. Or should we make the kernel more robust by defending against > this case? Hi Coiby, Whoever is sending HCI_EV_CONN_COMPLETE, this should not corrupt kernel memory. Even if it's firmware, it's not necessary trusted, see: https://www.blackhat.com/us-20/briefings/schedule/index.html#finding-new-bluetooth-low-energy-exploits-via-reverse-engineering-multiple-vendors-firmwares-19655 and: https://www.armis.com/bleedingbit/ So if an attacker takes over firmware, they can then corrupt kernel memory.