[PATCH] D132425: [clang] Do not instrument relative vtables under hwasan

Mitch Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 26 17:39:40 PDT 2022


hctim added a comment.

In D132425#3753065 <https://reviews.llvm.org/D132425#3753065>, @leonardchan wrote:

> We have a generic long term solution for hwasan+RV which I think might also be applicable for MTE+RV. For hwasan, since it's mainly the IR pass that converts usages of the vtable (within the vtable itself) to use tagged aliases, the ideal solution is to just have hwasan ignore these specific references in the vtable such that offset calculation can continue to use the untagged address allowing the relocation arithmetic to not overflow. Now for llvm, I'm assuming it's an instrumentation pass like memtagsanitizer that will ensure all references to globals go through the GOT by replacing all global references with the appropriate IR that gets lowered to this GOT reference. If this is the case, then I *think* a similar solution can be done here where particular references to the vtable continue to use the original vtable address and avoid instrumentation.

HWASan and MTE have a nice invariant that helps - functions aren't tagged (phew). IIUC, For HWASan, it seems like you could just use an `_NC` relocation and truncate off the tag bits when materializing a function pointer from the relative vtable. For MTE, taking the address of the vtable would be indirect (as it has to be grabbed from the GOT), and applying the offset would result in a tagged function pointer. Because code pages aren't mapped as `PROT_MTE`, seems like this would succeed (maybe unwinders would have to be taught to truncate any tag bits, but that seems about it).

Either way, I don't think we should worry about it right this instant, and any problems would be easily detected during experimentation.

Didn't actually realise this was submitted. Appreciate the follow-up patch for non-relative-vtables + hwasan :).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132425/new/

https://reviews.llvm.org/D132425



More information about the cfe-commits mailing list