Skip to content

Kernel: Pass all user pointers as Userspace<T*> in syscalls - #26980

Open
Hendiadyoin1 wants to merge 1 commit into
SerenityOS:masterfrom
Hendiadyoin1:Userspace-all-the-things
Open

Kernel: Pass all user pointers as Userspace<T*> in syscalls#26980
Hendiadyoin1 wants to merge 1 commit into
SerenityOS:masterfrom
Hendiadyoin1:Userspace-all-the-things

Conversation

@Hendiadyoin1

@Hendiadyoin1 Hendiadyoin1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

As the commit title suggests the main change is always passing the pointer arguments as Userspace<T*>.
This commit also makes creations of Userspace pointers more explicit on the kernel side and handles all the fallout from those changes.

These changes include:

  • Adding dereferenceability on the Userland side of Userspace<T*>
  • Adding const up conversion to Userspace<T*>
  • changing kernel/user copies to use the correct overloads
  • Adding/removing casts as necessary
  • Changing signatures as necessary

And a bit more controversial:

  • Changing futex params to contain volatile pointers
    This was the easiest way of getting the correct types for the atomic operations in sys$futex. The Kernel APIs should likely change signature instead, as volatility and atomicity are two very different concepts in modern c++.

@github-actions github-actions Bot added the 馃憖 pr-needs-review PR needs review from a maintainer or community member label Aug 27, 2026
@Hendiadyoin1
Hendiadyoin1 force-pushed the Userspace-all-the-things branch 2 times, most recently from 9348113 to da39e52 Compare August 28, 2026 09:52
As the commit title suggests the main change is always passing the
pointer arguments as Userspace<T*>.
This commit also makes creations of Userspace pointers more explicit on
the kernel side and handles all the fallout from those changes.

These changes include:
* Adding dereferenceability on the Userland side of Userspace<T*>
* Adding const up conversion to Userspace<T*>
* changing kernel/user copies to use the correct overloads
* Adding/removing casts as necessary
* Changing signatures as necessary
And a bit more controversial:
* Changing futex params to contain volatile pointers
  This was the easiest way of getting the correct types for the atomic
  operations in sys$futex.
  The Kernel APIs should likely change signature instead, as volatility
  and atomicity are two very different concepts in modern c++.
@spholz

spholz commented Aug 28, 2026

Copy link
Copy Markdown
Member

Can you please split this up into smaller atomic commits? (Maybe not one per syscall though.) There also seem to be some smaller drive-by changes between purely mechanical changes. It would be nice if those could be separate commits as well.

(I kind of liked that we didn't use too many fancy C++ features over the syscall border. But I guess it's worth the extra safety here.)

@spholz

spholz commented Aug 28, 2026

Copy link
Copy Markdown
Member

The Kernel APIs should likely change signature instead, as volatility and atomicity are two very different concepts in modern c++.

Why? Have a look at all the atomic* functions and builtins. They also use volatile parameters. "atomics" don't exist as a type at the language level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

馃憖 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants