futex: gate get_robust_list behind a ptrace access check#13241
Open
ibondarenko1 wants to merge 1 commit into
Open
futex: gate get_robust_list behind a ptrace access check#13241ibondarenko1 wants to merge 1 commit into
ibondarenko1 wants to merge 1 commit into
Conversation
get_robust_list(2) resolves a caller-supplied tid and copies out that task's robust-list head pointer with no permission check, so a task can read the robust-list head of any other task in its PID namespace, including a task owned by a different user. Linux gates this in kernel/futex/syscalls.c:do_get_robust_list(), which returns EPERM unless ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS) passes. process_vm_readv(2) already applies the equivalent Task.CanTrace check. Apply the same check before reading another task's robust-list head.
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.
Problem
get_robust_list(2)(GetRobustListinpkg/sentry/syscalls/linux/sys_futex.go) takes a caller-supplied tid, resolves it withPIDNamespace().TaskWithID(), and copies out that task's robust-list head pointer:There is no permission check between resolving
otand readingot.GetRobustList(). Any task can read the robust-list head of any other task in its PID namespace, including a task running as a different user. The head is a pointer into the target task's address space, so this discloses an address-space-layout pointer across a process boundary.Linux behavior
Linux gates this.
kernel/futex/syscalls.c:do_get_robust_list()returns-EPERMunlessptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)passes.In-tree precedent
process_vm_readv(2)is the other syscall in this tree that reaches another task by tid, and it already applies the equivalent gate (pkg/sentry/syscalls/linux/sys_process_vm.go):Change
Add a
Task.CanTracecheck in read mode (attach == false, matchingPTRACE_MODE_READ) before reading another task's robust-list head, so a task cannot inspect the robust list of a task it cannot trace. Reading one's own list (ot == t, includingtid == 0) is unaffected.Three added lines, no new imports.
Scope
Hardening / Linux-parity fix. The disclosure is confined to the caller's PID namespace and does not cross the gVisor sandbox boundary.