llvm-project/clang-tools-extra/docs/clang-tidy/checks/android/cloexec-inotify-init1.rst
raw| 1 | .. title:: clang-tidy - android-cloexec-inotify-init1 |
| 2 | |
| 3 | android-cloexec-inotify-init1 |
| 4 | ============================= |
| 5 | |
| 6 | ``inotify_init1()`` should include ``IN_CLOEXEC`` in its type argument to avoid the |
| 7 | file descriptor leakage. Without this flag, an opened sensitive file would |
| 8 | remain open across a fork+exec to a lower-privileged SELinux domain. |
| 9 | |
| 10 | Examples: |
| 11 | |
| 12 | .. code-block:: c++ |
| 13 | |
| 14 | inotify_init1(IN_NONBLOCK); |
| 15 | |
| 16 | // becomes |
| 17 | |
| 18 | inotify_init1(IN_NONBLOCK | IN_CLOEXEC); |