Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2922251pxb; Tue, 24 Aug 2021 10:40:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxhRER6ZuOwIUHSQelQXr9v9+/bu6eQov6ORuHHm6u7xeQDbDkkC73PXus0rWw6rK8u+6e X-Received: by 2002:a05:6e02:f44:: with SMTP id y4mr27741983ilj.257.1629826807494; Tue, 24 Aug 2021 10:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629826807; cv=none; d=google.com; s=arc-20160816; b=p9O/HOsnyUyERxKP+khvjL6n3IPI31nITiw50BECNcMBiYWXYGhPh+zyG2eMbl/N9C yv3mDS1aXePApJvpGrQa8sFa93rdIoCStreDFPzNkWv6nS6oMnzWz3r2vC5O8vaFNxzd 4+PpaiiYovmiCFQn35uTrJg8fWJ/xmGJMt2ZlX7bJaLfnQRHeXZHFi11Mhs14C1kpU5G 8DJPeDrZ81gcGhqBRUb3Hvisni7Bdm5zOrIhgRSFa4bkr4qpIyzn6BSag9I24PSq8pO6 MKeH7fOk8DZjuTwA3kRmG6HsuLUgJbzkLecV9JYYa79Q842HutGwnxkSY/pb+nS6swU3 oYXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rnu2n7lkaz18bQGSXqG18XgwLx0/kwh1uXxW1RUGpl4=; b=au7RkIiwrCPVeLnRdMwbpmw0bcWlzmGRsXAfmHRs/TjGRsYTImJ3YvU7tHMDExD2Eh 33j3ci3lB/4Qb0tjuP5zthnoTQV86MLYBTJoAoinf6PwOok66bspSFAwnGe7xJuQoy4/ NpoFEFwHHaXGPuKJ9KYecItQCr8sCy8wmcan0fXxrSa/i3fOJyfQMLsLd+x1fWjpWKID nuvISGkL9DvCFxFLNcKDCcOy+eROKpdVXqzmq6p6u9Dakn1aSm9rADrRZb3nfaRU4B4y 91UKZKifpd7reCLiP8itLcibonwCPrAN7/hKJSKfSHULjJ9mDvsyPTG6nbB6LnrFrl/X rGhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pXm1IGOZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si18084570ilb.145.2021.08.24.10.39.55; Tue, 24 Aug 2021 10:40:07 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pXm1IGOZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235347AbhHXRi3 (ORCPT + 99 others); Tue, 24 Aug 2021 13:38:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:39732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242350AbhHXRfJ (ORCPT ); Tue, 24 Aug 2021 13:35:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3090461BBF; Tue, 24 Aug 2021 17:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824805; bh=2XNBmfkXOU+krQM9YnxokQfJ96fIbLFwZ7WrGViP85Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXm1IGOZdF6nE/0224sVlal1YEzXwBsvujDtDHd3DBqFooUpVD2gYzIwT1j8HAUKf jbITD7dwUyew+YmlCoMzv1zYH8ihRBm4O8iPC6EdABVn/ZUymXcb5ICmA9LVsKqjPl gfQe16ZSQURlmw9vBKwc8sz7RZEm/lrUSLe/JVq8Qqb6TVQZiufL6UufsDr0Tfm05s 4EvNzYIK+3carIYYiUhvYbUbMFB4dMDf70xsqQr/Qhl2bA+xBLt+qfFLIIUm2HKMs/ En/qnAh06T0wpJ3RyGKXFj3wt6sWFIeIycVFe9RByCRZ3Aa826TmPTXt3xdqrwqhNM ax6CKgj+rFchg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Ole=20Bj=C3=B8rn=20Midtb=C3=B8?= , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.9 30/43] Bluetooth: hidp: use correct wait queue when removing ctrl_wait Date: Tue, 24 Aug 2021 13:06:01 -0400 Message-Id: <20210824170614.710813-31-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170614.710813-1-sashal@kernel.org> References: <20210824170614.710813-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.281-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.281-rc1 X-KernelTest-Deadline: 2021-08-26T17:06+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ole Bjørn Midtbø [ Upstream commit cca342d98bef68151a80b024f7bf5f388d1fbdea ] A different wait queue was used when removing ctrl_wait than when adding it. This effectively made the remove operation without locking compared to other operations on the wait queue ctrl_wait was part of. This caused issues like below where dead000000000100 is LIST_POISON1 and dead000000000200 is LIST_POISON2. list_add corruption. next->prev should be prev (ffffffc1b0a33a08), \ but was dead000000000200. (next=ffffffc03ac77de0). ------------[ cut here ]------------ CPU: 3 PID: 2138 Comm: bluetoothd Tainted: G O 4.4.238+ #9 ... ---[ end trace 0adc2158f0646eac ]--- Call trace: [] __list_add+0x38/0xb0 [] add_wait_queue+0x4c/0x68 [] __pollwait+0xec/0x100 [] bt_sock_poll+0x74/0x200 [] sock_poll+0x110/0x128 [] do_sys_poll+0x220/0x480 [] SyS_poll+0x80/0x138 [] __sys_trace_return+0x0/0x4 Unable to handle kernel paging request at virtual address dead000000000100 ... CPU: 4 PID: 5387 Comm: kworker/u15:3 Tainted: G W O 4.4.238+ #9 ... Call trace: [] __wake_up_common+0x7c/0xa8 [] __wake_up+0x50/0x70 [] sock_def_wakeup+0x58/0x60 [] l2cap_sock_teardown_cb+0x200/0x224 [] l2cap_chan_del+0xa4/0x298 [] l2cap_conn_del+0x118/0x198 [] l2cap_disconn_cfm+0x6c/0x78 [] hci_event_packet+0x564/0x2e30 [] hci_rx_work+0x10c/0x360 [] process_one_work+0x268/0x460 [] worker_thread+0x268/0x480 [] kthread+0x118/0x128 [] ret_from_fork+0x10/0x20 ---[ end trace 0adc2158f0646ead ]--- Signed-off-by: Ole Bjørn Midtbø Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hidp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 552e00b07196..9ec37c6c8c4a 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -1282,7 +1282,7 @@ static int hidp_session_thread(void *arg) /* cleanup runtime environment */ remove_wait_queue(sk_sleep(session->intr_sock->sk), &intr_wait); - remove_wait_queue(sk_sleep(session->intr_sock->sk), &ctrl_wait); + remove_wait_queue(sk_sleep(session->ctrl_sock->sk), &ctrl_wait); wake_up_interruptible(&session->report_queue); hidp_del_timer(session); -- 2.30.2