Page MenuHomeFreeBSD

cdefs: add bounds-safety annotation macros
AcceptedPublic

Authored by abhijeetsharma2002_gmail.com on Wed, Aug 19, 11:52 AM.
Tags
None
Referenced Files
F170680648: D58983.id185426.diff
Sun, Sep 6, 12:10 AM
F170649457: D58983.id184350.diff
Sat, Sep 5, 7:43 PM
F170649407: D58983.id184350.diff
Sat, Sep 5, 7:42 PM
F170647489: D58983.id.diff
Sat, Sep 5, 7:28 PM
F170608349: D58983.id.diff
Sat, Sep 5, 3:15 PM
F170603017: D58983.id.diff
Sat, Sep 5, 2:40 PM
Unknown Object (File)
Sat, Sep 5, 10:11 AM
Unknown Object (File)
Sat, Sep 5, 9:20 AM
Subscribers

Details

Reviewers
rpaulo
emaste
imp
Summary

Define the -fbounds-safety vocabulary (counted_by, sized_by,
__single, the forge escape hatches). Every macro expands to nothing
under compilers without the extension, so the annotated tree builds
unchanged with the stock toolchain.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76328
Build 73211: arc lint + arc unit

Event Timeline

Ah! I complained that these were missing from a prior review, but they are just what I was hoping for.

This revision is now accepted and ready to land.Wed, Aug 19, 7:24 PM
sys/sys/cdefs.h
408

Can you explain why these are under a different feature? What happens when one feature is ON but the other is off?

426

This is probably not going to be enough because you may need to add __indexable to static inline functions in headers which are going to be used by both compilers.

sys/sys/cdefs.h
408

bounds_safety_attributes enables the ABI-preserving annotations without applying the full bounds-safety pointer defaults, so unannotated parameters do not become __single. That provides an annotations-only migration mode where a file can be audited with -Wunsafe-buffer-usage before enabling full -fbounds-safety. The wide-pointer attributes are not supported in that mode, hence the bounds_attributes guard.

Separately, I noticed that my __has_ptrcheck definition is wrong, since I set it for either feature, whereas Clang's ptrcheck.h defines it only for bounds_attributes.

426

Makes sense. I will follow xnu and add a header_indexable/header_bidi_indexable pair that expands to nothing when unsupported.

This revision now requires review to proceed.Sat, Aug 29, 11:21 PM
This revision is now accepted and ready to land.Sun, Aug 30, 6:29 AM