Linux bluetooth development
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v3 5/6] monitor: Fix RFCOMM UIH frame length and credit-only handling
Date: Tue, 24 Nov 2026 10:22:46 +0100	[thread overview]
Message-ID: <20261124092248.207565-6-frederic.danis@collabora.com> (raw)
In-Reply-To: <20261124092248.207565-1-frederic.danis@collabora.com>

rfcomm_packet() consumed the trailing 1-byte FCS via a separate
tmp_frame view over the same bytes, but never trimmed it from
l2cap_frame itself, so the FCS byte was still included in the
payload handed to uih_frame()/mcc_frame(). For OBEX traffic this
showed up as a spurious trailing byte once the OBEX decoder started
enforcing PDU lengths strictly; drop the byte from l2cap_frame->size
right after it is read.

uih_frame() also handed credit-only UIH frames (an RFCOMM credit flow
control update carrying no information payload, size 0 once the
optional credits octet is consumed) to the OBEX channel check and
decoder, which could misdecode them as a 0-length OBEX PDU. Skip
decoding entirely when no payload bytes remain.

Assisted-by: Claude:claude-sonnet-5
---
v2-v3: New in v3.

 monitor/rfcomm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index d830684a9..8a44a2199 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -404,6 +404,12 @@ static bool uih_frame(struct rfcomm_frame *rfcomm_frame, uint8_t indent)
 		print_field("%*cCredits: %d", indent, ' ', hdr->credits);
 	}
 
+	/* A credit-only UIH frame (credit-based flow control update)
+	 * carries no information payload; nothing to decode.
+	 */
+	if (!frame->size)
+		return true;
+
 	if (obex_channel(frame->index, frame->handle, channel, NULL))
 		obex_packet(frame, channel, frame->size);
 	else
@@ -467,6 +473,13 @@ void rfcomm_packet(const struct l2cap_frame *frame)
 	if (!l2cap_frame_get_u8(&tmp_frame, &hdr.fcs))
 		goto fail;
 
+	/* The trailing FCS byte just consumed via tmp_frame is still
+	 * included in l2cap_frame's size (tmp_frame is a separate view
+	 * over the same bytes). Drop it so the information payload
+	 * handed to uih_frame()/mcc_frame() doesn't include it.
+	 */
+	l2cap_frame->size -= 1;
+
 	/* Decoding frame type */
 	ctype = RFCOMM_GET_TYPE(hdr.control);
 
-- 
2.43.0


  parent reply	other threads:[~2026-11-24  9:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  9:22 [PATCH BlueZ v3 0/6] monitor: Add an OBEX protocol decoder to btmon Frédéric Danis
2026-11-24  9:22 ` [PATCH BlueZ v3 1/6] monitor: Strip trailing L2CAP FCS before upper layer dissectors Frédéric Danis
2026-11-24  9:22 ` [PATCH BlueZ v3 2/6] monitor: Add OBEX protocol decoder Frédéric Danis
2026-11-24  9:22 ` [PATCH BlueZ v3 3/6] monitor: Decode PBAP/MAP/BIP Application Parameters tags Frédéric Danis
2026-11-24  9:22 ` [PATCH BlueZ v3 4/6] monitor: Reassemble L2CAP ERTM/Streaming SDUs Frédéric Danis
2026-11-24  9:22 ` Frédéric Danis [this message]
2026-11-24  9:22 ` [PATCH BlueZ v3 6/6] monitor: Reassemble OBEX PDUs split across RFCOMM UIH frames Frédéric Danis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124092248.207565-6-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox