9 Commits
Author SHA1 Message Date
gVisor bot d31070d68a Merge pull request #14534 from konstantin-s-bogom:setsid-orphan-deadlock-fix
PiperOrigin-RevId: 974150496
2026-08-31 17:02:06 -07:00
Konstantin Bogomolov 30fe0be955 Fix setsid deadlock when orphaning a shared-sighand process group
Scope the signal mutex to just the tg.tty clear in CreateSession, matching how
CreateProcessGroup, JoinProcessGroup, and the exit path already call
handleOrphan without holding a signal mutex.

CreateSession held tg.signalHandlers.mu across the entire process group
manipulation, but it only needs that mutex to clear tg.tty. When setsid(2)
orphans the caller's old process group, decRefWithParent calls handleOrphan,
which locks the signal mutex of every thread group remaining in the group. If
the caller itself, or a sibling thread group that shares the caller's
SignalHandlers (created via clone(CLONE_VM|CLONE_SIGHAND) without CLONE_THREAD),
is still a member, handleOrphan re-locks the already-held, non-reentrant mutex
and the sentry deadlocks while holding TaskSet.mu, freezing the whole sandbox.

Regression test hangs prior to the fix.
2026-08-31 14:29:57 -07:00
gVisor bot 31aea838a6 processes test: Disable HWASan for ExecSwapPreClone.
If we enable HWASan, the stack_ptr of the new thread is tagged. That is invalid.

PiperOrigin-RevId: 917944632
2026-05-19 11:45:55 -07:00
Jamie LiuandgVisor bot d588ae7740 Fix some processes_test flakes.
- Do not return from ExecSwapPreClone(), which is called from a fork()ed
  process.

- Use TEST_*CHECK() rather than ASSERT_*() in some places requiring
  async-signal-safety.

- Use ReadFd/WriteFd() rather than bare read/write(), to handle EINTR.

PiperOrigin-RevId: 632019219
2024-05-08 21:08:23 -07:00
Andrei VaginandgVisor bot 45199f7e70 systrap: track the spinning queue length in a separate counter
The current implementation has a race condition resulting in the skipping of
one element in the queue array. When retrieving objects from the queue, the
stub code can get stuck in an infinite loop due to unexpected unused elements.

Updates #10000

PiperOrigin-RevId: 608679165
2024-02-20 11:35:21 -08:00
Andrei VaginandgVisor bot d39e044ef8 tests: don't use raw threads
We have to use pthreads if we want to use other libc calls.

PiperOrigin-RevId: 453851326
2022-06-08 23:57:50 -07:00
Etienne PerotandgVisor bot 56f17b6656 Fix flakiness in Processes::ExecSwapThreadGroupLeader.
This closes the write end of the pipe earlier in the main test
body, and avoids allocations after fork+clone when building up
the `execve` array's flags.

There may be more obvious ways to do this, let me know :)

PiperOrigin-RevId: 453809395
2022-06-08 18:02:53 -07:00
Etienne PerotandgVisor bot 0316a1702f Cache each thread group's TID within their own namespace.
This avoids requiring a lock in `ThreadGroup.ID`, which in turn breaks the
following lock cycle:
`kernel.taskSetRWMutex` -> `kernel.taskMutex` -> `mm.metadataMutex`
-> `mm.mappingRWMutex` -> `kernel.taskSetRWMutex`

(Also, less locking within `createVMALocked` is probably for the better in
general.)

PiperOrigin-RevId: 449588573
2022-05-18 15:14:14 -07:00
Andrei VaginandgVisor bot 503fb7d76d kernel: reparentLocked has to update children maps of old and new parents
Reported-by: [email protected]
PiperOrigin-RevId: 356536113
2021-02-09 10:37:04 -08:00