Venkateswara Naralasetty <quic_vnaralas@xxxxxxxxxxx> writes: > Currently there is no validation on the spectral/CFR report > over the db ring buffers from the hardware. Improper/incomplete > DMA by the target can result in invalid data received by host. > Due to this we may populate incorrect data to user space. > > This buffer validation support fix this issues by filling some > magic value in the buffer during buffer replenish and check for > the magic value in the buffer received by the target. If host > detect magic value in the received buffer it will drop the buffer. > > Tested-on: IPQ8074 WLAN.HK.2.4.0.1-01467-QCAHKSWPL_SILICONZ-1 > > Signed-off-by: Venkateswara Naralasetty <quic_vnaralas@xxxxxxxxxxx> > --- > v2: > * Rebased on TOT > > drivers/net/wireless/ath/ath11k/dbring.c | 32 ++++++++++++++++++++++++++++++ > drivers/net/wireless/ath/ath11k/dbring.h | 1 + > drivers/net/wireless/ath/ath11k/spectral.c | 10 ++++++++++ > 3 files changed, 43 insertions(+) > > diff --git a/drivers/net/wireless/ath/ath11k/dbring.c b/drivers/net/wireless/ath/ath11k/dbring.c > index 31cf7ac..5c07442 100644 > --- a/drivers/net/wireless/ath/ath11k/dbring.c > +++ b/drivers/net/wireless/ath/ath11k/dbring.c > @@ -6,6 +6,37 @@ > #include "core.h" > #include "debug.h" > > +#define ATH11K_DB_MAGIC_VALUE 0xdeadbeaf > + > +int ath11k_dbring_validate_buffer(struct ath11k *ar, void *buffer, u32 size) > +{ > + u32 *temp; > + int idx; > + > + size = size >> 2; > + > + for (idx = 0, temp = buffer; idx < size; idx++, temp++) { > + if (*temp == ATH11K_DB_MAGIC_VALUE) { > + ath11k_warn(ar->ab, "found magic value in the buffer\n"); I moved the warning message to the callers to make it easier to identify where the corruption is happening and also added the word "dropping" to make the message clearer for the user. https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=6c90df4c7aca225c4c486f31ca956ae6c08abe59 -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches