qcacmn: Race condition while using pkt log buffer
There can be a race condition if two different threads use the pkt log buffer at the same time. This issue can lead to Use-After-Free of the packet log buffer. To address this issue, protect the pktlog buffer access using spinlock. Change-Id: I75d9375c9d85ac26dab1c06658d3f0fdbeb62935 CRs-Fixed: 2034486
这个提交包含在:

提交者
Sandeep Puligilla

父节点
8d88af5f32
当前提交
485d594ea1
@@ -457,6 +457,7 @@ int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
|
||||
|
||||
}
|
||||
|
||||
spin_lock_bh(&pl_info->log_lock);
|
||||
pl_info->buf->bufhdr.version = CUR_PKTLOG_VER;
|
||||
pl_info->buf->bufhdr.magic_num = PKTLOG_MAGIC_NUM;
|
||||
pl_info->buf->wr_offset = 0;
|
||||
@@ -465,6 +466,7 @@ int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
|
||||
pl_info->buf->bytes_written = 0;
|
||||
pl_info->buf->msg_index = 1;
|
||||
pl_info->buf->offset = PKTLOG_READ_OFFSET;
|
||||
spin_unlock_bh(&pl_info->log_lock);
|
||||
|
||||
pl_info->start_time_thruput = os_get_timestamp();
|
||||
pl_info->start_time_per = pl_info->start_time_thruput;
|
||||
@@ -542,12 +544,14 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spin_lock_bh(&pl_info->log_lock);
|
||||
if (pl_info->buf != NULL) {
|
||||
if (pl_dev->is_pktlog_cb_subscribed &&
|
||||
wdi_pktlog_unsubscribe(pdev_txrx_handle,
|
||||
pl_info->log_state)) {
|
||||
pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
|
||||
printk("Cannot unsubscribe pktlog from the WDI\n");
|
||||
spin_unlock_bh(&pl_info->log_lock);
|
||||
return -EFAULT;
|
||||
}
|
||||
pktlog_release_buf(pdev_txrx_handle);
|
||||
@@ -560,6 +564,7 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
|
||||
pl_info->buf_size = size;
|
||||
}
|
||||
pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
|
||||
spin_unlock_bh(&pl_info->log_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户