Skip to content

Commit b00177a

Browse files
committed
Address _some_ of the review feedback
Also update to __has_feature, though that is blocked on #153291
1 parent 8776323 commit b00177a

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

clang/docs/PointerAuthentication.rst

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ This document serves four purposes:
5252
ways in which programmers can strengthen its protections (including
5353
recommendations for language implementors).
5454

55-
- It documents the language ABIs currently used for C, C++, and Objective-C
56-
on arm64e.
55+
- It documents the stable ABI of the C, C++, and Objective-C languages on arm64e
56+
platforms.
5757

5858

5959
Basic concepts
@@ -274,13 +274,16 @@ There are three levels of the pointer authentication language feature:
274274
including return addresses, function pointers, and C++ virtual functions. The
275275
intent is for all pointers to code in program memory to be signed in some way
276276
and for all branches to code in program text to authenticate those
277-
signatures.
277+
signatures. In addition to the code pointers themselves, we also use pointer
278+
authentication to protect data values that directly or indirectly influence
279+
control flow or program integrity.
278280

279281
- The language also provides extensions to override the default rules used by
280282
the language implementation. For example, the ``__ptrauth`` type qualifier
281-
can be used to change how pointers are signed when they are stored in
282-
a particular variable or field; this provides much stronger protection than
283-
is guaranteed by the default rules for C function and data pointers.
283+
can be used to change how pointers or pointer sized integers are signed when
284+
they are stored in a particular variable or field; this provides much stronger
285+
protection than is guaranteed by the default rules for C function and data
286+
pointers.
284287

285288
- Finally, the language provides the ``<ptrauth.h>`` intrinsic interface for
286289
manually signing and authenticating pointers in code. These can be used in
@@ -360,7 +363,7 @@ signed with address diversity.
360363

361364
While this representation of nulls is the safest option for the general case,
362365
there are some situations in which a null pointer may have important semantic
363-
or security impact. For that purpose clang has the concept of a pointer
366+
or security impact. For that purpose Clang has the concept of a pointer
364367
authentication schema that signs and authenticates null values.
365368

366369
Return addresses
@@ -397,17 +400,17 @@ Feature testing
397400
Whether the current target uses pointer authentication can be tested for with
398401
a number of different tests.
399402

400-
- ``__has_extension(ptrauth_intrinsics)`` is true if ``<ptrauth.h>`` provides
401-
its normal interface. This may be true even on targets where pointer
403+
- ``__has_feature(ptrauth_intrinsics)`` is true if ``<ptrauth.h>`` provides its
404+
normal interface. This may be true even on targets where pointer
402405
authentication is not enabled by default.
403406

404-
- ``__has_extension(ptrauth_returns)`` is true if the target uses pointer
407+
- ``__has_feature(ptrauth_returns)`` is true if the target uses pointer
405408
authentication to protect return addresses.
406409

407-
- ``__has_extension(ptrauth_calls)`` is true if the target uses pointer
410+
- ``__has_feature(ptrauth_calls)`` is true if the target uses pointer
408411
authentication to protect indirect branches. This implies
409-
``__has_extension(ptrauth_returns)`` and
410-
``__has_extension(ptrauth_intrinsics)``.
412+
``__has_feature(ptrauth_returns)`` and
413+
``__has_feature(ptrauth_intrinsics)``.
411414

412415
Clang provides several other tests only for historical purposes; for current
413416
purposes they are all equivalent to ``ptrauth_calls``.
@@ -477,13 +480,14 @@ rules of C++:
477480

478481
- A type may be **non-trivial to copy**.
479482

480-
- A type may also be **illegal to copy**. Types that are illegal to copy are
483+
- A type may also be **illegal to copy**. Types that are illegal to copy are
481484
always non-trivial to copy.
482485

483486
- A type may also be **address-sensitive**.
484487

485-
- A type qualified with a ``ptrauth`` qualifier that requires address diversity
486-
is non-trivial to copy and address-sensitive.
488+
- A type qualified with a ``ptrauth`` qualifier or implicit authentication
489+
schema that requires address diversity is non-trivial to copy and
490+
address-sensitive.
487491

488492
- An array type is illegal to copy, non-trivial to copy, or address-sensitive
489493
if its element type is illegal to copy, non-trivial to copy, or
@@ -829,15 +833,20 @@ the following example of a hand-rolled "v-table":
829833
void (*logStatus)(Object *);
830834
};
831835
832-
This weakness can be mitigated by using a more specific signing schema for each
833-
purpose. For example, in this example, the ``__ptrauth`` qualifier can be used
834-
with a different constant discriminator for each field. Since there's no
835-
particular reason it's important for this v-table to be copyable with
836-
``memcpy``, the functions can also be signed with address diversity:
836+
The weakness in this design is that by lacking any context specific
837+
discriminator, means an attacker can substiture any of these fields with any
838+
other correctly signed function pointer. Similarly the lack of address diversity
839+
allows an attacker to replace the functions in one type's "v-table" with those
840+
of another. This can be mitigated by overriding the default authentication
841+
schema with a more specific signing schema for each purpose. For instance, in
842+
this example, the ``__ptrauth`` qualifier can be used with a different constant
843+
discriminator for each field. Since there's no particular reason it's important
844+
for this v-table to be copyable with ``memcpy``, the functions can also be
845+
signed with address diversity:
837846

838847
.. code-block:: c
839848
840-
#if __has_extension(ptrauth_calls)
849+
#if __has_feature(ptrauth_calls)
841850
#define objectOperation(discriminator) \
842851
__ptrauth(ptrauth_key_function_pointer, 1, discriminator)
843852
#else

0 commit comments

Comments
 (0)