Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1872065pxb; Sat, 22 Jan 2022 08:38:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7GgMNUnzB/SVFToUcZs4xTMqapggZOlOiU5N6mbLl3smlwXp8fRUOdiN+6V3Gk+9Tki9B X-Received: by 2002:a17:902:76c6:b0:14a:c884:9c90 with SMTP id j6-20020a17090276c600b0014ac8849c90mr8301943plt.145.1642869530725; Sat, 22 Jan 2022 08:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642869530; cv=none; d=google.com; s=arc-20160816; b=sFknq5V+ffoqqCNJL/CUK23RiCLZ6oeMUZO+Oky87k+Eb/UDIpB6DJ0Ndfaf0yreSl IhgZ1U1D5rapIpVklD1AEsK6ht4nkdQ5f2TIhpgZ5Z5sXwZxJl9VeQqV8St2mDj3nw41 tWjYaRlUyQKboTr4mwq8M9vHnu2PywR7J88gHtKuuRBA4TOD9Gi4SgPTrkaOhmnpL0mR ZO6rnWXK1I1BsnVOReQKl55aCuO9PVEFiLG+IAHVLjk7p5wR6K/f+RFqhX0deSx9N6Ke 6mKQpfcd6At6cdEzY6FrGTs2rfcSMzK4rXdhjI2UCgPbuoZrHZWkQSFguPiXYaSnjylX 1l7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=iqd2Czkqz3tSQo6v3I3ISZGWnw7e8Y7YECCX4zOmlkI=; b=pHbW85jtYX6TmDrQW8A/UlLQA8wWRd8GXUGoxe1vZ4gw0084CuSztKv/V/fg4T/qhO dh56YjSDjBWjs2uKRs3sroMtRJENN+VCK0V6vnqydOcLovawOdazq1wzuff+v6BB7ydK K1hyK/o84EnRcWv89aAs3FtFw7WgmahvNCuudjH1uY6u5JHP5XpSafeUV11GcrVRnOTg zxs83p0nuj7JNcKDDAvCeh9LIh3gwDH12TBX/bFJx3UjyQaKjiW1LLcBWBCaWHTdYlav uLZmLZ/ij4Nozd7UmvlOhuSgyd5BRTmWmPHTuXxkcZNPLSiI5OxeNqr8GstJ6mn+yM7y sVDA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f198si8338524pfa.347.2022.01.22.08.37.46; Sat, 22 Jan 2022 08:38:50 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231531AbiAUWrz convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 Jan 2022 17:47:55 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:46038 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiAUWry (ORCPT ); Fri, 21 Jan 2022 17:47:54 -0500 Received: from smtpclient.apple (p4fefca45.dip0.t-ipconnect.de [79.239.202.69]) by mail.holtmann.org (Postfix) with ESMTPSA id 94A56CED19; Fri, 21 Jan 2022 23:47:52 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [PATCH] Bluetooth: hci_serdev: call init_rwsem() before p->open() From: Marcel Holtmann In-Reply-To: <20220113132704.4354-1-paskripkin@gmail.com> Date: Fri, 21 Jan 2022 23:47:52 +0100 Cc: Johan Hedberg , Luiz Augusto von Dentz , lukas@wunner.de, BlueZ , linux-kernel@vger.kernel.org, Yiru Xu Content-Transfer-Encoding: 8BIT Message-Id: References: <20220113132704.4354-1-paskripkin@gmail.com> To: Pavel Skripkin X-Mailer: Apple Mail (2.3693.40.0.1.81) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Pavel, > kvartet reported, that hci_uart_tx_wakeup() uses uninitialized rwsem. > The problem was in wrong place for percpu_init_rwsem() call. > > hci_uart_proto::open() may register a timer whose callback may call > hci_uart_tx_wakeup(). There is a chance, that hci_uart_register_device() > thread won't be fast enough to call percpu_init_rwsem(). > > Fix it my moving percpu_init_rwsem() call before p->open(). > > INFO: trying to register non-static key. > The code is fine but needs lockdep annotation, or maybe > you didn't initialize this object before use? > turning off the locking correctness validator. > CPU: 2 PID: 18524 Comm: syz-executor.5 Not tainted 5.16.0-rc6 #9 > ... > Call Trace: > > __dump_stack lib/dump_stack.c:88 [inline] > dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 > assign_lock_key kernel/locking/lockdep.c:951 [inline] > register_lock_class+0x148d/0x1950 kernel/locking/lockdep.c:1263 > __lock_acquire+0x106/0x57e0 kernel/locking/lockdep.c:4906 > lock_acquire kernel/locking/lockdep.c:5637 [inline] > lock_acquire+0x1ab/0x520 kernel/locking/lockdep.c:5602 > percpu_down_read_trylock include/linux/percpu-rwsem.h:92 [inline] > hci_uart_tx_wakeup+0x12e/0x490 drivers/bluetooth/hci_ldisc.c:124 > h5_timed_event+0x32f/0x6a0 drivers/bluetooth/hci_h5.c:188 > call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421 > > Fixes: d73e17281665 ("Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops") > Reported-by: Yiru Xu > Signed-off-by: Pavel Skripkin > --- > drivers/bluetooth/hci_serdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel