casaroli opened a new pull request, #4014: URL: https://github.com/apache/nuttx-apps/pull/4014
depends-on: apache/nuttx/pull/21647 ## Summary memfd_create() must make a new file with the flags 0, `MFD_CLOEXEC` and `MFD_ALLOW_SEALING`, and with a long name. The name is only for debug, and Linux accepts names of up to 249 characters. On nuttx master memfd_create() fails with ENOENT for all three flags and with ENAMETOOLONG for a long name (fixed by apache/nuttx#21647). This PR adds testing/libc/memfd_create (`CONFIG_TESTING_MEMFD_CREATE`, program `memfd_create_test`). It makes files with flags 0, `MFD_CLOEXEC | MFD_ALLOW_SEALING` and a name of 200 characters. Then it checks `FD_CLOEXEC` for `MFD_CLOEXEC`, the size after ftruncate(), write() and read(), and that a second file with the same name is a new empty file. testing/fs/memfd does not find this bug: it gives `O_CREAT | O_CLOEXEC` as flags, needs `MM_KASAN`, and does not check the results. ## Impact New test program only, off by default. Make and CMake build files are both added. It depends on `!LIBC_MEMFD_ERROR`, as testing/fs/memfd does. With `LIBC_MEMFD_TMPFS`, `CONFIG_LIBC_TMPDIR` must exist (memfd_create() makes only the last directory). ## Testing With apache/nuttx#21647, `memfd_create_test` gives 0 errors; on nuttx master it gives 4 errors (flags 0, `MFD_ALLOW_SEALING` and `MFD_CLOEXEC` with ENOENT, the long name with ENAMETOOLONG): - qemu-armv8a:nsh (flat build, arm64, QEMU) with `LIBC_MEMFD_TMPFS` and the test as a builtin. ostest exits 0 after it, and testing/fs/memfd (`MM_KASAN`) passes with 50/50 threads. - qemu-armv8a:knsh (kernel build, arm64, QEMU, `LIBC_MEMFD_SHMFS`), the test built as a separate program. - mps2-an500:knsh (protected build, Cortex-M7, QEMU, `LIBC_MEMFD_TMPFS`), the test in the user image. `tools/checkpatch.sh -c -u -m -g origin/master..HEAD` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
