aq(4): Fix OOB write in RSS table packing (no link / panic)#2232
Open
DominoTree wants to merge 2 commits into
Open
aq(4): Fix OOB write in RSS table packing (no link / panic)#2232DominoTree wants to merge 2 commits into
DominoTree wants to merge 2 commits into
Conversation
Fix an out-of-bounds stack write in aq_hw_rss_set(). RSS table entries are 3 bits (8 queues max), but with more than 8 RX rings rss_table[] holds larger values; the 32-bit write then spills one uint16_t past bitary[] and corrupts the stack, so the NIC never links or the kernel panics. Mask each value to 3 bits and pack 16 bits at a time to keep the write in bounds. Confirmed on AQC107 (firmware 3.1.88) under FreeBSD 15.0-RELEASE: with the OOB write the interface attached but stayed "no carrier"; removed, link negotiates 1000baseT full-duplex and passes traffic. Signed-off-by: Nick Price <nick@spun.io>
Author
|
Cross-posted at freebsd/freebsd-ports#522 to fix things for existing users before aq(4) lands |
aq_if_attach_post() built the RSS indirection table with rss_table[i] = i & (rx_rings_count - 1); which assumes rx_rings_count is a power of two. iflib does not guarantee that (queue counts such as 6, 12 or 24 are possible), so the mask left some queues with no entries and skewed the hash distribution. When rx_rings_count was 0 the (count - 1) underflow also turned the mask into a no-op rather than failing safe. Use a modulo over min(rx_rings_count, HW_ATL_RSS_QUEUES_MAX) instead. The redirection-table field is 3 bits wide, so the hardware can only hash across 8 queues regardless of ring count; capping here keeps the table values in range and complements the bounds fix in aq_hw_rss_set(). Signed-off-by: Nick Price <nick@spun.io>
Author
|
(Added a second small commit with another RSS fix) |
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.
Fix an out-of-bounds stack write in aq_hw_rss_set(). RSS table entries are 3 bits (8 queues max), but with more than 8 RX rings rss_table[] holds larger values; the 32-bit write then spills one uint16_t past bitary[] and corrupts the stack, so the NIC never links or the kernel panics. Mask each value to 3 bits and pack 16 bits at a time to keep the write in bounds.
Confirmed on AQC107 (firmware 3.1.88) under FreeBSD 15.0-RELEASE: with the OOB write the interface attached but stayed "no carrier"; removed, link negotiates 1000baseT full-duplex and passes traffic.
cc @emaste