Page MenuHomePhabricator

[RISC-V][HWASAN] Enable HWASAN for RISC-V architecture
AcceptedPublic

Authored by smd on Aug 6 2022, 2:48 PM.

Details

Summary

[12/12] patch series to port ASAN for riscv64

These changes allow using HWASAN on RISCV64 architecture.

The majority of existing tests are passing with a few exceptions(see below).
The tests were run on QEMU, since currently there're no hardware with support
for J-extension.

For this feature to work the system must support PR_{SET,GET}_TAGGED_ADDR_CTRL
syscall. For now this is only available for a patched Linux kernel and QEMU with
enabled experimental J-extension.

Results of running HWASAN lit tests for RISC-V:

Unsupported      :  5
Passed             : 79                                                                           
Expectedly Failed  :  3

Current RISC-V code models and existing relocation symbols don't allow us to
tag global variables. This will be addressed in further patches.
These tests are marked as expected to fail since they check tagging globals:

HWAddressSanitizer-riscv64 :: TestCases/global-with-reduction.c (21 of 87)
HWAddressSanitizer-riscv64 :: TestCases/global.c (22 of 87)
HWAddressSanitizer-riscv64 :: TestCases/exported-tagged-global.c (52 of 87)

Depends On D131344

Diff Detail

Event Timeline

smd created this revision.Aug 6 2022, 2:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2022, 2:48 PM
smd published this revision for review.Aug 7 2022, 3:29 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 7 2022, 3:29 AM
Herald added subscribers: Restricted Project, cfe-commits, pcwang-thead, MaskRay. · View Herald Transcript
smd edited the summary of this revision. (Show Details)Aug 9 2022, 2:57 PM
vitalybuka accepted this revision.Aug 9 2022, 3:31 PM
This revision is now accepted and ready to land.Aug 9 2022, 3:31 PM
smd edited the summary of this revision. (Show Details)Aug 10 2022, 8:06 AM

I guess we should checking J extension is enabled somewhere when user trying to enable HWASAN? or checking that at HWASAN library at run-time? otherwise my understanding is user will get crash when enabling HWASAN if linux and/or HW don't support that?

smd added a comment.EditedAug 10 2022, 8:49 AM

I guess we should checking J extension is enabled somewhere when user trying to enable HWASAN? or checking that at HWASAN library at run-time? otherwise my understanding is user will get crash when enabling HWASAN if linux and/or HW don't support that?

It relies on a runtime check: during init runtime makes PR_{SET,GET}_TAGGED_ADDR_CTRL calls and if they're not supported, it fails with an error. So burden of checking if J extension is present is on Linux kernel.

kito-cheng accepted this revision.Aug 14 2022, 11:44 PM

It relies on a runtime check: during init runtime makes PR_{SET,GET}_TAGGED_ADDR_CTRL calls and if they're not supported, it fails with an error. So burden of checking if J extension is present is on Linux kernel.

Sounds good to me :)

smd edited the summary of this revision. (Show Details)Aug 30 2022, 11:19 PM