Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5459200pxu; Tue, 22 Dec 2020 18:43:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0IFCK+udnbWBRm/LNPvdupZ/iGF5aYlv6iK5fdGxxVOOFIco1WxRu2o1vcv+hhtId8bmJ X-Received: by 2002:a17:906:43c5:: with SMTP id j5mr22911114ejn.530.1608691384999; Tue, 22 Dec 2020 18:43:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691384; cv=none; d=google.com; s=arc-20160816; b=SNgRz6uKN9KoPRajc8hVQOZ3K5IVxYcVnz/XZArK6t+El/5lhFP8qz3B/xrKf+TvWf GBaTFFTdIHaKpLhr6xlOBzcTGDmNUchgZz1173HhiyXJIULkBSi71Dt57eOx+Axqkkb3 hrthzjAy1hDayVOlHQa6arsimtG0eC8rIVi16GAYsiCfJ4Mo3PsA66pXzV+DzfVxHNOy iTriehofYt4Yp22OoGx2xq5a7kQpB1yR+l4/arutItTMxBa0d6iYjoE2LqSwWep1oGl7 sAtATlOOmcbi3dPxUvYUF24fi4MRyMHqTZPOmKPzpDkJbwinKE0zty2Sps+3Ef3DFZcI P3Kw== 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=YDVNjk/P+h7q969n2wAzog5pT8vFNxdHqoJ/lnVzpBQ=; b=ScPAtcLG2UzROHrTzE7trtHQVUGm9Zd7e4MXFNTkl8C7bfjZEBD34t61xa2Qhophm0 EVUdASbcVnWz3+loCHcMBAGrPi2BFJwvy3FZbN9/PBhRHgVE779Sq6lr1153UG6Ud/d/ 1yZkvKtIMC5pBfsrgOCiTQr/tJLy/24wj3mkqHjTmtUSCvxMJqH/x6N+gZTIqN3j1pj8 zElBKeURRSb1ZhLFkrgQyligKN+ebn3UiGeM99I+TcgJHeX1t/ugg6xG5646W3rFcsPy e1P75rosd3SD9WQR6M0XHNcfa7rx2GmDiNAB0It9X6Lomh51HRsBy5aYq8/9swMW645J FzQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RXyi5hZg; 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 t11si10085488edv.337.2020.12.22.18.42.42; Tue, 22 Dec 2020 18:43:04 -0800 (PST) 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=RXyi5hZg; 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 S1730217AbgLWCk6 (ORCPT + 99 others); Tue, 22 Dec 2020 21:40:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:49802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730008AbgLWCXa (ORCPT ); Tue, 22 Dec 2020 21:23:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37D1922248; Wed, 23 Dec 2020 02:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690193; bh=7rkc2npnIOGBriow68QXRzJnlTMY0fW7MhLDJT038nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RXyi5hZgw6r/9oqZL1RX21X6DybvNwEXiT0X+aHPwVBo6TKd1auzGeU1KqmGMvImu mvjglw3V7PqIk6XU+erICZ9Am0eO+pX4qUYKrc3ky4Oh2PT0xpMlwIqWm1XgH0J/1v T+jW+hgziqCtsCGG22UvIvfZ5d5z4C0mLa4KtnlYuejHhZMLVLBumCbGkOi0ZAtXQD 0+p63DHcr1N2YWg5hxyMZK55jXEeoRq24ff+jSNZ2MtcpTAaOGlxuNeIFaQvqUA2n2 GRQiCqcYPEhjBx8o5y5x8DyjKRSu4+yb/YYQwDFVXoAQEvFZhnyZRqSj7fuQdU2YdM q0jXgtQ+5PPlg== 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 , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 16/66] Bluetooth: hidp: use correct wait queue when removing ctrl_wait Date: Tue, 22 Dec 2020 21:22:02 -0500 Message-Id: <20201223022253.2793452-16-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 b21fcc838784d..acebcf605bb5a 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -1283,7 +1283,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.27.0