Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2899779pxb; Tue, 24 Aug 2021 10:10:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTh/BCIrxHODAV6TjAR+qJ/rz8ibCOxAp3zsZ/hMqnJ4b7pbIJG0eTMkYXr/WSjUFnxfFg X-Received: by 2002:a17:906:32c9:: with SMTP id k9mr14833059ejk.218.1629825003529; Tue, 24 Aug 2021 10:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825003; cv=none; d=google.com; s=arc-20160816; b=dh4MM28DMKBkY3wL6SDLDi4+mm+LJ7abCN8K3kHFJ6oieRBazWAAcwXP0PeIcZTyOP n8XP+9O7pySSjGKLwqd6RnUCdtQsBG+YiKmFAJpIuzdTUyhVLdyb8WiF4k9ZYe8sfGqr Atak3ehpX2+vi6QbBftFTMa4tmXf0aUSagUqYBfOPlyqzru1Mh2go51b+NSk6wbM63a/ SLPhu7V+j7bC8UJ+3T0qKw45f7OBW+4oYIxAzxmHbikHQltkbowOH2EDv864PjY044Dy 5eICAPn3S671UgcA1EEWq3Kjy9ELgxJihbzvh9nWRpxv5nMxwbJsz6Oy/SiFpoajTfnD za3Q== 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=cT7gGiWLDx80HHklEPVj8IWvwGyca2hWdHedJch3tJo=; b=KvifdxVaFR/cnKcQoplljfjS4STT/mtbhPanUebpcEcoLsMrf1+lMvhZRju9FQApqB S1Roc/ImtvX2S0tm31zE4jfOrfcRgTevWj95unxPM46QP094RcfDYMjsegQWMWyxU9G9 TJv7JZ0ewMa25G5c6VZzHuHw327CdvwVTiwqoeLw2aYBsoislX3QhH+MffuFj34CwOBN I7i1tUqGDi/8VYAwVZCB3ifraROPmb2X7/Nokf6usE4fiN+C1a6xb2WCWC4Yhgpe5SGv oN7vG1TVxkTmSSK7oOgIkmlU6eMCaBABY/e4v+iIs2W2zmfEkWYG+2S0dOCG8R1YlLPI 1nvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EjaTXgZv; 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 u6si20530166eju.564.2021.08.24.10.09.38; Tue, 24 Aug 2021 10:10:03 -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=EjaTXgZv; 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 S239213AbhHXRIc (ORCPT + 99 others); Tue, 24 Aug 2021 13:08:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:47438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239098AbhHXRGP (ORCPT ); Tue, 24 Aug 2021 13:06:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B4A2619A6; Tue, 24 Aug 2021 16:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824384; bh=1fjPIrBNFzQeyRJDXFUYdHhFrCKPOEIaEro6hGd119c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EjaTXgZv7H1hQmJUebcQEItDwlzY807hFOPDcCkZ0OhUAKVbEL6cmFHkDVgXv+wsf z671GBYkPDh6SNoQj4R8o+FpUeoDiVxJhndUcskMnKvEvRO7VqAlOISAaDPL0bMyt3 KpmAmJtK+I3KUvwlYaNSoQlGfbmPb9pmwTTAB4WYbbyhkpcZrsGuuKxjcoyXJqQK/K MlzGkcz4tgJlySIC1mqHTvEiKuzS88ZyDgWTFsI87fiDJCTw08s+cP8Cexa71MIQLn BA/1LNHwwTpWYzximHA10S1yAXskwOdFdxXQHGa/znBCVwAj7vZYwxqoHUNWb1XNwa yO7tE0c1mcw2w== 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 5.10 34/98] Bluetooth: hidp: use correct wait queue when removing ctrl_wait Date: Tue, 24 Aug 2021 12:58:04 -0400 Message-Id: <20210824165908.709932-35-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+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 3b4fa27a44e6..0db48c812662 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -1290,7 +1290,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