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