[PATCH] D79279: Allow volatile parameters to __builtin_mem{cpy,move,set}

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 18:11:53 PDT 2020


jfb created this revision.
Herald added subscribers: cfe-commits, ributzka, dexonsmith, jkorous, JDevlieghere.
Herald added a project: clang.

These builtins are often used (or should be used) in places where time-of-check
time-of-use security issues are important (e.g. copying from untrusted buffers).
They don't accept volatile pointee parameters in C++, and merely warn about such
parameters in C, which leads to confusion. In these settings, it's useful to
overload the builtin and permit volatile pointee parameters. The code generation
then directly emits the existing volatile variant of the mem* builtin function
call, which ensures that the affected memory location is only accessed once
(thereby preventing double-reads under an adversatial memory mapping).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79279

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin-memfns.c
  clang/test/CodeGen/builtin-volatile-memfns.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79279.261598.patch
Type: text/x-patch
Size: 10989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200502/9c5c7b5a/attachment-0001.bin>


More information about the cfe-commits mailing list