Skip to content

[sanitizer][CFI] Add support to build CFI with sanitize-coverage #131296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

Mephistophiles
Copy link
Contributor

Added ability to build together with -fsanitize=cfi and
-fsanitize-coverage=trace-cmp at the same time.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@Mephistophiles
Copy link
Contributor Author

This is RFC PR: It seems very likely that having CFI instrumentation should not interfere with coverage instrumentation. But I am not completely sure. If these patch look good, please accept this commit.

@Mephistophiles Mephistophiles marked this pull request as ready for review March 14, 2025 09:32
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Mar 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Maxim Zhukov (Mephistophiles)

Changes

Added ability to build together with -fsanitize=cfi and
-fsanitize-coverage=trace-cmp at the same time.


Full diff: https://github.com/llvm/llvm-project/pull/131296.diff

1 Files Affected:

  • (modified) clang/lib/Driver/SanitizerArgs.cpp (+2-1)
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 6e75001585c61..3c7cd562a14e3 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -54,7 +54,8 @@ static const SanitizerMask SupportsCoverage =
     SanitizerKind::FuzzerNoLink | SanitizerKind::FloatDivideByZero |
     SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack |
     SanitizerKind::Thread | SanitizerKind::ObjCCast | SanitizerKind::KCFI |
-    SanitizerKind::NumericalStability | SanitizerKind::Vptr;
+    SanitizerKind::NumericalStability | SanitizerKind::Vptr |
+    SanitizerKind::CFI;
 static const SanitizerMask RecoverableByDefault =
     SanitizerKind::Undefined | SanitizerKind::Integer |
     SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |

Added ability to build together with -fsanitize=cfi and
-fsanitize-coverage=trace-cmp at the same time.
@vitalybuka vitalybuka self-requested a review March 14, 2025 19:02
@Mephistophiles
Copy link
Contributor Author

Hi @vitalybuka! Should I wait @kstoimenov approval?

@Mephistophiles
Copy link
Contributor Author

@vitalybuka friendly ping

@Mephistophiles
Copy link
Contributor Author

@vitalybuka ping :) Can I merge this PR?

@chestnykh chestnykh self-requested a review April 2, 2025 11:12
Copy link
Contributor

@chestnykh chestnykh left a comment

Choose a reason for hiding this comment

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

LGTM

@chestnykh
Copy link
Contributor

@Mephistophiles do you have commit access or you need someone to push on your behalf?

@Mephistophiles
Copy link
Contributor Author

@chestnykh unfortunately, I don't have the rights to merge this PR

@chestnykh chestnykh merged commit 2b7daaf into llvm:main Apr 2, 2025
11 checks passed
Copy link

github-actions bot commented Apr 2, 2025

@Mephistophiles Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@vitalybuka
Copy link
Collaborator

Sorry for the delay.
LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants