Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1075281pxk; Mon, 31 Aug 2020 09:07:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbXoyi6dkgZ0d/845KF1hGIt3fQMx2heAZ/2ENk9oLHKKgA/4w71Biaw7GnjRHFq/DNaOc X-Received: by 2002:a50:99d5:: with SMTP id n21mr1875079edb.88.1598890047841; Mon, 31 Aug 2020 09:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598890047; cv=none; d=google.com; s=arc-20160816; b=Cq5Km1BFLBpv+Ah+3ug1yWof0Buy7Tr66LUWWjHkc1D6V9QzyeKZUZiyzwsrpJnNK9 3B37jEUVnCDDKEUguNAM8lwd2vciYtKUEx+3jAZPV5SwGhPKfWiv0oimJra8XwU5JMuX 7woNk95Nj8ZxQXutZ8WeKMZK0sVWwFesogSQSP2GUu/6GFtYnhAga+uaMEZkOygW5cFX E28EXxlsttVV929UlOGLtTL1rvJ94kpM5yH/cU8+nzjG/d0XErhrM66tVdN7ytDv+ZFR ouVKU1sdj7IKL4JGftENHtsZw788TLbNW+SvkhQ+6aZ32UDJc0UgczQxea2PwnZ47Uop ++UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=hdfsRpD0vW5LM77HCSsblRzxRItmO2fVHVQCskQg+kE=; b=H8oA/eI775MF1TYQbFGM3XGc+QBDIYIOsqa6dvdCbqY5fYoqz07DmLgCIcQ1Z2V9x0 tTkEw+paJa1BQbPhzC47ha+5DIWHH5rvGl6Wom8jWN2cloSSm9pRlTcznAJ5QdiBJAfA Cw6sUKrYyrXJ7HVdK3PONtLl8M5cNmtZ1IOU6UNEECHM1bBRAC0kFfwnrKe8rduC8LWL X88lo5cdiucAY+9Jt3TDuHDjgTLcyFTOVC4M9euz5vDsjcoZTazWov/hqH2mxn9LtqG6 r57hDhCjkUFsm/m0Zh2OrS4HD39bMX1XxdYPbV4sUD2hc0ghiK7O+8F4FwQqBA7KvuqG l9bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si2939451edr.166.2020.08.31.09.07.04; Mon, 31 Aug 2020 09:07:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728449AbgHaQGV convert rfc822-to-8bit (ORCPT + 99 others); Mon, 31 Aug 2020 12:06:21 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:48615 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727019AbgHaQGU (ORCPT ); Mon, 31 Aug 2020 12:06:20 -0400 Received: from marcel-macbook.fritz.box (p4ff9f430.dip0.t-ipconnect.de [79.249.244.48]) by mail.holtmann.org (Postfix) with ESMTPSA id BF220CECCE; Mon, 31 Aug 2020 18:16:27 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: fix "list_add double add" in hci_conn_complete_evt From: Marcel Holtmann In-Reply-To: <20200823010022.938532-1-coiby.xu@gmail.com> Date: Mon, 31 Aug 2020 18:06:18 +0200 Cc: linux-bluetooth , linux-kernel-mentees@lists.linuxfoundation.org, Greg KH , syzkaller-bugs@googlegroups.com, syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com, Johan Hedberg , "David S. Miller" , Jakub Kicinski , "open list:NETWORKING [GENERAL]" , open list Content-Transfer-Encoding: 8BIT Message-Id: References: <000000000000c57f2d05ac4c5b8e@google.com> <20200823010022.938532-1-coiby.xu@gmail.com> To: Coiby Xu X-Mailer: Apple Mail (2.3608.120.23.2.1) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Coiby, > When two HCI_EV_CONN_COMPLETE event packets with status=0 of the same > HCI connection are received, device_add would be called twice which > leads to kobject_add being called twice. Thus duplicate > (struct hci_conn *conn)->dev.kobj.entry would be inserted into > (struct hci_conn *conn)->dev.kobj.kset->list. > > This issue can be fixed by checking (struct hci_conn *conn)->debugfs. > If it's not NULL, it means the HCI connection has been completed and we > won't duplicate the work as for processing the first > HCI_EV_CONN_COMPLETE event. do you have a btmon trace for this happening? > Reported-and-tested-by: syzbot+dd768a260f7358adbaf9@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=dd768a260f7358adbaf9 > Signed-off-by: Coiby Xu > --- > net/bluetooth/hci_event.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 4b7fc430793c..1233739ce760 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -2605,6 +2605,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > } > > if (!ev->status) { > + if (conn->debugfs) { > + bt_dev_err(hdev, "The connection has been completed"); > + goto unlock; > + } > + And instead of doing papering over a hole, I would rather detect that the HCI event is not valid since we already received one for this connection. Regards Marcel