From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 DF114382397 for ; Tue, 21 Apr 2026 11:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776772438; cv=none; b=mxGh+szAl9fCjeu6G1GnsNIMDlMYHqUpxnHWYD8Mvx/CuYUc+zuEZYQVkh9hpwjH7/yIC2v/4sXbRoW6sO/9E2QiqWj/4roTV9/fbJx1ldMCmmZneoaZG4o1gpxLzcdn3GV3KC7RemztkfW2u+0M99X/BzA6cioe2/HxwWNrVL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776772438; c=relaxed/simple; bh=yxMnjb7Q/aVt42qFmyhSxlpTh87sBoktrFRyOjtdA34=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QSvIl69ivYnt6hlP0EcN1NatHCOH4oiz0NCqFMNWphjJCB2ZwN9gmwo7t5prhRg1TY5Ez/6lOFgAf4Tnyhbwswi0uaKPlgQRSaiFCNaxzZXwRS63aZBOsu9ujAuuh+nMekOqA8yfW4pwNQFrrQe5OQLHE8yAMLPwdSG631y4Aj4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hackers.camp; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hackers.camp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4836fc075d2so3090325e9.0 for ; Tue, 21 Apr 2026 04:53:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776772435; x=1777377235; 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=O/OjdGnv+jUltTzO6oNyOl9eOSq15AA1fhn11BjFGWs=; b=r+rdLeODpW7me6ARTNtTAuIiytRflLeUlFdKGkPRYp/UEUOiU5zZhjyU8iINkDl7BA ZHhikPk3ZOzxNG/3yk0oPdu92dnQRY/4aspnQl11dBFVbH1ugJ2xWGIoEofyNZhD8TCL n4Y0I0TEevPCv1fqe9ONP4aZw7h2cZRhAy7nhlrqR0XeVYVUCrQdoBH6RFl1T6LszcYq nHbXwTur7eZHC4asXI6Y4FZfBMY8wJsNGXXCp1VyifTd/DURYqdax0PmDT2Sa7YZ1CyU lK4eSBKsnz/Wu3N/j+m2PepG92SJ0hHsF1PIOkQrGqnUIeuxz6jnb8IBH9HKz7wf4I3b Df7g== X-Forwarded-Encrypted: i=1; AFNElJ91Nn2HtIUKBUCmjykRC8rM4UygqotJtWhRrdo9eo2PXyqRObcnV+oYMICqZ0A1GuYXes49wyGR0N97pC0=@vger.kernel.org X-Gm-Message-State: AOJu0Yyx0H3v67NVPsWFvAS+laL3KFiCeRVEh5gaEaEPJOVZmUv9OXl8 BpdKFnWngXr5PaHAxkM1mh1kicgOnYs6deHULfKs7tqy29a9xMcRlMCkZVfhkK5W X-Gm-Gg: AeBDiesrLOrC1G5Q0UxmTDzRcrJ0oqaUNwvE9u3eJOOfa4od0f6plVDFYCza2fZCt7h rBRAsz0z5KZbxrK0s1M32KC0wqNLz3iMVMtEKpdyre3RCYpXeubF239tsZ+B6zjKeaDve31hmMY ExoNuXS8ujt1vpgyjpkypW3ImauteVQOJ0qYNTrF+jK1LpKWXzK0/wSQcRZNRErSllcBudp3TJM m19ZguC2QkoykRAWwIuhnydBdoCBvlfllI1vv4EOEW3IYitSDLL8L8rDJqia7g7fsXhP3802Bl5 TEKVChU7O8ddqMQ2jNyhU2D6+lZGhhOo7KM1mdUhgc/mMnHeUlhNNu2rFqDQGzXmegWwcjm5YwD R3LWAcN/we9HIqlRzyA9Ji3qTjR8nQIj7gI5Ax7VUeriXKliy+9CF5W8bpiGwhgMuWqdGBWEuzL fWXoHlozGQ8mTmAaXYDC+51ZrNlCxlrSVFj/bKPW5Ef0iQLobwOn/0ChBw7vEGVe4mZ+iAsFDH+ Jmwo/FNzh4+wA== X-Received: by 2002:a05:600c:c492:b0:48a:5302:8ed9 with SMTP id 5b1f17b1804b1-48a53029075mr39053625e9.0.1776772434933; Tue, 21 Apr 2026 04:53:54 -0700 (PDT) Received: from spartian-1.home ([2a01:cb1c:784:2f00:708:2805:7128:7a75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc0f82bbsm605148105e9.3.2026.04.21.04.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 04:53:54 -0700 (PDT) From: Aurelien DESBRIERES To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, linux-kernel@vger.kernel.org, syzbot+ff30eeab8e07b37d524e@syzkaller.appspotmail.com, Aurelien DESBRIERES Subject: [PATCH] Bluetooth: hci_uart: Fix NULL deref in recv callbacks when priv is uninitialized Date: Tue, 21 Apr 2026 15:53:31 +0200 Message-ID: <20260421135331.15425-1-aurelien@hackers.camp> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When a fault is injected during hci_uart line discipline setup, the proto open() callback may fail leaving hu->priv as NULL. A subsequent TIOCSTI ioctl can trigger the recv() callback before priv is initialized, causing a NULL pointer dereference. Fix all four affected HCI UART protocol drivers by adding a NULL check on hu->priv at the start of their recv() callbacks: h4, h5, ath and bcsp. Reported-by: syzbot+ff30eeab8e07b37d524e@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ff30eeab8e07b37d524e Signed-off-by: Aurelien DESBRIERES Assisted-by: Claude:claude-sonnet-4-6 --- drivers/bluetooth/hci_ath.c | 3 +++ drivers/bluetooth/hci_bcsp.c | 3 +++ drivers/bluetooth/hci_h4.c | 3 +++ drivers/bluetooth/hci_h5.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index fa679ad0acdf..8201fa7f61e8 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -191,6 +191,9 @@ static int ath_recv(struct hci_uart *hu, const void *data, int count) { struct ath_struct *ath = hu->priv; + if (!ath) + return -ENODEV; + ath->rx_skb = h4_recv_buf(hu, ath->rx_skb, data, count, ath_recv_pkts, ARRAY_SIZE(ath_recv_pkts)); if (IS_ERR(ath->rx_skb)) { diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index b386f91d8b46..db56eead27ce 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c @@ -585,6 +585,9 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count) if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) return -EUNATCH; + if (!bcsp) + return -ENODEV; + BT_DBG("hu %p count %d rx_state %d rx_count %ld", hu, count, bcsp->rx_state, bcsp->rx_count); diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index a889a66a326f..767372707498 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -109,6 +109,9 @@ static int h4_recv(struct hci_uart *hu, const void *data, int count) { struct h4_struct *h4 = hu->priv; + if (!h4) + return -ENODEV; + h4->rx_skb = h4_recv_buf(hu, h4->rx_skb, data, count, h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts)); if (IS_ERR(h4->rx_skb)) { diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index cfdf75dc2847..d35383718212 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -587,6 +587,9 @@ static int h5_recv(struct hci_uart *hu, const void *data, int count) struct h5 *h5 = hu->priv; const unsigned char *ptr = data; + if (!h5) + return -ENODEV; + BT_DBG("%s pending %zu count %d", hu->hdev->name, h5->rx_pending, count); -- 2.53.0