refactor(kernel): fix gid field typing and drop dead len check - #265
Merged
Conversation
Two cleanups from the utsname/process review: - task_struct declares rgid/gid as pid_t although gid_t exists and the uid mirror fields below them use uid_t; fix the fields and the two credential snapshots in process.c that copied the wrong type (issue #258). - __gethostname's guard is dead code: len is size_t, so the comparison is always false and the -EINVAL branch unreachable; remove the check and its comment (issue #257).
This was
linked to
issues
Aug 26, 2026
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.
Summary
Clean up two type/validation inconsistencies found during the recent
utsnameand process review.len < 0validation from__gethostname().gid_trather thanpid_tfor process group-ID credential fields and their temporary snapshots.Fixes #257.
Fixes #258.
Problem / motivation
#257 — unreachable hostname length validation
__gethostname()receives its length as asize_t:but previously contained:
Since
size_tis unsigned, this condition can never be true. The branch was dead code, and its accompanying comment incorrectly suggested that negative lengths could reach the function and be rejected.The only current caller passes
SYS_LEN, so removing the check does not change runtime behavior.#258 — GID fields typed as process IDs
task_structdeclared the real and effective group IDs as:even though these fields represent group IDs and the tree provides the appropriate
gid_ttype.This was inconsistent with the neighboring user-ID fields:
and propagated into credential snapshots used by the transactional
execve()path.pgidremainspid_t, since a process-group ID is correctly represented using the process-ID type.At present,
pid_tandgid_tare bothsigned int, so this is a type-correctness cleanup rather than a behavioral or ABI change.Changes
kernel/src/sys/utsname.clen < 0check.kernel/inc/process/process.hChange:
to:
kernel/src/process/process.cUse
gid_tfor both credential snapshots that mirrortask->gid:No credential semantics or
execve()behavior are changed.Validation
git diff --checkValidation details:
Scope
pgidremains correctly typed aspid_t.utsname, credential, orexecve()changes are included.The two issues are combined because both are small, behavior-neutral type/source correctness cleanups discovered during the same review pass, and together remain a narrowly scoped kernel cleanup.
Related issues
Fixes #257.
Fixes #258.