Skip to content

Commit f477784

Browse files
authored
[BoundsSafety][doc] Make it clear that the feature is work-in-progress (#95964)
The `-fbounds-safety` feature is not available yet and the implementation is still in progress, which will be guarded by `-fexperimental-bounds-safety`. To avoid the confusion, we're making it more explicit that the feature is not available yet and the document only describes the model.
1 parent 560b645 commit f477784

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

clang/docs/BoundsSafety.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
Overview
99
========
1010

11+
**NOTE:** This is a design document and the feature is not available for users yet.
12+
Please see :doc:`BoundsSafetyImplPlans` for more details.
13+
1114
``-fbounds-safety`` is a C extension to enforce bounds safety to prevent
1215
out-of-bounds (OOB) memory accesses, which remain a major source of security
1316
vulnerabilities in C. ``-fbounds-safety`` aims to eliminate this class of bugs
@@ -55,9 +58,7 @@ adopt, offering these properties that make it widely adoptable in practice:
5558
* It has a relatively low adoption cost.
5659

5760
This document discusses the key designs of ``-fbounds-safety``. The document is
58-
subject to be actively updated with a more detailed specification. The
59-
implementation plan can be found in :doc:`BoundsSafetyImplPlans`.
60-
61+
subject to be actively updated with a more detailed specification.
6162

6263
Programming Model
6364
=================

clang/docs/BoundsSafetyImplPlans.rst

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,39 @@ Implementation plans for ``-fbounds-safety``
55
.. contents::
66
:local:
77

8+
Gradual updates with experimental flag
9+
======================================
10+
11+
The feature will be implemented as a series of smaller PRs and we will guard our
12+
implementation with an experimental flag ``-fexperimental-bounds-safety`` until
13+
the usable model is fully available. Once the model is ready for use, we will
14+
expose the flag ``-fbounds-safety``.
15+
16+
Possible patch sets
17+
-------------------
18+
19+
* External bounds annotations and the (late) parsing logic.
20+
* Internal bounds annotations (wide pointers) and their parsing logic.
21+
* Clang code generation for wide pointers with debug information.
22+
* Pointer cast semantics involving bounds annotations (this could be divided
23+
into multiple sub-PRs).
24+
* CFG analysis for pairs of related pointer and count assignments and the likes.
25+
* Bounds check expressions in AST and the Clang code generation (this could also
26+
be divided into multiple sub-PRs).
27+
28+
Proposed implementation
29+
=======================
30+
831
External bounds annotations
9-
===========================
32+
---------------------------
1033

1134
The bounds annotations are C type attributes appertaining to pointer types. If
1235
an attribute is added to the position of a declaration attribute, e.g., ``int
1336
*ptr __counted_by(size)``, the attribute appertains to the outermost pointer
1437
type of the declaration (``int *``).
1538

1639
New sugar types
17-
===============
40+
---------------
1841

1942
An external bounds annotation creates a type sugar of the underlying pointer
2043
types. We will introduce a new sugar type, ``DynamicBoundsPointerType`` to
@@ -29,7 +52,7 @@ overloading. However, this design requires a separate logic to walk through the
2952
entire type hierarchy to check type compatibility of bounds annotations.
3053

3154
Late parsing for C
32-
==================
55+
------------------
3356

3457
A bounds annotation such as ``__counted_by(count)`` can be added to type of a
3558
struct field declaration where count is another field of the same struct
@@ -43,7 +66,7 @@ same logic. This requires introducing late parsing logic for C/C++ type
4366
attributes.
4467

4568
Internal bounds annotations
46-
===========================
69+
---------------------------
4770

4871
``__indexable`` and ``__bidi_indexable`` alter pointer representations to be
4972
equivalent to a struct with the pointer and the corresponding bounds fields.
@@ -65,7 +88,7 @@ operations returning wide pointers. Alternatively, a new ``TEK`` and an
6588
expression emitter dedicated to wide pointers could be introduced.
6689

6790
Default bounds annotations
68-
==========================
91+
--------------------------
6992

7093
The model may implicitly add ``__bidi_indexable`` or ``__single`` depending on
7194
the context of the declaration that has the pointer type. ``__bidi_indexable``
@@ -79,7 +102,7 @@ This also requires the parser to reset the type of the declaration with the
79102
newly created type with the right default attribute.
80103

81104
Promotion expression
82-
====================
105+
--------------------
83106

84107
A new expression will be introduced to represent the conversion from a pointer
85108
with an external bounds annotation, such as ``__counted_by``, to
@@ -88,7 +111,7 @@ CastExprs because it requires an extra subexpression(s) to provide the bounds
88111
information necessary to create a wide pointer.
89112

90113
Bounds check expression
91-
=======================
114+
-----------------------
92115

93116
Bounds checks are part of semantics defined in the ``-fbounds-safety`` language
94117
model. Hence, exposing the bounds checks and other semantic actions in the AST
@@ -98,7 +121,7 @@ and has the additional sub-expressions that are necessary to perform the check
98121
according to the kind.
99122

100123
Paired assignment check
101-
=======================
124+
-----------------------
102125

103126
``-fbounds-safety`` enforces that variables or fields related with the same
104127
external bounds annotation (e.g., ``buf`` and ``count`` related with
@@ -123,7 +146,7 @@ provides a linear view of statements within each ``CFGBlock`` (Clang
123146
``CFGBlock`` represents a single basic block in a source-level CFG).
124147

125148
Bounds check optimizations
126-
==========================
149+
--------------------------
127150

128151
In ``-fbounds-safety``, the Clang frontend emits run-time checks for every
129152
memory dereference if the type system or analyses in the frontend couldn’t
@@ -229,27 +252,3 @@ solution.
229252

230253
``-fbounds-safety`` is not currently supported in C++, but we believe the
231254
general approach would be applicable for future efforts.
232-
233-
Upstreaming plan
234-
================
235-
236-
Gradual updates with experimental flag
237-
--------------------------------------
238-
239-
The upstreaming will take place as a series of smaller PRs and we will guard our
240-
implementation with an experimental flag ``-fexperimental-bounds-safety`` until
241-
the usable model is fully upstreamed. Once the model is ready for use, we will
242-
expose the flag ``-fbounds-safety``.
243-
244-
Possible patch sets
245-
-------------------
246-
247-
* External bounds annotations and the (late) parsing logic.
248-
* Internal bounds annotations (wide pointers) and their parsing logic.
249-
* Clang code generation for wide pointers with debug information.
250-
* Pointer cast semantics involving bounds annotations (this could be divided
251-
into multiple sub-PRs).
252-
* CFG analysis for pairs of related pointer and count assignments and the likes.
253-
* Bounds check expressions in AST and the Clang code generation (this could also
254-
be divided into multiple sub-PRs).
255-

0 commit comments

Comments
 (0)