Skip to content

ofdm: UN_SYNC resets rxbufst, as the sync state machine does - #80

Open
nkgoodall wants to merge 1 commit into
drowe67:mainfrom
nkgoodall:fix/ofdm-unsync-rxbufst
Open

nkgoodall wants to merge 1 commit into
drowe67:mainfrom
nkgoodall:fix/ofdm-unsync-rxbufst

Conversation

@nkgoodall

Copy link
Copy Markdown

Fixes the out-of-bounds read described in #79.

ofdm_set_sync(UN_SYNC) reset the sync state machine to search and zeroed rxbuf, but left rxbufst where it was. After a postamble sync — which backs rxbufst up by np * samplesperframe to the start of the packet — the position sat below its normal search value. A second UN_SYNC while the decoder was in trial froze it there, and the next postamble detection subtracted another np * samplesperframe: rxbufst went below rxbuf and burst acquisition read outside the buffer (ASan SEGV in est_timing_and_freq via ofdm_sync_search_burst).

UN_SYNC now sets rxbufst = nrxbufhistory, the same reset the sync state machine itself does on its other two returns to search.

The reproducer in #79 is public-API-only and deterministic: on stock main it SEGVs within three bursts; with this line it runs to completion with no ASan report.

Diagnosis by Rafael Diniz; the original find was in Rhizomatica's Mercury (PR #455, fixed there in #457, shipped in 1.9.22).

Co-authored-by: Rafael Diniz rafael@riseup.net

ofdm_set_sync(UN_SYNC) reset sync_state to search and zeroed rxbuf but
left rxbufst where it was.  After a postamble sync -- which backs rxbufst
up by np * samplesperframe to the start of the packet -- the position sat
below its normal search value, and a second UN_SYNC while the decoder was
in trial froze it there.  The next postamble detection then subtracted
another np * samplesperframe: rxbufst went below rxbuf and burst
acquisition read outside the buffer (ASan SEGV in est_timing_and_freq via
ofdm_sync_search_burst).

UN_SYNC now sets rxbufst = nrxbufhistory, the same reset the state
machine itself does on its other two returns to search.  Deterministic
public-API reproducer and diagnosis in drowe67#79.

Co-authored-by: Rafael Diniz <rafael@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant