brintos

brintos / llvm-project-archived public Read only

0
0
Text · 727 B · 850eae7 Raw
25 lines · plain
1.. title:: clang-tidy - android-cloexec-open2 3android-cloexec-open4====================5 6A common source of security bugs is code that opens a file without using the7``O_CLOEXEC`` flag. Without that flag, an opened sensitive file would remain8open across a fork+exec to a lower-privileged SELinux domain, leaking that9sensitive data. Open-like functions including ``open()``, ``openat()``, and10``open64()`` should include ``O_CLOEXEC`` in their flags argument.11 12Examples:13 14.. code-block:: c++15 16  open("filename", O_RDWR);17  open64("filename", O_RDWR);18  openat(0, "filename", O_RDWR);19 20  // becomes21 22  open("filename", O_RDWR | O_CLOEXEC);23  open64("filename", O_RDWR | O_CLOEXEC);24  openat(0, "filename", O_RDWR | O_CLOEXEC);25