From nobody Sat Jul 25 00:11:12 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 B7EFA35DA40 for ; Tue, 21 Jul 2026 21:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669411; cv=none; b=KXYtbCwt2LMaSZecbdFLdZUpNvNrNUByMvlixY6lrlcXqLZVRezTn2jf/rhUuYWs0LDY+zxA67LBEHfoR32DG8npeULE7BU25f6IAL0/vVdXKNMd9NfNVF0+LS6D7MaTzDQb7jaxUBb8PS2NpsDi6TaVo+XDwwyk1GKqAeKx3IM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669411; c=relaxed/simple; bh=P7ujY1EjctEEJ5BiCaydXlUdc5GaBLmNSJjxyuWmsJk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YrMZcpE1FyE4+Izvlczwb8yljm2uLN0O1aaAQEl05l9UVcKIYcFDfiEPIYCHFgt0PxaOweJqS5zhZPQT5AozY9cEGZ8mlJJxs7K8XQ0LLmrtP/XJ666ZcrDUoaa43Vx4jau+zKo6C9IESLxk+CgVyOf2gZ/EAJC3bRo4viiOaTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=T3WJo1Sp; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="T3WJo1Sp" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-47f7444576cso2047890f8f.0 for ; Tue, 21 Jul 2026 14:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1784669408; x=1785274208; 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:content-type; bh=3s/JSUZXhrEE+qb2/7zOa34Br6kcFp6PkK9c5SJgKlI=; b=T3WJo1SptPzmlk/ldenzEcIE2GqeIiJwBqYm1DocSde9Txix6fRcGn2tIWpocS/Z3F 8yHBG3boHSQBSSioe1OsfCMHVhexXDHxLd5NkCQgXFAzRZD3Qi+mP1XIcef9pk8rQb4t 64CrHX9/6PwLnCmPw0GafMTPDc4qDszvl8UlKfK5onTE48pNSLb57l0trC7P8HKaBsDq QHLPURCMCFjMmCDs0Yp8qowj8Qn///BVCFv3Kx/lvZZeu4WsrN0/uSnn4xhxVmm6xh5F 4RN8d7/a9XliGagmN4lj3CEIQquNtRxID6ZvjkMtWfcItQFHqPDCiDcEBPXg2UVvppYM WT2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784669408; x=1785274208; 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:content-type; bh=3s/JSUZXhrEE+qb2/7zOa34Br6kcFp6PkK9c5SJgKlI=; b=NhLmdHbh220Vrvvb8ujMowP6yk0JtysxRP0Sb0HegQduQOo+RHenXCTHEX13p00xD/ rf/aBiGk8F+XLQ3prp25wNKYARPv+wOMtibe6T5cggfr36yrKYdVQZm4YhWkoCr0HIU8 rDPi7oeY/l3OVOzpZFsm6bjjyrjKfAvu95MKVyyA/uvtSzskQRriZ0ZIdAS2JSApBeu8 NY813fcES1ASrF6BF2s3Xr4QbvaUx0lFntUlz7xm9rvbvHqGIkQTl5QsRWcAN26zkx/h IzLSPHQZ3uxO8J4pFqDM9LHpD6vpuotuhE6Y3z3itcHdmHvkhJ0HcQ6GtV2B5f07NtE5 RJVg== X-Forwarded-Encrypted: i=1; AHgh+RrXLkgXU538fn4yAnWp+pUAOnkBOpUj0Kn3BrcSHqZJzMXtPpn6pYo3RTvtqvkzzfANo/JUMmAGTmsduHk=@vger.kernel.org X-Gm-Message-State: AOJu0YweF65/7EbJTTXicBlhLmeJyGLsGU1MQTyLoFL+zJugGY3YuUer 7CZFGn6B0oP5z0tPOuV16WxmJiZOxDqZuOXYzVsl/U5QX+ncP/1t9lMaJIvluVijXN6VVQ4USBk Zh/Qmew== X-Gm-Gg: AR+sD12m0XROnncZpRW31b81ppmMw197wpD8/+zpRrDcI/tYXcwRlEsltgR52lm1dD/ DYHxvqonYgS/6N/j5Uw/p5V3lGQSD9+9ntCNsIoh32mmOdrCKmULl5H02nSFWs7S9mKzJ2V+wUc g/JEoed7Mo9pnB8KXV2+vEjP7UTI8oae0ChURvtizOAWhiJg9UeDn6gpYZiZ/vRsDzUPHb/kiVu 9fA8VpVTRGMhcGm+K9AoP5XNC4dJTgG1LeNgn/asl15QjkHrnmuLAZonAXTv7UUzbSN8PT2SpVh wGerAZ2CmqqITcsG5DmS02Wbyzp1u2e6Dk7YXlICm5Fd8upIbPUBdEI6AdRPLN0/PTAgLZaziNn Ef23CGSUKXo+V0KpVI5Y81pYMY+4ZstWQLpw2clbU0xC0xp+3kAqRfrdU50l5t00ySjEL3Dq5JJ FxfA6LZV+vg5+zxgc493zw02jVQL9rvciO2wZ6F9aizAV+M31cokzBHuyg1xmfaR+hxh+686FA/ QSHF/PXs7S7PiOMlrzEV+8/ X-Received: by 2002:a05:6000:2c10:b0:47d:f023:b4b3 with SMTP id ffacd0b85a97d-47f62328323mr23668481f8f.34.1784669407123; Tue, 21 Jul 2026 14:30:07 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.14]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63e519f4sm40482672f8f.14.2026.07.21.14.30.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 Jul 2026 14:30:06 -0700 (PDT) From: Doruk Tan Ozturk To: Luiz Augusto von Dentz , Marcel Holtmann , Amitkumar Karwar , Neeraj Kale Cc: Paul Menzel , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Doruk Tan Ozturk Subject: [PATCH v3] Bluetooth: btnxpuart: Fix out-of-bounds read in nxp_recv_fw_req_v1() Date: Tue, 21 Jul 2026 23:30:05 +0200 Message-ID: <20260721213005.38581-1-doruk@0sec.ai> 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: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 25c286d75821 ("Bluetooth: btnxpuart: Fix out-of-bounds firmware read in nxp_recv_fw_req_v3()") bounded the v3 firmware download offset but left an unbounded read in the v1 handler. nxp_recv_fw_req_v1() advances a device-driven download offset (fw_dnld_v1_offset) by fw_v1_sent_bytes on every request, and that bookkeeping runs even when the payload write is skipped, so the offset can walk past nxpdev->fw->size. When the controller then requests a header (len =3D=3D HDR_LEN), the driver reads the 16-byte bootloader header at nxp_get_data_len(nxpdev->fw->data + nxpdev->fw_dnld_v1_offset) with no bound on the offset, reading past the end of the firmware image. A malicious or malfunctioning NXP UART controller can drive this to read out-of-bounds kernel memory during firmware download. Bound the offset before the header read, and convert the payload write guard to the overflow-safe form used by the v3 path (fw_dnld_v1_offset is u32, so fw_dnld_v1_offset + len can wrap). Log the offset and firmware size at the reject site to aid debugging of a real device. This was found by 0sec automated security-research tooling (https://0sec.ai). Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP Bluetoot= h chipsets") Cc: stable@vger.kernel.org Reviewed-by: Neeraj Sanjay Kale Assisted-by: 0sec:claude-opus-4-8 Signed-off-by: Doruk Tan Ozturk --- v3: reformat the reject path to stay within the 80-column limit (hoist offset/size to locals, fold the header-request and bounds tests into one guard); no functional change vs v2. Drop expected_len from the log line -- it is always HDR_LEN at the reject site. Shorten the subject to 80 columns. Carries the Reviewed-by, the logic is unchanged. v2: log offset/fw size at the reject site (requested by Neeraj Kale and Paul Menzel). v1: https://lore.kernel.org/linux-bluetooth/20260705115650.81724-1-doruk@0s= ec.ai/ drivers/bluetooth/btnxpuart.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c index 0bb300eef157..423a20f78baa 100644 --- a/drivers/bluetooth/btnxpuart.c +++ b/drivers/bluetooth/btnxpuart.c @@ -1041,6 +1041,16 @@ static int nxp_recv_fw_req_v1(struct hci_dev *hdev, = struct sk_buff *skb) * and we need to re-send the previous header again. */ if (len =3D=3D nxpdev->fw_v1_expected_len) { + u32 off =3D nxpdev->fw_dnld_v1_offset; + size_t sz =3D nxpdev->fw->size; + + if (len =3D=3D HDR_LEN && + (off >=3D sz || sz - off < HDR_LEN)) { + bt_dev_err(hdev, + "FW req OOB: offset %u, size %zu", + off, sz); + goto free_skb; + } if (len =3D=3D HDR_LEN) nxpdev->fw_v1_expected_len =3D nxp_get_data_len(nxpdev->fw->data + nxpdev->fw_dnld_v1_offset); @@ -1053,7 +1063,8 @@ static int nxp_recv_fw_req_v1(struct hci_dev *hdev, s= truct sk_buff *skb) } } =20 - if (nxpdev->fw_dnld_v1_offset + len <=3D nxpdev->fw->size) + if (nxpdev->fw_dnld_v1_offset < nxpdev->fw->size && + len <=3D nxpdev->fw->size - nxpdev->fw_dnld_v1_offset) serdev_device_write_buf(nxpdev->serdev, nxpdev->fw->data + nxpdev->fw_dnld_v1_offset, len); nxpdev->fw_v1_sent_bytes =3D len; --=20 2.43.0