aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdch.h
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-06-30 16:03:06 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2021-07-01 13:09:10 +0200
commit4f67a9bf4610c9e948f0d81f3b039f36675180a3 (patch)
treebf7f2aca513c0df2f2eaf2f4772a779e2558898b /src/pdch.h
parent1989a190664ca1d4169c80336b2ecc00426c84f1 (diff)
pdch: Fix heap-use-after-free in pdch->ulc
In existing previous code, pdch->ulc would be freed in gprs_rlcmac_pdch::free_resources() when it became disabled as per PCUIF info_ind (for instance, when a DYN TS is switched PDCH->SDCCH8). However, pdch->ulc was so far only allocated during pdch_init, which is only called during bts_alloc() time. Hence, after first info_ind disabling it, if it became again enabled (again by info_ind re-enabling it after SDCCH8 was not longer in use), the pdch->ulc would be used again but it would point to freed memory. Let's rearrange how/when resources are freed to make it more logical. With this patch, pdch internal resources are freed upon ->disable(), and re-allocated upon ->enable(). Change-Id: Id51f5f6a54ac9f24b784c17bc360ac38f5726fc7
Diffstat (limited to 'src/pdch.h')
-rw-r--r--src/pdch.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pdch.h b/src/pdch.h
index cfa0195f..00f0b9d6 100644
--- a/src/pdch.h
+++ b/src/pdch.h
@@ -55,8 +55,6 @@ struct gprs_rlcmac_pdch {
bool add_paging(uint8_t chan_needed, const struct osmo_mobile_identity *mi);
- void free_resources();
-
bool is_enabled() const;
void enable();
@@ -145,6 +143,8 @@ private:
enum gprs_rlcmac_tbf_direction dir);
gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi,
enum gprs_rlcmac_tbf_direction dir);
+
+ void free_resources();
#endif
uint8_t m_num_tbfs[2];
@@ -191,6 +191,7 @@ extern "C" {
void pdch_init(struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_trx *trx, uint8_t ts_nr);
void pdch_free_all_tbf(struct gprs_rlcmac_pdch *pdch);
void pdch_disable(struct gprs_rlcmac_pdch *pdch);
+bool pdch_is_enabled(const struct gprs_rlcmac_pdch *pdch);
#ifdef __cplusplus
}
#endif