Bug 215757

Summary: KASAN (sw-tags): investigate disabling recovery compiler option
Product: Memory Management Reporter: Andrey Konovalov (andreyknvl)
Component: SanitizersAssignee: MM/Sanitizers virtual assignee (mm_sanitizers)
Status: NEW ---    
Severity: normal CC: kasan-dev
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: upstream Subsystem:
Regression: No Bisected commit-id:

Description Andrey Konovalov 2022-03-27 14:56:08 UTC
For SW_TAGS KASAN, the instrumentation allows to control whether we can proceed after a crash was detected. This is done by passing the -recover flag to the compiler. Disabling recovery allows to generate more compact code.

Unfortunately, disabling recovery does not work for the kernel as is. KASAN reporting is disabled in some contexts (for example when the allocator accesses slab object metadata; this is controlled by current->kasan_depth). All these accesses are detected by the tool, even though the reports for them are not printed. If the recovery is disabled, KASAN will not be able to proceed after the first of such accesses.

Investigate the possibility of disabling recovery, or update the comment at [1] to say that it is impossible to disable.

[1] https://elixir.bootlin.com/linux/v5.17/source/arch/arm64/kernel/traps.c#L1032