This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Added asan_shadow_defines.h, which contatins shadow offset for various platforms.
AbandonedPublic

Authored by kstoimenov on Dec 3 2021, 1:15 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Dec 3 2021, 1:15 PM
kstoimenov requested review of this revision.Dec 3 2021, 1:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2021, 1:15 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka added inline comments.Dec 3 2021, 1:27 PM
compiler-rt/lib/asan/asan_mapping.h
33–35

can you do just
if SHADOW_OFFSET_CONST
define SHADOW_OFFSET kConstShadowOffset
esle
define SHADOW_OFFSET __asan_shadow_memory_dynamic_address

vitalybuka added inline comments.Dec 3 2021, 1:30 PM
compiler-rt/lib/asan/asan_mapping.h
23–24

constexpr?

vitalybuka added inline comments.Dec 3 2021, 1:38 PM
compiler-rt/lib/asan/asan_shadow_defines.h
191

It was 0x7FFFFFFF & (~0xFFFULL << kDefaultShadowScale);
you need to use
#if defined(ASAN_SHADOW_SCALE) here

vitalybuka added inline comments.Dec 3 2021, 1:41 PM
compiler-rt/lib/asan/asan_shadow_defines.h
191

or we can remove COMPILER_RT_ASAN_SHADOW_SCALE and ASAN_SHADOW_SCALE, it's should be unused after related code was removed

kstoimenov updated this revision to Diff 391743.Dec 3 2021, 2:44 PM
kstoimenov marked an inline comment as done.

Addressed comments.

kstoimenov marked 3 inline comments as done.Dec 3 2021, 2:46 PM
kstoimenov added inline comments.
compiler-rt/lib/asan/asan_mapping.h
23–24

I prefer to update the whole file in a separate patch.

33–35

I like that idea.

compiler-rt/lib/asan/asan_shadow_defines.h
191

I added an error message if ASAN_SHADOW_SCALE != 3.

191

Removing ASAN_SHADOW_SCALE is another clean up patch I think.

vitalybuka added inline comments.Dec 3 2021, 3:13 PM
compiler-rt/lib/asan/asan_shadow_defines.h
161

0x0aaa0000 for better alignment

168

SANITIZER_IOS 32bit

  1. define SHADOW_OFFSET __asan_shadow_memory_dynamic_address
175

kRiscv64_ShadowOffset64 = 0xd55550000;

176

SANITIZER_MAC && defined(aarch64) should be __asan_shadow_memory_dynamic_address

also SANITIZER_WINDOWS64 __asan_shadow_memory_dynamic_address

187

this one was u64 kDefaultShadowOffset64 = 1ULL << 44
or 0x100000000000

190

we lost

#  elif defined(__sparc__)
#    define SHADOW_OFFSET_CONST 0x80000000000
vitalybuka added inline comments.Dec 3 2021, 3:16 PM
compiler-rt/lib/asan/asan_shadow_defines.h
175

it would be nice if you align all these to 8bytes with leading 0s as well

kstoimenov updated this revision to Diff 392061.Dec 6 2021, 7:39 AM
kstoimenov marked 8 inline comments as done.

Addressed comments.

kstoimenov updated this revision to Diff 392063.Dec 6 2021, 7:45 AM

Updated Fuchsia.

compiler-rt/lib/asan/asan_shadow_defines.h
168

Removed.

187

I added an error message for this.

vitalybuka accepted this revision.Dec 6 2021, 11:46 AM
vitalybuka added inline comments.
compiler-rt/lib/asan/asan_shadow_defines.h
175

it would be nice if you align all these to 8bytes with leading 0s as well

You call, but I expected 64bit values like this: 0x0d55550000 -> 0x0000000d55550000

176

This one is not done?

187

this one was u64 kDefaultShadowOffset64 = 1ULL << 44

I added an error message for this.

I see you fixed the constant. What does this reply mean here?

This revision is now accepted and ready to land.Dec 6 2021, 11:46 AM

Sorry I didn't realize you have more comments before submitting it. Maybe you can send me a patch with the things that I missed in this one? Might be easier that way.

compiler-rt/lib/asan/asan_shadow_defines.h
176

Not sure what you mean by that.

187

I added this error:

  1. error "Only ASAN_SHADOW_SCALE = 3 is supported."
vitalybuka added inline comments.Dec 6 2021, 2:15 PM
compiler-rt/lib/asan/asan_shadow_defines.h
176

SANITIZER_MAC && defined(aarch64) had a different constant

vitalybuka reopened this revision.EditedDec 6 2021, 3:35 PM

it's not the reason, but cmake file needs to be updated

This revision is now accepted and ready to land.Dec 6 2021, 3:35 PM
kstoimenov abandoned this revision.Dec 8 2021, 10:45 AM