From nobody Sun Feb 8 07:07:39 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29C741E2614 for ; Sun, 18 Jan 2026 12:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768738340; cv=none; b=EzKfgv36DFBABeFOZaAh985buZwvBYqtDWEiFfP/mVjioQIC5yNOeMW+dD4vk4+ot8j41Shhm8nYnGP7hwz2+2+WlizuWAErDPoqXbTIhLgW/W5NYTGJSzgfcw2C5Vi4PJNXTsstWQCwizywvDfZVnBjU+K6pGH2DMsHdm530Yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768738340; c=relaxed/simple; bh=N8uOl1EaA/aS69tNWeZPW69lrkXIWIKD+RLBU8Llom4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jxUi1wMcrddeoVa+kKBbF1d65xpSJCFJzSKOQbQakVs6c320EnIsmnqJVJYYFRj6hokLkg7mmMBakHYvjVbFm+p/ktYONfG/LxeRns7TuXGEbC2m394B5FXeSfnhRhneLwO9EYDIAnItrNTrgMue6z+jEgs4+4ODPGfGseojo7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ODYc9bkM; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ODYc9bkM" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-81f3c14027cso1914656b3a.1 for ; Sun, 18 Jan 2026 04:12:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768738338; x=1769343138; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Jo/liQNhmIP33PmLWiQZilkrElIrHhpcOhaaOZJIRQo=; b=ODYc9bkMTAdH9iT+musBSCAioqGRso6tF/ZKh/BrKSUM7vBNiiEdnoTudUxF1XwDcQ tbgeLFfm82RHMoUR9evaORbGRL7taNar6bgKPxndeurNiXXC0IvBBpOc3eWrOBQU4ggL 1e2EccfyuHdvvoKBD27FGr5jusO56K/V9IRtROyEzMO/oIMrIze08hl5IgUimNxf3Iqj ZxdZKrkg52+H/FINYdUjFEqrKKlZDQzS7YRHGdRF/HAtsCbV8XDAH8mwkaHiqWBIi9jM EZ+o4KP/Dqyx+EyDUjEv93dlyLnrZi/+ep0dckvEn4+fKZGnVKEsSmhD0EiYnA5RLGrV 6nqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768738338; x=1769343138; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Jo/liQNhmIP33PmLWiQZilkrElIrHhpcOhaaOZJIRQo=; b=daVyReON5W8gCv7HroLpMoYk3htVlIcsydBf9Qx+0DzMaEfOeUltsn5SeKnIx2RUaC vGCysOUORXdS6g2gmzWt3etv374+7GPK6XSvUU3mfOUVj3NM/EPeo7QMyVS05NbS0pVA cSmw4runsx46J/QXbyAdGjtHQ8xcBIaohQmv60NnYOZFUE9/wcyFxgHSyg3I67zWzi+d QWZAS31fVqG0WEKsx/FgWkDSZCS09jhygWH8CEQdd5ENGkeTN5VQCMz6CezaBRT2C6pm oei+OL4FlKOYlFrv7jyf9tIfwAQPfwvbdKK1QRbtZIBs3s2jF2PSk7zxssQ5xH96TMEm iBEA== X-Forwarded-Encrypted: i=1; AJvYcCWKmNuU9skjyuku+ZaM2gVLpnklDgbCyKn5XvIut3fC+gx0/lU1ycrpIDA1yJkohgMDFxQXHu13+YHwrDo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4i5FYE3u5WmHM5rUw7uSU6m69oP3dSZ7u572W5/rIh9rzLZjA U1tN/Nu9oaL7SONDxaG5+pfDCvd5u15UMyi0lofO4EWD4jr4VzbjzbKW X-Gm-Gg: AY/fxX4xU4RMok0HCKigYyu8EULUij7I3Ej4az/t8KVteu0TyB9qUrsuKe1J8IYb0jK 1Ql5b2IPl7kEMkogT4QRbucSI7BRCp2Ue+hrLxLyAcY8ga4CQVbDhe8XI7HDLihJjbgZNNeuK0N JbUKoSBxBsB00wPU8pWxhNscRDUb2wy6kBtbRwIeGmdmglWZ+3J4nmbybRxCWll7w0zIEY33EWr 7itKxaJlhBfeAaSlLhYagh37mlUms2wimbZr0r/iIehtT67+pYXpSZTtw69wnHj1PyDSbgb20nc qjQ4qyRCZhTXZXz1ixNaFYggVWV8e4UoYOiysM02f/MoS7M+DMTPVo/q6zIfmBS3C5r+28vhmkt 9iYQKtw79bSMItJYYpG4odCxhP5FQOvjI+tHrw9e5Sbdsv/lGpJe7IcjudwP1aHQalZyEiZGYwc /07Y34MxaQpWw1XqQnpkWZENfgTLdZQ9fANc+WCllJrYJG4sXcfzTu4Rd7uQGNEyTO X-Received: by 2002:a05:6a00:a86:b0:7f1:2aac:b75f with SMTP id d2e1a72fcca58-81fa07549d1mr6531317b3a.30.1768738338396; Sun, 18 Jan 2026 04:12:18 -0800 (PST) Received: from localhost.localdomain (118-167-220-133.dynamic-ip.hinet.net. [118.167.220.133]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-81fa10c3721sm6566721b3a.23.2026.01.18.04.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 04:12:17 -0800 (PST) From: Jia-Hong Su To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Hong Su Subject: [PATCH] Bluetooth: hci_uart: fix null-ptr-deref in hci_uart_write_work Date: Sun, 18 Jan 2026 20:08:59 +0800 Message-Id: <20260118120859.83680-1-s11242586@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hci_uart_set_proto() sets HCI_UART_PROTO_INIT before calling hci_uart_register_dev(), which calls proto->open() to initialize hu->priv. However, if a TTY write wakeup occurs during this window, hci_uart_tx_wakeup() may schedule write_work before hu->priv is initialized, leading to a NULL pointer dereference in hci_uart_write_work() when proto->dequeue() accesses hu->priv. The race condition is: CPU0 CPU1 ---- ---- hci_uart_set_proto() set_bit(HCI_UART_PROTO_INIT) hci_uart_register_dev() tty write wakeup hci_uart_tty_wakeup() hci_uart_tx_wakeup() schedule_work(&hu->write_work) proto->open(hu) // initializes hu->priv hci_uart_write_work() hci_uart_dequeue() proto->dequeue(hu) // accesses hu->priv (NULL!) Fix this by moving set_bit(HCI_UART_PROTO_INIT) after proto->open() succeeds, ensuring hu->priv is initialized before any work can be scheduled. Fixes: 5df5dafc171b ("Bluetooth: hci_uart: Fix another race during initiali= zation") Link: https://lore.kernel.org/linux-bluetooth/6969764f.170a0220.2b9fc4.35a7= @mx.google.com/ Signed-off-by: Jia-Hong Su --- drivers/bluetooth/hci_ldisc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index d0adae3267b4..2b28515de92c 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -685,6 +685,8 @@ static int hci_uart_register_dev(struct hci_uart *hu) return err; } =20 + set_bit(HCI_UART_PROTO_INIT, &hu->flags); + if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) return 0; =20 @@ -712,8 +714,6 @@ static int hci_uart_set_proto(struct hci_uart *hu, int = id) =20 hu->proto =3D p; =20 - set_bit(HCI_UART_PROTO_INIT, &hu->flags); - err =3D hci_uart_register_dev(hu); if (err) { return err; --=20 2.34.1