royzah opened a new pull request, #20416:
URL: https://github.com/apache/nuttx/pull/20416

   Depends on #20412; its commits are included until it merges.
   
   ## Why
   
   In a kernel build the kernel ran a process's own heap allocator, on metadata 
the process controls, to set or clear an environment variable and to back an 
anonymous `mmap()`. At exit it freed both from whatever address space happened 
to be current.
   
   ## How
   
   | Commit | Does |
   | --- | --- |
   | `fs/mmap` | a user anonymous mapping is fresh pages mapped into the 
process, as the REVISIT asked |
   | `environ` | libc owns the environment in a kernel build and tells the 
kernel where it is with `set_environ_ptr()`; the kernel only reads it, pointer 
by pointer. `getenv`, `setenv`, `putenv`, `unsetenv` and `clearenv` leave the 
syscall table there |
   
   Flat and protected builds are unchanged.
   
   `env_sanitize_secure()` on master still edits the environment in the kernel. 
Nothing calls it today; in a kernel build it would need to go through the 
process.
   
   ## Tested
   
   | Where | Result |
   | --- | --- |
   | `qemu-armv8a:knsh` | `ostest` passes, its environment checks included; 
`hello` |
   | `rv-virt:knsh64` | `hello`; `ostest` log identical to master's |
   | i.MX93, PX4 kernel build | environment set, read and inherited by a 
spawned process; anonymous map zeroed, in user space, unmapped |
   
   `tools/checkpatch.sh` clean.
   


-- 
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]

Reply via email to