Skip to content

Fix Clang CFI icall type mismatch in rd_list_remove_cmp and string comparators - #5557

Open
Eric Xu (EricFXU) wants to merge 4 commits into
confluentinc:masterfrom
EricFXU:fix-cfi-errors-librd-kafka
Open

Fix Clang CFI icall type mismatch in rd_list_remove_cmp and string comparators#5557
Eric Xu (EricFXU) wants to merge 4 commits into
confluentinc:masterfrom
EricFXU:fix-cfi-errors-librd-kafka

Conversation

@EricFXU

@EricFXU Eric Xu (EricFXU) commented Jul 28, 2026

Copy link
Copy Markdown

Problem

Under Clang Control Flow Integrity (-fsanitize=cfi-icall), function pointer signatures at indirect call sites must match the target function parameter types exactly.

Passing (void *)strcmp or comparators without const parameters to rd_list_remove_cmp and rd_list_find causes Clang CFI to flag due to type mismatches between int (*)(void *, void *) and int (*)(const void *, const void *).

Fix

  1. Updated rd_list_remove_cmp and rd_list_remove_multi_cmp signatures in src/rdlist.h and src/rdlist.c to accept int (*cmp)(const void *_a, const void *_b).
  2. Replaced (void *)strcmp function pointer casts with rd_list_cmp_str in src/rdkafka_metadata.c, src/rdkafka_partition.c, src/rdkafka_topic.c, and src/rdkafka_sasl_oauthbearer.c.

@EricFXU
Eric Xu (EricFXU) requested a review from a team as a code owner July 28, 2026 19:50
@confluent-cla-assistant

confluent-cla-assistant Bot commented Jul 28, 2026

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ EricFXU
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR Eric Xu (@EricFXU).
I've added a few comments.
Once those are addressed we can run the CI and see if anything else comes up.

Comment thread src/rdlist.h
Comment thread src/rdkafka_metadata.c Outdated
@Ankith-Confluent

Copy link
Copy Markdown
Member

/sem-approve

@Ankith-Confluent

Copy link
Copy Markdown
Member

Hi Eric Xu (@EricFXU)
There are few style fixes
Could you run make style-fix to resolve it.

@EricFXU

Eric Xu (EricFXU) commented Aug 6, 2026

Copy link
Copy Markdown
Author

Hi Ankith L (@Ankith-Confluent), I had installed the wrong version of cmake (pip install installed 18.1.18), and I realized style-format.sh only checks the major version number is set to 18. With the help of AI, checked and confirmed the dockerfile's image has ubuntu:24.04 , which uses 18.1.3 version. After installing this version, I think the make style-fix runs the right format. Please LMK if this doesn't pass and I can try something else.

Also, could you please help answer when we can expect this fix to be released?

@Ankith-Confluent

Copy link
Copy Markdown
Member

/sem-approve

@Ankith-Confluent

Copy link
Copy Markdown
Member

Hey Eric Xu (@EricFXU)
The dates on the release is not finalised yet, but it should be by the end of the month.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR Eric Xu (@EricFXU)
LGTM!

We will be merging it after another round of review.

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.

2 participants