Commit Graph
62 Commits
Author SHA1 Message Date
Jing ChenandgVisor bot 906efa4976 Implement setns CLONE_NEWUTS namespace type.
PiperOrigin-RevId: 554306089
2023-08-06 15:33:25 -07:00
Andrei VaginandgVisor bot 988a2981dc kernel: GetMountNamespace has to check that mntns isn't nil
Reported-by: [email protected]
PiperOrigin-RevId: 553568085
2023-08-03 13:14:04 -07:00
Andrei VaginandgVisor bot 2d37d59eeb kernel: don't use atomic pointers for task.netns
task.netns is always changed from a task goroutine under task.mu.

It means that we can access it without any locks from a task goroutine
we don't need to increment a reference counter in such cases.

In all other cases, we need to take task.mu.

PiperOrigin-RevId: 552913323
2023-08-01 14:04:53 -07:00
Andrei VaginandgVisor bot c5493106c6 Implement the setns syscall
This change introduces the nsfs file system. Each new namespace allocates
a new nsfs inode.

Here are reasons why we need these inodes:
* each namespace has to have an unique id.
* proc/pid/ns/ contains one entry for each namespace. Bind mounting one of
  the files in this directory to somewhere else in the filesystem keeps the
  corresponding namespace alive even if all processes currently in
  the namespace terminate.
* setns() allows the calling process to join an existing namespace specified
  by a file descriptor.

PiperOrigin-RevId: 550694515
2023-07-24 15:45:08 -07:00
Nicolas LacasseandgVisor bot 6733665148 Implement PR_{S,G}ET_CHILD_SUBREAPER.
Closes #2323

PiperOrigin-RevId: 548205854
2023-07-14 13:19:25 -07:00
Lucas ManningandgVisor bot 13b3dac594 Fix circular lock between filesystemRWMutex and taskSetRWMutex.
PiperOrigin-RevId: 500747195
2023-01-09 10:24:35 -08:00
Ayush RanjanandgVisor bot 7cac4e2732 Start cleaning up VFS1.
PiperOrigin-RevId: 486586072
2022-11-07 00:39:54 -08:00
Michael Pratt 58d7853d9f Set tg.exiting on group exit via exit(2)
Setting t.tg.exiting during PrepareGroupExit prevents a SIGKILL that
arrives while the task is zombied from changing the exit status (see
ThreadGroup.applySignalSideEffectsLocked).

However, PrepareExit does not set t.tg.exiting, meaning that if the last
task exits via exit(2), then a SIGKILL _can_ change the exit status.
This does not match Linux.

Fix this by detecting that we are the last task in PrepareExit and, if
so, going through the PrepareGroupExit path.

My initial version of this CL had Task.exitThreadGroup set t.tg.exiting
if it wasn't already set. This leaves a small window between return from
exit(2) and the start of the runExit state where a SIGKILL could still
change the exit status. While this window likely doesn't matter much in
practice, I suspect it is observable via ptrace, which could see exit(2)
return and assume that the exit status is fixed. I didn't test this
case, but figured it would be cleaner to just close the race window.

Fixes #7930.
2022-08-30 15:51:31 -04:00
Fabricio VoznikaandgVisor bot 59f1b78fd5 Rename seccheck.checkers to seccheck.sinks
Makes the naming consistent with the public configuration. There is no
behavior change.

Updates #4805

PiperOrigin-RevId: 462448505
2022-07-21 12:47:06 -07:00
Andrei VaginandgVisor bot 89c8e320fc Don't leak network namespaces
PiperOrigin-RevId: 454707336
2022-06-13 15:05:21 -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
Ayush RanjanandgVisor bot 2026e1f078 Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Fabricio VoznikaandgVisor bot c7b4708168 Fire clone point for thread creation
Thread creation tracking is required by Falco.

Updates #4805

PiperOrigin-RevId: 447003670
2022-05-06 09:28:44 -07:00
Zach KoopmansandgVisor bot 94557222ed Don't send security events for clone/exit tasks that are threads.
Two security messages points are PointCloneProcess and PointExitNotifyParent
(see pkg/sentry/seccheck/seccheck.go).
Both of these should only trigger when we have a process starting or exiting
respectively. Becuase of this, only send a start message if "clone()" is
called without CLONE_THREAD set, and only send an exit message if the thread
group (read: process) is exiting.

PiperOrigin-RevId: 445334328
2022-04-28 23:01:19 -07:00
Fabricio VoznikaandgVisor bot 78c6e57f48 Add sentry/task_exit point
Updates #4805

PiperOrigin-RevId: 445222912
2022-04-28 12:45:48 -07:00
Fabricio VoznikaandgVisor bot 81eaf62655 Refactor code to use seccheck.SendToCheckers
Updates #4805

PiperOrigin-RevId: 445017536
2022-04-27 18:04:14 -07:00
Fabricio VoznikaandgVisor bot 93023f5e60 Use proto structs for seccheck points
Given that in most cases points are serialized to another process,
point data is now created diretly into protos.

As part of this change, infrastructure to track optional and context
fields was created to facilitate addition of lots of Points which is
needed for upcomming of changes.

Updates #4805

Currently the SST code is converting seccheck protos into SST protos
in the sentry before sending it to the API. After this change, SST
checker will be changed to send seccheck protos to the API and the
API then converts these into SST on the way to pubsub.

PiperOrigin-RevId: 442688320
2022-04-18 19:03:15 -07:00
Andrei Vagin 66f52d13e9 Fix circular locking of kernel.taskMutex and kernfs.filesystemRWMutex
mntns.DecRef can be called without holding task.Mu.

panic: WARNING: circular locking detected: kernel.taskMutex -> kernfs.filesystemRWMutex:
goroutine 68 [running]:
gvisor.dev/gvisor/pkg/log.Stacks(0x40)
        pkg/log/log.go:313 +0x9e
gvisor.dev/gvisor/pkg/sync/locking.checkLock(0xc0000b2780, 0xc0000b3b80, {0x0, 0x0, 0x739539})
        pkg/sync/locking/lockdep.go:53 +0x14a
gvisor.dev/gvisor/pkg/sync/locking.AddGLock(0xc0000b2780, 0x0)
        pkg/sync/locking/lockdep.go:102 +0x27d
gvisor.dev/gvisor/pkg/sentry/fsimpl/kernfs.(*filesystemRWMutex).Lock(0xc0001e0230)
        bazel-out/k8-fastbuild-ST-1a50d7a562c6/bin/pkg/sentry/fsimpl/kernfs/filesystem_mutex.go:16 +0x34
gvisor.dev/gvisor/pkg/sentry/fsimpl/kernfs.(*Filesystem).Release(0xc0001e01e0, {0x158ef50, 0xc00046ca80})
        pkg/sentry/fsimpl/kernfs/filesystem.go:266 +0x67
gvisor.dev/gvisor/pkg/sentry/fsimpl/proc.(*filesystem).Release(0xc0001e01e0, {0x158ef50, 0xc00046ca80})
        pkg/sentry/fsimpl/proc/filesystem.go:104 +0x6b
gvisor.dev/gvisor/pkg/sentry/vfs.(*Filesystem).DecRef.func1()
        pkg/sentry/vfs/filesystem.go:81 +0xbd
gvisor.dev/gvisor/pkg/sentry/vfs.(*FilesystemRefs).DecRef(0xc00046ca80, 0xc0005bbd00)
        bazel-out/k8-fastbuild-ST-1a50d7a562c6/bin/pkg/sentry/vfs/filesystem_refs.go:131 +0x74
gvisor.dev/gvisor/pkg/sentry/vfs.(*Filesystem).DecRef(0xc000512500, {0x158ef50, 0xc00046ca80})
        pkg/sentry/vfs/filesystem.go:77 +0x5b
gvisor.dev/gvisor/pkg/sentry/vfs.(*Mount).destroy(0xc000312d80, {0x158ef50, 0xc00046ca80})
        pkg/sentry/vfs/mount.go:544 +0x159
gvisor.dev/gvisor/pkg/sentry/vfs.(*Mount).DecRef(0xc000312d80, {0x158ef50, 0xc00046ca80})
        pkg/sentry/vfs/mount.go:528 +0x99
gvisor.dev/gvisor/pkg/sentry/vfs.(*MountNamespace).DecRef.func1()
        pkg/sentry/vfs/mount.go:583 +0x157
gvisor.dev/gvisor/pkg/sentry/vfs.(*MountNamespaceRefs).DecRef(0x0, 0xc0005bbed0)
        bazel-out/k8-fastbuild-ST-1a50d7a562c6/bin/pkg/sentry/vfs/mount_namespace_refs.go:131 +0x74
gvisor.dev/gvisor/pkg/sentry/vfs.(*MountNamespace).DecRef(0xc00046d238, {0x158ef50, 0xc00046ca80})
        pkg/sentry/vfs/mount.go:571 +0x87
gvisor.dev/gvisor/pkg/sentry/kernel.(*runExitMain).execute(0xc0004932a8, 0xc00046ca80)
        pkg/sentry/kernel/task_exit.go:256 +0x27f
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run(0xc00046ca80, 0x1)
        pkg/sentry/kernel/task_run.go:95 +0x1ec
created by gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).Start
        pkg/sentry/kernel/task_start.go:345 +0x106

known lock chain: kernfs.filesystemRWMutex -> kernel.taskMutex

====== kernfs.filesystemRWMutex -> kernel.taskMutex =====
goroutine 68 [running]:
gvisor.dev/gvisor/pkg/log.Stacks(0x80)
        pkg/log/log.go:313 +0x9e
gvisor.dev/gvisor/pkg/sync/locking.AddGLock(0xc0000b3b80, 0x0)
        pkg/sync/locking/lockdep.go:105 +0x2b5
gvisor.dev/gvisor/pkg/sentry/kernel.(*taskMutex).Lock(0xc00046d238)
        bazel-out/k8-fastbuild-ST-1a50d7a562c6/bin/pkg/sentry/kernel/task_mutex.go:16 +0x34
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).WithMuLocked(0xc00046ca80, 0xc0005bad78)
        pkg/sentry/kernel/task.go:818 +0x3e
gvisor.dev/gvisor/pkg/sentry/fsimpl/proc.getMM(0x6245f69b)
        pkg/sentry/fsimpl/proc/task_files.go:48 +0x4d
gvisor.dev/gvisor/pkg/sentry/fsimpl/proc.(*taskOwnedInode).getOwner(0x1000000001ff, 0x0)
        pkg/sentry/fsimpl/proc/task.go:207 +0xb2
gvisor.dev/gvisor/pkg/sentry/fsimpl/proc.(*taskOwnedInode).Stat(0xc00049d2a8, {0x158ef50, 0xc00046ca80}, 0x0, {0x4, 0x0})
        pkg/sentry/fsimpl/proc/task.go:174 +0x117
gvisor.dev/gvisor/pkg/sentry/fsimpl/kernfs.(*Filesystem).StatAt(0xc0001e01e0, {0x158ef50, 0xc00046ca80}, 0xc00058c758, {0xb2a80, 0xc0})
        pkg/sentry/fsimpl/kernfs/filesystem.go:837 +0x262
gvisor.dev/gvisor/pkg/sentry/vfs.(*VirtualFilesystem).StatAt(0xc0005bb6f0, {0x158ef50, 0xc00046ca80}, 0xc0005bb6f0, 0xd9f54f, 0xc0005bb6c0)
        pkg/sentry/vfs/vfs.go:598 +0xe3
gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.fstatat(0xc00046ca80, 0x7, 0x0, 0xc0005bbc14, 0x100)
        pkg/sentry/syscalls/linux/vfs2/stat.go:104 +0x5d1
gvisor.dev/gvisor/pkg/sentry/syscalls/linux/vfs2.Newfstatat(0x65, {{0x7}, {0x56043e7212c0}, {0x56043e721230}, {0x100}, {0x100}, {0x1}})
        pkg/sentry/syscalls/linux/vfs2/stat.go:50 +0x5f
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).executeSyscall(0xc00046ca80, 0x106, {{0x7}, {0x56043e7212c0}, {0x56043e721230}, {0x100}, {0x100}, {0x1}})
        pkg/sentry/kernel/task_syscall.go:103 +0x2d7
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallInvoke(0xc00046ca80, 0xf6a220, {{0x7}, {0x56043e7212c0}, {0x56043e721230}, {0x100}, {0x100}, {0x1}})
        pkg/sentry/kernel/task_syscall.go:238 +0x57
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallEnter(0xc0000c9c70, 0x15a3038, {{0x7}, {0x56043e7212c0}, {0x56043e721230}, {0x100}, {0x100}, {0x1}})
        pkg/sentry/kernel/task_syscall.go:198 +0x85
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscall(0xc00046ca80)
        pkg/sentry/kernel/task_syscall.go:173 +0x38e
gvisor.dev/gvisor/pkg/sentry/kernel.(*runApp).execute(0xc0004932a8, 0xc00046ca80)
        pkg/sentry/kernel/task_run.go:254 +0x10fb
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run(0xc00046ca80, 0x1)
        pkg/sentry/kernel/task_run.go:95 +0x1ec
created by gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).Start
        pkg/sentry/kernel/task_start.go:345 +0x106
2022-03-31 15:42:34 -07:00
Etienne PerotandgVisor bot 2a64cbcfd6 Refactor task start and exit from a PID namespace into separate functions.
PiperOrigin-RevId: 426083905
2022-02-03 01:47:27 -08:00
Jamie LiuandgVisor bot febb57a041 Add caller for the ExitNotifyParent checkpoint.
PiperOrigin-RevId: 422925140
2022-01-19 16:02:20 -08:00
Andrei Vagin 3ba699a85f Implement RLIMIT_NPROC
This is simplified version without supporting hierarchical
user-namespace counters.

Signed-off-by: Andrei Vagin <[email protected]>
2021-12-23 13:52:05 -08:00
Adin ScannellandgVisor bot 4967b16af9 Update Waitable API.
Instead of passing the event mask at registratrion time, pass the mask as part
of the waiter. This makes the mask immutable and simplifies the architecture of
waiters. This is also necessary for a future fix that will allow the fdnotifier
to keep persistent entries, as opposed to requiring constant updates.

This change is intended to be a no-op in terms of function. The only exception
is signalfd, where this mask was abused. To handle this case, the operation of
signalfd changed to allow one layer of indirection.

PiperOrigin-RevId: 409702998
2021-11-13 12:54:39 -08:00
Zach KoopmansandgVisor bot 17d151514d [syserr] Move ConvertIntr function to linuxerr package
Move ConverIntr out of syserr package and delete an unused function.

PiperOrigin-RevId: 407676258
2021-11-04 14:55:52 -07:00
Nicolas LacasseandgVisor bot 35f1723116 Fix lock order violations: mm.mappingMu > Task.mu.
Document this ordering in mm/mm.go.

PiperOrigin-RevId: 393413203
2021-08-27 13:18:49 -07:00
Zach KoopmansandgVisor bot 83bf514e27 [syserror] Remove pkg syserror.
Removes package syserror and moves still relevant code to either linuxerr
or to syserr (to be later removed).

Internal errors are converted from random types to *errors.Error types used
in linuxerr. Internal errors are in linuxerr/internal.go.

PiperOrigin-RevId: 390724202
2021-08-13 17:16:52 -07:00
Jamie LiuandgVisor bot 62f45a109d Replace kernel.ExitStatus with linux.WaitStatus.
PiperOrigin-RevId: 383705129
2021-07-08 13:39:15 -07:00
Zach KoopmansandgVisor bot f033577349 [syserror] Update several syserror errors to linuxerr equivalents.
Update/remove most syserror errors to linuxerr equivalents. For list
of removed errors, see //pkg/syserror/syserror.go.

PiperOrigin-RevId: 382574582
2021-07-01 12:05:19 -07:00
Ayush RanjanandgVisor bot f7e133f133 [op] Move SignalInfo to abi/linux package.
Fixes #214

PiperOrigin-RevId: 378680466
2021-06-10 10:26:36 -07:00
Ayush RanjanandgVisor bot 2149f75c99 [op] Move SignalAct to abi/linux package.
There were also other duplicate definitions of the same struct that I have now
removed.

Updates #214

PiperOrigin-RevId: 378579954
2021-06-09 22:53:41 -07:00
Tamir DubersteinandgVisor bot 6d9d66465c Implement stringer for ExitStatus
PiperOrigin-RevId: 377370807
2021-06-03 14:18:22 -07:00
Rahat MahmoodandgVisor bot de97621de2 Implement cgroupfs.
A skeleton implementation of cgroupfs. It supports trivial cpu and
memory controllers with no support for hierarchies.

PiperOrigin-RevId: 366561126
2021-04-02 21:10:44 -07:00
Dean DengandgVisor bot f541f8580f Add YAMA security module restrictions on ptrace(2).
Restrict ptrace(2) according to the default configurations of the YAMA security
module (mode 1), which is a common default among various Linux distributions.
The new access checks only permit the tracer to proceed if one of the following
conditions is met:

a) The tracer is already attached to the tracee.

b) The target is a descendant of the tracer.

c) The target has explicitly given permission to the tracer through the
PR_SET_PTRACER prctl.

d) The tracer has CAP_SYS_PTRACE.

See security/yama/yama_lsm.c for more details.

Note that these checks are added to CanTrace, which is checked for
PTRACE_ATTACH as well as some other operations, e.g., checking a process'
memory layout through /proc/[pid]/mem.

Since this patch adds restrictions to ptrace, it may break compatibility for
applications run by non-root users that, for instance, rely on being able to
trace processes that are not descended from the tracer (e.g., `gdb -p`). YAMA
restrictions can be turned off by setting /proc/sys/kernel/yama/ptrace_scope
to 0, or exceptions can be made on a per-process basis with the PR_SET_PTRACER
prctl.

Reported-by: [email protected]
PiperOrigin-RevId: 359237723
2021-02-24 02:03:16 -08: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
Adin ScannellandgVisor bot 69f0412910 Remove existing nogo exceptions.
PiperOrigin-RevId: 347047550
2020-12-11 12:06:49 -08:00
Jamie LiuandgVisor bot 0dede4687f Rename kernel.TaskContext to kernel.TaskImage.
This reduces confusion with context.Context (which is also relevant to
kernel.Tasks) and is consistent with existing function kernel.LoadTaskImage().

PiperOrigin-RevId: 342167298
2020-11-12 17:39:19 -08:00
Dean DengandgVisor bot b2ee1accb2 [vfs2] Fix fork reference leaks.
PiperOrigin-RevId: 337919424
2020-10-19 13:20:13 -07:00
Dean DengandgVisor bot 61a20003c0 Fix shm reference leak.
All shm segments in an IPC namespace should be released once that namespace is
destroyed. Add reference counting to IPCNamespace so that once the last task
with a reference on it exits, we can trigger a destructor that will clean up
all shm segments that have not been explicitly freed by the application.

PiperOrigin-RevId: 337032977
2020-10-14 00:13:21 -07:00
Rahat MahmoodandgVisor bot c25d44649f Enable automated marshalling for the syscall package.
PiperOrigin-RevId: 331940975
2020-09-15 23:38:57 -07:00
Dean DengandgVisor bot e81484d89e Expose basic coverage information to userspace through kcov interface.
In Linux, a kernel configuration is set that compiles the kernel with a
custom function that is called at the beginning of every basic block, which
updates the memory-mapped coverage information. The Go coverage tool does not
allow us to inject arbitrary instructions into basic blocks, but it does
provide data that we can convert to a kcov-like format and transfer them to
userspace through a memory mapping.

Note that this is not a strict implementation of kcov, which is especially
tricky to do because we do not have the same coverage tools available in Go
that that are available for the actual Linux kernel. In Linux, a kernel
configuration is set that compiles the kernel with a custom function that is
called at the beginning of every basic block to write program counters to the
kcov memory mapping. In Go, however, coverage tools only give us a count of
basic blocks as they are executed. Every time we return to userspace, we
collect the coverage information and write out PCs for each block that was
executed, providing userspace with the illusion that the kcov data is always
up to date. For convenience, we also generate a unique synthetic PC for each
block instead of using actual PCs. Finally, we do not provide thread-specific
coverage data (each kcov instance only contains PCs executed by the thread
owning it); instead, we will supply data for any file specified by --
instrumentation_filter.

Also, fix issue in nogo that was causing pkg/coverage:coverage_nogo
compilation to fail.

PiperOrigin-RevId: 328426526
2020-08-25 16:28:45 -07:00
Nayana BidariandgVisor bot 4a8d0d3f20 Plumbing context.Context to DecRef() and Release().
context is passed to DecRef() and Release() which is
needed for SO_LINGER implementation.

PiperOrigin-RevId: 324672584
2020-08-03 13:36:05 -07:00
Nicolas LacasseandgVisor bot 86dc46113e Implement get/set_robust_list.
PiperOrigin-RevId: 322904430
2020-07-23 17:42:50 -07:00
gVisor bot 649b11f624 Plumb VFS2 inside the Sentry
- Added fsbridge package with interface that can be used to open
  and read from VFS1 and VFS2 files.
- Converted ELF loader to use fsbridge
- Added VFS2 types to FSContext
- Added vfs.MountNamespace to ThreadGroup

Updates #1623

PiperOrigin-RevId: 295183950
2020-02-14 11:12:47 -08:00
Adin ScannellandgVisor bot 25b09ce49b Add runtime tracing.
This adds meaningful annotations to the trace generated by the runtime/trace
package.

PiperOrigin-RevId: 284290115
2019-12-06 17:00:07 -08:00
Adin ScannellandgVisor bot 753da9604e Remove map from fd_map, change to fd_table.
This renames FDMap to FDTable and drops the kernel.FD type, which had an entire
package to itself and didn't serve much use (it was freely cast between types,
and served as more of an annoyance than providing any protection.)

Based on BenchmarkFDLookupAndDecRef-12, we can expect 5-10 ns per lookup
operation, and 10-15 ns per concurrent lookup operation of savings.

This also fixes two tangential usage issues with the FDMap. Namely, non-atomic
use of NewFDFrom and associated calls to Remove (that are both racy and fail to
drop the reference on the underlying file.)

PiperOrigin-RevId: 256285890
2019-07-02 19:28:59 -07:00
Adin ScannellandShentubot add40fd6ad Update canonical repository.
This can be merged after:
https://github.com/google/gvisor-website/pull/77
  or
https://github.com/google/gvisor-website/pull/78

PiperOrigin-RevId: 253132620
2019-06-13 16:50:15 -07:00
Michael PrattandShentubot 507a15dce9 Always wait on tracee children
After bf959931ddb88c4e4366e96dd22e68fa0db9527c ("wait/ptrace: assume
__WALL if the child is traced") (Linux 4.7), tracees are always eligible
for waiting, regardless of type.

PiperOrigin-RevId: 250399527
2019-05-30 12:05:46 -07:00
Michael PrattandShentubot 711290a7f6 Add support for wait(WNOTHREAD)
PiperOrigin-RevId: 249537694
Change-Id: Iaa4bca73a2d8341e03064d59a2eb490afc3f80da
2019-05-22 15:54:23 -07:00
Michael PrattandShentubot 4d52a55201 Change copyright notice to "The gVisor Authors"
Based on the guidelines at
https://opensource.google.com/docs/releasing/authors/.

1. $ rg -l "Google LLC" | xargs sed -i 's/Google LLC.*/The gVisor Authors./'
2. Manual fixup of "Google Inc" references.
3. Add AUTHORS file. Authors may request to be added to this file.
4. Point netstack AUTHORS to gVisor AUTHORS. Drop CONTRIBUTORS.

Fixes #209

PiperOrigin-RevId: 245823212
Change-Id: I64530b24ad021a7d683137459cafc510f5ee1de9
2019-04-29 14:26:23 -07:00
Nicolas LacasseandShentubot f4ce43e1f4 Allow and document bug ids in gVisor codebase.
PiperOrigin-RevId: 245818639
Change-Id: I03703ef0fb9b6675955637b9fe2776204c545789
2019-04-29 14:04:14 -07:00
Michael PrattandShentubot 4968dd1341 Cache ThreadGroups in PIDNamespace
If there are thousands of threads, ThreadGroupsAppend becomes very
expensive as it must iterate over all Tasks to find the ThreadGroup
leaders.

Reduce the cost by maintaining a map of ThreadGroups which can be used
to grab them all directly.

The one somewhat visible change is to convert PID namespace init
children zapping to a group-directed SIGKILL, as Linux did in
82058d668465 "signal: Use group_send_sig_info to kill all processes in a
pid namespace".

In a benchmark that creates N threads which sleep for two minutes, we
see approximately this much CPU time in ThreadGroupsAppend:

Before:

1 thread: 0ms
1024 threads: 30ms - 9130ms
4096 threads: 50ms - 2000ms
8192 threads: 18160ms
16384 threads: 17210ms

After:

1 thread: 0ms
1024 threads: 0ms
4096 threads: 0ms
8192 threads: 0ms
16384 threads: 0ms

The profiling is actually extremely noisy (likely due to cache effects),
as some runs show almost no samples at 1024, 4096 threads, but obviously
this does not scale to lots of threads.

PiperOrigin-RevId: 241828039
Change-Id: I17827c90045df4b3c49b3174f3a05bca3026a72c
2019-04-03 16:22:43 -07:00