llvm / llvm/llvm-project

[clang][PAC] Don't issue a "changes pointer-authentication of pointee type" warning for memcpy/move, etc even if the types have the same schemas

Open
#162,410 0 comments 0 reactions 1 assignee Claimed by @ojhunt View on GitHub
clang
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I noticed this while trying to clean up some annoying cast work arounds in the hardening upstreaming:

```cpp
typedef void * __ptrauth(0, 0, 0) ptr_type;
ptr_type p, q;
// assume init
memcpy(&q, &p, sizeof(p));
```

produces

```
passing '__ptrauth(0,0,0) void **' (aka '__ptrauth(0,0,0) unsigned long *') to parameter of type 'const void *' changes pointer-authentication of pointee type
```

The issue is that the analysis producing this warning is looking at the destination type of arg0 and/or arg1, which at the point of checking may already have been cast (either implicitly or explicitly) to `void*` as that is the required type of the destination.

When fixing this we should also consider implicit schemas, and consider warning if the values are address discriminated - though how to suppress that warning is an adventure in its own misery.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.