Commit Graph

30 Commits

Author SHA1 Message Date
Fabricio Voznika 8d426b7381 Parse mmap protection and flags in strace
PiperOrigin-RevId: 378712518
2021-06-10 12:51:43 -07:00
Dean Deng d496c285aa Add TODOs to old reference counting utility.
PiperOrigin-RevId: 372012795
2021-05-04 15:58:43 -07:00
Dean Deng 3b4674ffe0 Add logging option to leak checker.
Also refactor the template and CheckedObject interface to make this cleaner.

Updates #1486.

PiperOrigin-RevId: 339577120
2020-10-28 18:23:29 -07:00
Fabricio Voznika 778c367171 Fix panic in `runsc flags`
When printing flags, FlagSet.PrintDefaults compares the Zero
value to the flag default value. The Zero refs.LeakMode value
was panicking in String() because it didn't expect the default
to be used

Closes #4023

PiperOrigin-RevId: 333150836
2020-09-22 13:45:24 -07:00
Fabricio Voznika 32e7a54f7f Make flag propagation automatic
Use reflection and tags to provide automatic conversion from
Config to flags. This makes adding new flags less error-prone,
skips flags using default values (easier to read), and makes
tests correctly use default flag values for test Configs.

Updates #3494

PiperOrigin-RevId: 328662070
2020-08-26 20:24:41 -07:00
Dean Deng 79e7d0b06a Run GC before sandbox exit when leak checking is enabled.
Running garbage collection enqueues all finalizers, which are used by the
refs/refs_vfs2 packages to detect reference leaks. Note that even with GC,
there is no guarantee that all finalizers will be run before the program exits.
This is a best effort attempt to activate leak checks as much as possible.

Updates #3545.

PiperOrigin-RevId: 325834438
2020-08-10 10:33:22 -07:00
Dean Deng b918d97850 Add reference counting utility to VFS2.
The utility has several differences from the VFS1 equivalent:
- There are no weak references, which have a significant overhead
- In order to print useful debug messages with the type of the reference-
  counted object, we use a generic Refs object with the owner type as a
  template parameter. In vfs1, this was accomplished by storing a type name
  and caller stack directly in the ref count (as in vfs1), which increases the
  struct size by 6x. (Note that the caller stack was needed because fs types
  like Dirent were shared by all fs implementations; in vfs2, each impl has
  its own data structures, so this is no longer necessary.)

Updates #1486.

PiperOrigin-RevId: 325271469
2020-08-06 11:40:03 -07:00
Dean Deng b44408b40e Automated rollback of changelist 324906582
PiperOrigin-RevId: 324931854
2020-08-04 18:20:20 -07:00
Dean Deng 0500f84b6f Add reference counting utility to VFS2.
The utility has several differences from the VFS1 equivalent:
- There are no weak references, which have a significant overhead
- In order to print useful debug messages with the type of the reference-
  counted object, we use a generic Refs object with the owner type as a
  template parameter. In vfs1, this was accomplished by storing a type name
  and caller stack directly in the ref count (as in vfs1), which increases the
  struct size by 6x. (Note that the caller stack was needed because fs types
  like Dirent were shared by all fs implementations; in vfs2, each impl has
  its own data structures, so this is no longer necessary.)

As an example, the utility is added to tmpfs.inode.

Updates #1486.

PiperOrigin-RevId: 324906582
2020-08-04 15:48:27 -07:00
Nayana Bidari b2ae7ea1bb 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
Adin Scannell d29e59af9f Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00
Ian Gudger 27500d529f New sync package.
* Rename syncutil to sync.
* Add aliases to sync types.
* Replace existing usage of standard library sync package.

This will make it easier to swap out synchronization primitives. For example,
this will allow us to use primitives from github.com/sasha-s/go-deadlock to
check for lock ordering violations.

Updates #1472

PiperOrigin-RevId: 289033387
2020-01-09 22:02:24 -08:00
Kevin Krakauer 2a82d5ad68 Reorder BUILD license and load functions in gvisor.
PiperOrigin-RevId: 275139066
2019-10-16 16:40:30 -07:00
Michael Pratt df5d377521 Remove go_test from go_stateify and go_marshal
They are no-ops, so the standard rule works fine.

PiperOrigin-RevId: 268776264
2019-09-12 15:10:17 -07:00
gVisor bot 0789b9cc08 Merge pull request #655 from praveensastry:feature/runsc-ref-chk-leak
PiperOrigin-RevId: 266226714
2019-08-29 14:17:32 -07:00
praveensastry 7672eaae25 Add log prefix for better clarity 2019-08-22 22:52:43 +10:00
Ian Gudger 072d941e32 Add note to name logging mentioning trace logging should be enabled to debug.
PiperOrigin-RevId: 263194584
2019-08-13 12:49:18 -07:00
praveensastry 73985c6545 Fix the Stringer for leak mode 2019-08-09 17:13:06 +10:00
praveensastry 607be0585f Add option to configure reference leak checking 2019-08-06 01:15:48 +10:00
Adin Scannell 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
Ian Gudger 3446f4e29b Add stack trace printing to reference leak checking.
PiperOrigin-RevId: 255759891
2019-06-29 09:23:22 -07:00
Ian Gudger 45566fa4e4 Add finalizer on AtomicRefCount to check for leaks.
PiperOrigin-RevId: 255711454
2019-06-28 20:07:52 -07:00
Adin Scannell 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 Pratt 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
Michael Pratt 2a0c69b19f Remove license comments
Nothing reads them and they can simply get stale.

Generated with:
$ sed -i "s/licenses(\(.*\)).*/licenses(\1)/" **/BUILD

PiperOrigin-RevId: 231818945
Change-Id: Ibc3f9838546b7e94f13f217060d31f4ada9d4bf0
2019-01-31 11:12:53 -08:00
Ian Gudger 8fce67af24 Use correct company name in copyright header
PiperOrigin-RevId: 217951017
Change-Id: Ie08bf6987f98467d07457bcf35b5f1ff6e43c035
2018-10-19 16:35:11 -07:00
Adin Scannell c09f9acd7c Distinguish Element and Linker for ilist.
Furthermore, allow for the specification of an ElementMapper. This allows a
single "Element" type to exist on multiple inline lists, and work without
having to embed the entry type.

This is a requisite change for supporting a per-Inode list of Dirents.

PiperOrigin-RevId: 211467497
Change-Id: If2768999b43e03fdaecf8ed15f435fe37518d163
2018-09-04 09:19:11 -07:00
Zhaozhong Ni be7fcbc558 stateify: support explicit annotation mode; convert refs and stack packages.
We have been unnecessarily creating too many savable types implicitly.

PiperOrigin-RevId: 206334201
Change-Id: Idc5a3a14bfb7ee125c4f2bb2b1c53164e46f29a8
2018-07-27 10:17:21 -07:00
Rahat Mahmood 8878a66a56 Implement sysv shm.
PiperOrigin-RevId: 197058289
Change-Id: I3946c25028b7e032be4894d61acb48ac0c24d574
2018-05-17 15:06:19 -07:00
Googler d02b74a5dc Check in gVisor.
PiperOrigin-RevId: 194583126
Change-Id: Ica1d8821a90f74e7e745962d71801c598c652463
2018-04-28 01:44:26 -04:00