Repository navigation
cyw43: add the missing padding before BssInfo::ie_length - #7601
Open
modelmiser wants to merge 1 commit into
Open
modelmiser wants to merge 1 commit into
modelmiser wants to merge 1 commit into
Conversation
wl_bss_info_t v109 (brcmfmac's brcmf_bss_info_le) is naturally aligned: ie_offset at 116, two pad bytes, ie_length at 120, SNR at 124, sizeof 128. BssInfo is repr(C, packed(2)) and names every other alignment pad explicitly but not this one, so ie_length was read at 118 (the real value shifted up by 16 bits: 0x014C0000 for 332) and snr at 122 (the high half of ie_length, always 0). Add the two bytes, and two bytes of tail padding so SIZE is 128 like the C struct. SIZE is public, so this is a breaking change. Tests pin the offsets and decode a firmware-layout record. Reported with the fix in embassy-rs#3164 by plugwash. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
👋 Welcome, @modelmiser, and thanks for opening your first pull request here! If you haven't already, please give the contributor guide a read. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BssInfomirrors the firmware'swl_bss_info_tversion 109 (Linux brcmfmac'sstruct brcmf_bss_info_le). That C struct is not packed, so two bytes of padding sit betweenie_offset(offset 116) andie_length(offset 120), withSNRat 124 andsizeof128. The Rust struct isrepr(C, packed(2))and names the other alignment pads explicitly (reserved1…reserved4) but not this one, soie_lengthis read at 118 andsnrat 122.Effect before this change: with the pad bytes zero,
ie_lengthcomes out as the real length shifted up by 16 bits (332 bytes of IEs read as 0x014C0000, the value @plugwash measured in #3164), andsnrreads the high half ofie_length, i.e. 0.This adds the two bytes, as they proposed there, plus two bytes of tail padding so the struct is 128 bytes like the C one.
BssInfo::SIZEgoes from 124 to 128, and with it the array length in the publicfrom_bytes/from_bytes_mut/to_bytes.ie_offset,ie_lengthorsnr.BssInfo::SIZEis the minimum record lengthScanResults::parseandBssInfo::parseaccept and the number of bytes copied into the event, so a scan event whose record is shorter than 128 bytes is dropped (the floor was 124). The CYW43439 reportsie_offset128, so its records are at least that long.size_of::<events::Message>()goes from 140 to 144; the event queue holds two.offset_of!pins the three fields at 116 / 120 / 124 and the size at 128, and a record laid out like the C struct decodesie_length332 andsnr25. Both fail without the pad beforeie_length. CI does not run them (.github/ci/test.shhas no cyw43 entry); I can addcargo test --manifest-path ./cyw43/Cargo.toml --libthere if you want.ie_lengthreads 150–394 on real scan results, and the record'slength - ie_offsetequalsie_lengthrounded up to a multiple of 4. The CYW4373 and CYW43455 share this struct and were not tested; the driver does not check the record'sversion.Related: #3164.
🤖 Generated with Claude Code