Skip to content

Commit 6f36f8a

Browse files
committed
ll: Fix use after free in ble_ll_isoal_mux_free
mbuf needs to be removed from pkthdr list before being freed. Otherwise sdu_q list will operate on invalid data.
1 parent f71333a commit 6f36f8a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

nimble/controller/src/ble_ll_isoal.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,19 @@ void
6060
ble_ll_isoal_mux_free(struct ble_ll_isoal_mux *mux)
6161
{
6262
struct os_mbuf_pkthdr *pkthdr;
63-
struct os_mbuf *om;
64-
struct os_mbuf *om_next;
6563

6664
pkthdr = STAILQ_FIRST(&mux->sdu_q);
6765
while (pkthdr) {
68-
om = OS_MBUF_PKTHDR_TO_MBUF(pkthdr);
66+
/* remove from list before freeing om */
67+
STAILQ_REMOVE_HEAD(&mux->sdu_q, omp_next);
6968

70-
while (om) {
71-
om_next = SLIST_NEXT(om, om_next);
72-
os_mbuf_free(om);
73-
om = om_next;
74-
}
69+
os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(pkthdr));
7570

76-
STAILQ_REMOVE_HEAD(&mux->sdu_q, omp_next);
7771
pkthdr = STAILQ_FIRST(&mux->sdu_q);
7872
}
7973

8074
STAILQ_INIT(&mux->sdu_q);
75+
mux->sdu_q_len = 0;
8176
}
8277

8378
void

0 commit comments

Comments
 (0)