Commit 25f420a
Bluetooth: L2CAP: Fix ERTM re-init and zero pdu_len infinite loop
l2cap_config_req() processes CONFIG_REQ for channels in BT_CONNECTED
state to support L2CAP reconfiguration (e.g. MTU changes). However,
since both CONF_INPUT_DONE and CONF_OUTPUT_DONE are already set from
the initial configuration, the reconfiguration path falls through to
l2cap_ertm_init(), which re-initializes tx_q, srej_q, srej_list, and
retrans_list without freeing the previous allocations and sets
chan->sdu to NULL without freeing the existing skb. This leaks all
previously allocated ERTM resources.
Additionally, l2cap_parse_conf_req() does not validate the minimum
value of remote_mps derived from the RFC max_pdu_size option. A zero
value propagates to l2cap_segment_sdu() where pdu_len becomes zero,
causing the while loop to never terminate since len is never
decremented, exhausting all available memory.
Fix the double-init by skipping l2cap_ertm_init() and
l2cap_chan_ready() when the channel is already in BT_CONNECTED state,
while still allowing the reconfiguration parameters to be updated
through l2cap_parse_conf_req(). Also add a pdu_len zero check in
l2cap_segment_sdu() as a safeguard.
Fixes: 96298f6 ("Bluetooth: L2CAP: handle l2cap config request during open state")
Signed-off-by: Hyunwoo Kim <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>1 parent 00fdebb commit 25f420a
1 file changed
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2398 | 2398 | | |
2399 | 2399 | | |
2400 | 2400 | | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
2401 | 2404 | | |
2402 | 2405 | | |
2403 | 2406 | | |
| |||
4333 | 4336 | | |
4334 | 4337 | | |
4335 | 4338 | | |
4336 | | - | |
4337 | | - | |
4338 | | - | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
4339 | 4343 | | |
4340 | | - | |
4341 | | - | |
4342 | | - | |
4343 | | - | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
4344 | 4349 | | |
4345 | 4350 | | |
4346 | 4351 | | |
| |||
0 commit comments