casaroli opened a new pull request, #3993:
URL: https://github.com/apache/nuttx-apps/pull/3993
## Summary
In a CMake build with `CONFIG_SCHED_USER_IDENTITY`, no builtin application
can start. nxinit cannot start NSH: `Error Starting service 'console': 13`
(EACCES) every second.
With `CONFIG_SCHED_USER_IDENTITY`, `struct builtin_s` has `uid`, `gid` and
`mode` after `main`. `REGISTER` in `Make.defs` writes the `UID`, `GID` and
`MODE` of the application, else 0, 0 and 0555. `builtin/CMakeLists.txt` wrote
only `{ name, priority, stack size, main }`, so the mode of each builtin was 0.
`CONFIG_BINFMT_CHECKEXEC` (default y with `SCHED_USER_IDENTITY`) then makes
`builtin_loadbinary()` return -EACCES for each builtin, because no execute bit
is set.
This PR writes uid, gid and mode in the CMake build as `REGISTER` does: from
the target properties `APP_UID`, `APP_GID` and `APP_MODE` if they are set, else
0, 0 and 0555.
This is why the tests of apache/nuttx#21542, apache/nuttx#21547 and
apache/nuttx#21557 build qemu-armv8a with `LIBC_ENVPATH` and `BINFMT_CHECKEXEC`
disabled ("which current master needs for nxinit to start nsh there").
apache/nuttx#21558 removes the `LIBC_ENVPATH` problem; this PR removes the
`BINFMT_CHECKEXEC` problem of the CMake build.
## Impact
- CMake build with `CONFIG_SCHED_USER_IDENTITY` only. In-tree, 8 defconfigs
have it (qemu-armv8a and qemu-armv7a rpserver/rpproxy, sim:citest,
sim:posix_test, rv-virt:citest, teensy-4.x:pikron-bb).
- Without `SCHED_USER_IDENTITY`, the CMake build writes the same
`builtin_list.h` as before.
- The make build does not change: `Make.defs` and `Application.mk` are not
touched.
- Per-application values (`MODE 484` of examples/hello with
`EXAMPLES_HELLO_RESTRICTED`, the setuid `MODE` of system/sudo) need
apache/nuttx#21566, which stores `UID`, `GID` and `MODE` of
`nuttx_add_application()` as these target properties. Without it the defaults
0, 0 and 0555 apply. This PR does not depend on it.
## Testing
qemu-armv8a:rpserver (`SCHED_USER_IDENTITY=y`, `BINFMT_CHECKEXEC=y`) on the
branch of apache/nuttx#21558 (f24447adc96, `LIBC_ENVPATH` removed), built as in
its documentation (`cmake -GNinja`), aarch64-none-elf-gcc 14.2, QEMU TCG on
macOS (RPMSG port UART), then `hello` at the prompt:
| build | apps | `builtin_list.h` | result |
|---|---|---|---|
| CMake | master 19a303645 | `{ "sh", 100, 8192, sh_main },` | no prompt,
`Error Starting service 'console': 13` 60 times |
| CMake | this PR | `{ "sh", 100, 8192, sh_main, 0, 0, 0555 },` | `server>`
prompt, `hello` prints `Hello, World!!` |
| make | this PR | `{ "sh", 100, 8192, sh_main, 0, 0, 0555 },` (registry) |
`server>` prompt, `hello` prints `Hello, World!!` |
CMake configure only (`builtin_list.h`):
- rpserver + `EXAMPLES_HELLO_RESTRICTED`, this PR with apache/nuttx#21566:
`{ "hello", 100, 8192, hello_main, 0, 0, 484 },`; without it: `0, 0, 0555`.
- qemu-armv8a:nsh (no `SCHED_USER_IDENTITY`), this PR: `{ "hello", 100,
8192, hello_main },`, the same as master.
`tools/checkpatch.sh -c -u -m -g` passes (cmake-format included).
--
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]