casaroli opened a new pull request, #21098:
URL: https://github.com/apache/nuttx/pull/21098
## Summary
A program that looks for a process by its user reads the `Uid:` and `Gid:`
lines of `/proc/<pid>/status`, or the owner of the `/proc/<pid>` directory, as
on Linux. NuttX showed neither: there was no such line, and the owner of every
procfs entry was 0.
With `CONFIG_SCHED_USER_IDENTITY`, this PR adds two lines to
`/proc/<pid>/status`, in the column format of that file: `Uid:` gives the real
and the effective user ID of the task group, in this order, and `Gid:` gives
the real and the effective group ID. `stat()` of `/proc/<pid>` and of the files
in it gives the effective user and group ID of the task group in `st_uid` and
`st_gid`.
The second commit describes this in `Documentation/os/filesystem/procfs.rst`.
## Impact
Only with `CONFIG_SCHED_USER_IDENTITY`: two more lines in
`/proc/<pid>/status` (after `Group:`), and an owner for the `/proc/<pid>`
entries (before: always 0). The modes do not change. Without the option nothing
changes. Flat, protected and kernel builds; no architecture code.
## Testing
Tested on master aeab6fbf989 and on this PR rebased on it.
Test program `procuid.c` on `qemu-armv8a:knsh` (QEMU with HVF), with
`CONFIG_SCHED_USER_IDENTITY` and `CONFIG_PIPES`. The test runs as root; the
children come from `fork()` and wait while the parent reads their entries.
| Case | master | this PR |
|---|---|---|
| `Uid:` of `/proc/self/status` = `getuid()` `geteuid()` | FAIL (no line) |
PASS |
| `Gid:` of `/proc/self/status` = `getgid()` `getegid()` | FAIL (no line) |
PASS |
| `stat("/proc/self")` and `stat("/proc/self/status")`: owner 0/0 | PASS
(always 0/0) | PASS |
| child after `setgid(1000)` + `setuid(1000)`: `Uid: 1000 1000`, `Gid: 1000
1000` | FAIL | PASS |
| the same child: `stat("/proc/<pid>")` gives 1000/1000 | FAIL (0/0) | PASS |
| child after `setegid(3000)` + `seteuid(2000)`: `Uid: 0 2000`, `Gid: 0
3000` | FAIL | PASS |
| the same child: `stat()` of `/proc/<pid>` and `/proc/<pid>/cmdline` give
2000/3000 | FAIL (0/0) | PASS |
ostest exits with status 0 on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` (with
the same options).
Build, each OK: with `CONFIG_SCHED_USER_IDENTITY`: `qemu-armv8a:nsh` (flat,
arm64), `qemu-armv8a:knsh` (kernel, arm64), `rv-virt:pnsh64` (protected, rv64),
`rv-virt:knsh64` (kernel, rv64); without it: `lm3s6965-ek:qemu-protected`
(protected, armv7-m).
`tools/checkpatch.sh -c -u -m -g` 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]