Skip to content

fix(ble_gap): fix NULL deref and use-after-free in ble_gap_rx_rd_rem_ver_info_complete - #1189

Open
tahiraltundag wants to merge 1 commit into
h2zero:release/2.5from
tahiraltundag:fix/nimble-null-deref-ver-info
Open

tahiraltundag wants to merge 1 commit into
h2zero:release/2.5from
tahiraltundag:fix/nimble-null-deref-ver-info

Conversation

@tahiraltundag

Copy link
Copy Markdown

Summary

Fixes #1183

Crash at ble_gap_rx_rd_rem_ver_info_complete when remote version complete arrives after conn is already gone. Original code unlocked, then dereferenced conn without NULL check (panic), and NULL check came after the stores. Also touching conn after unlock is a UAF.

Change

  • Check conn == NULL while holding ble_hs_lock, return early
  • Copy bhc_rd_rem_ver_params and is_master flag while locked, then unlock
  • Mirrors safe pattern in ble_gap_rx_rd_rem_sup_feat_complete
  • File: src/nimble/nimble/host/src/ble_gap.c:2852

Testing

…ver_info_complete

conn was dereferenced after ble_hs_unlock() without NULL check,
and the NULL check came after the stores. If handle is already
gone (disconnect raced rem-ver complete), this panics. Also
touching conn after unlock is a UAF.

Check NULL and copy rem-ver fields while holding lock, save
is_master flag before unlock. Mirrors the safe pattern in
ble_gap_rx_rd_rem_sup_feat_complete.

Fixes h2zero#1183

Signed-off-by: tahiraltundag <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: db78bb2b-b407-4ca2-bf58-591448001dd9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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