Conversation
royzah
requested review from
jerpelea,
linguini1,
lupyuen,
masayuki2009,
pkarashchenko,
pussuw,
xiaoxiang781216 and
yf13
as code owners
September 30, 2026 15:55
This was referenced Sep 30, 2026
linguini1
requested changes
Sep 30, 2026
linguini1
left a comment
Contributor
There was a problem hiding this comment.
Test logs required please.
This was referenced Oct 1, 2026
Contributor
Author
|
Full QEMU |
Contributor
|
comment in the original pr |
Contributor
Author
|
Pushed: uaccess_ok is access_ok now, and arm64 returns -EINVAL instead of panicking. Fresh logs in the body. |
Contributor
|
Please include the full logs for each target |
Contributor
Author
|
@linguini1 arm64 and rv64 QEMU runs are in the description.
|
Blank lines after declarations, one declaration per line and case alignment, so the check passes on the files the next commits change. No code changes. Signed-off-by: Royyan Zahir <royzah@gmail.com>
uaccess_ok() says whether a range lies in the caller's address environment and uaccess_check() kills the caller when it does not. They are how a kernel build refuses a kernel address passed in by a process. Signed-off-by: Royyan Zahir <royzah@gmail.com>
access_ok() trusts the user address range, so a kernel mapping inside it would pass as user memory. Refuse such a mapping: at boot the kernel stops, arm64_mmu_set_memregion() returns -EINVAL. Signed-off-by: Royyan Zahir <royzah@gmail.com>
access_ok() trusts the user address range, so a global kernel leaf inside it would pass as user memory. Refuse such a mapping. Signed-off-by: Royyan Zahir <royzah@gmail.com>
arch.h declares it for an address environment; x86_64 had the same check as the private x86_64_uservaddr(), which it replaces. The syscall checks need it in every kernel build. Signed-off-by: Royyan Zahir <royzah@gmail.com>
risc-v and x86_64 walk the active page tables for up_addrenv_va_to_pa() the way arm64 does. drivers/misc/addrenv.c defined the same symbol from a static table, which cannot see user mappings: in a kernel build it now steps aside and arm64 builds its walker there too. Outside a kernel build nothing changes. Signed-off-by: Royyan Zahir <royzah@gmail.com>
xiaoxiang781216
approved these changes
Oct 2, 2026
Contributor
Author
|
hey @linguini1 logs are up (comment + zip), mind another look when u got time? same for #20416 and #20417 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Summary
In a kernel build a syscall trusts every pointer a process passes. A process can hand the kernel a kernel address and have it read out, written to, or followed through a nested pointer. This PR adds what the checks stand on. The checks at the syscall boundary follow in their own PR once this lands, so where they belong, the generated stubs or the functions, can be settled there.
sched/addrenvuaccess_ok(), anduaccess_check(), which kills the caller throughuaccess_fault()-EINVALup_addrenv_user_vaddr(), whicharch.halready declares; replaces the privatex86_64_uservaddr()archup_addrenv_va_to_pa()like arm64; in a kernel build the table indrivers/misc/addrenv.csteps aside, as it cannot see user mappingsImpact
Kernel builds only. Nothing calls the new checks yet. A kernel mapping over the user window is refused, and in risc-v and x86_64 kernel builds the MMU answers
up_addrenv_va_to_pa(), also withDEV_SIMPLE_ADDRENV. Flat and protected builds unchanged.Testing
Host: Ubuntu 24.04, x86_64. Builds and QEMU runs in
ghcr.io/apache/nuttx/apache-nuttx-ci-linux(QEMU 6.2, Arm GNU GCC 13.2, xPack RISC-V GCC 14.3).QEMU:
helloostestqemu-armv8a:knshExiting with status 0rv-virt:knsh64Started user_main at PID=6, as master doesqemu-intel64:knsh_romfsnx_bringup.c:370in QEMU too, so not comparedAlso built:
canmv230:remote,canmv230:master,qemu-intel64:knsh_romfs_pci,rv-virt:knetnsh64,qemu-armv8a:fb,qemu-armv7a:full,sim:nsh.qemu-armv8a:knsh:hello, thenostestrv-virt:knsh64:hello, thenostest; identical to master'stools/checkpatch.sh -c -u -m -gclean.