Bug 203751 - check alignment of atomicops/bitops
Summary: check alignment of atomicops/bitops
Status: NEW
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P1 enhancement
Assignee: MM/Sanitizers virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-29 11:28 UTC by Dmitry Vyukov
Modified: 2019-05-29 11:28 UTC (History)
1 user (show)

See Also:
Kernel Version: ALL
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Dmitry Vyukov 2019-05-29 11:28:43 UTC
This come up during review of bitops instrumentation:
https://groups.google.com/d/msg/kasan-dev/g8BcLLjpgoA/qxaxdveBBQAJ

It would be useful to check that addresses passed to atomicops/bitops are properly aligned, because the future hardware may trap on unaligned accesses, there is significant performance penalty for accesses splitting cache lines and it may cause problems with bit/little-endiness.

Bitops should be aligned to long:
https://groups.google.com/d/msg/kasan-dev/g8BcLLjpgoA/Fr5uTbiEBQAJ
Documentation/core-api/atomic_ops.rst
        Native atomic bit operations are defined to operate on objects aligned
        to the size of an "unsigned long" C data type, and are least of that
        size.  The endianness of the bits within each "unsigned long" are the
        native endianness of the cpu.

This should be done as a separate config (not KASAN) as not related to
KASAN per se. But the existing {atomicops,bitops}-instrumented.h hooks provide handy foundation for such checks.

Note You need to log in before you can comment on or make changes to this bug.