Bluetooth: RFCOMM: Validate MTU in rfcomm_apply_pn() to prevent infinite loop
authorHyunwoo Kim <imv4bel@gmail.com>
Thu, 19 Mar 2026 15:14:58 +0000 (00:14 +0900)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 24 Aug 2026 17:13:13 +0000 (13:13 -0400)
commit44c98fd082eafd49d55a8a4077ff488175b2fe24
tree46360294b5c3a10efc57fd338b08f67155ca710d
parent560bef609fa5992745929e8d7d458b9d88dd2830
Bluetooth: RFCOMM: Validate MTU in rfcomm_apply_pn() to prevent infinite loop

rfcomm_apply_pn() accepts the MTU value from a remote PN (Parameter
Negotiation) frame without checking for zero. When the remote peer
sends an MTU of zero, d->mtu is set to 0. This causes the sendmsg
path to enter an infinite loop when fragmenting data, as each fragment
has size == min_t(size_t, len, 0) == 0, so the remaining length never
decreases. The infinite allocation of zero-length skbs exhausts all
system memory.

Fix by clamping d->mtu to RFCOMM_DEFAULT_MTU when the negotiated
value is zero, consistent with the initial value assigned in
rfcomm_dlc_alloc().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/rfcomm/core.c