Skip to content

app: validate repair tile link count limits#8498

Open
two-heart wants to merge 1 commit intofiredancer-io:mainfrom
two-heart:shred-layout-cap
Open

app: validate repair tile link count limits#8498
two-heart wants to merge 1 commit intofiredancer-io:mainfrom
two-heart:shred-layout-cap

Conversation

@two-heart
Copy link
Contributor

Reject firedancer configs with shred_tile_count>16 or sign_tile_count>17 to prevent repair init out-of-bounds writes. No really a likely real world config, but we should not oob in any case.

Reject firedancer configs with shred_tile_count>16 or sign_tile_count>17 to prevent repair init out-of-bounds writes. No really a likely real world config, but we should not oob in any case.
Copilot AI review requested due to automatic review settings February 26, 2026 18:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds defensive validation for Firedancer configs to prevent repair tile link-count misconfiguration that could lead to out-of-bounds writes during repair initialization.

Changes:

  • Introduces max constants for repair-related shred/sign link limits.
  • Validates layout.shred_tile_count <= 16 when is_firedancer is set.
  • Validates firedancer.layout.sign_tile_count <= 17 when is_firedancer is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +544 to +546
if( FD_UNLIKELY( config->firedancer.layout.sign_tile_count > (FD_REPAIR_MAX_SIGN_LINK_CNT + 1U) ) ) {
FD_LOG_ERR(( "`firedancer.layout.sign_tile_count` must be <= %u", FD_REPAIR_MAX_SIGN_LINK_CNT + 1U ));
}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sign tile limit is expressed as FD_REPAIR_MAX_SIGN_LINK_CNT + 1U, but the macro name/value (16) represents link count while the config field is a tile count. This is easy to misread as an off-by-one bug. Consider defining a dedicated constant for the config upper bound (e.g., FD_REPAIR_MAX_SIGN_TILE_CNT = 17) and/or add a short comment explaining why one extra sign tile is allowed (e.g., sign tile 0 is not wired to repair).

Copilot uses AI. Check for mistakes.
Comment on lines +457 to +458
#define FD_REPAIR_MAX_SHRED_LINK_CNT (16U)
#define FD_REPAIR_MAX_SIGN_LINK_CNT (16U)
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These max values duplicate the repair tile’s fixed-size arrays (e.g., MAX_SHRED_TILE_CNT / MAX_SIGN_TILE_CNT in src/discof/repair/fd_repair_tile.c). Keeping separate constants here risks drift (config could allow values that later OOB in the tile, or reject valid ones) if the repair tile limits change. Consider moving the limits into a shared header (or exported fd_repair_* constant) and referencing that from both the repair tile and config validation.

Copilot uses AI. Check for mistakes.
} \
} while(0)

#define FD_REPAIR_MAX_SHRED_LINK_CNT (16U)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a good place for this. Just FD_TEST them in the repair tile where it assigns to the arrays

Copy link
Contributor

@mmcgee-jump mmcgee-jump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

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.

3 participants