Commit Graph
462 Commits
Author SHA1 Message Date
Nicolas LacasseandgVisor bot 5530811417 Tweaks to containerd tests and helpers.
PiperOrigin-RevId: 565839195
2023-09-15 20:02:41 -07:00
Lucas ManningandgVisor bot 33c1b3856d Fix debug builds.
This change also adds instructions for using a debugger with syscall tests.

Fixes #9039

PiperOrigin-RevId: 563576842
2023-09-07 16:28:00 -07:00
Nevena KotlajaandgVisor bot eecc9d27f6 Migrate Automatic Exec Groups by adding a toolchain parameter to the affected actions
This is a step forward for the full migration of Automatic Exec Groups (AEGs). This change will be effective once AEGs are enabled.

In this CL I've added a toolchain_type to `toolchain` attribute of ctx.actions.{run, run_shell} since the Execution platform is selected on a toolchain type level, not on a rule level like before AEGs.

PiperOrigin-RevId: 560782417
2023-08-28 12:14:35 -07:00
gVisor bot 00a845b69f Merge pull request #8807 from jkowalski:allow-atomic-methods
PiperOrigin-RevId: 559151506
2023-08-22 10:26:32 -07:00
Jarek Kowalski 79d20045de checklocks: always allow calls to methods of atomic wrappers
This allows the use of wrappers such as atomic.Int32 introduced in
Go 1.19 without triggering the `unexpected call to atomic function`.
2023-08-21 18:58:18 -07:00
Etienne PerotandgVisor bot a6f64111fc Implement CLI tool to deploy the runsc installer in any Kubernetes cluster.
This adds a command-line tool named `gvisor_k8s_tool` that allows running the
`runsc` installer image as a DaemonSet in a Kubernetes cluster, either through
GKE or through `kubectl` configuration.

Example:

```shell
# Install using default kubectl context:
$ ./gvisor_k8s_tool install --cluster=kube: --image=my-runsc-installer

# Install using custom kubectl config and context:
$ KUBECONFIG=/tmp/myconfig ./gvisor_k8s_tool \
    install --cluster=kube:mycontext --image=my-runsc-installer

# Install in a GKE cluster:
$ ./gvisor_k8s_tool install \
    --cluster=gke:projects/myproject/locations/us-central1-a/clusters/mylittlecluster \
    --image=my-runsc-installer
```

PiperOrigin-RevId: 557945316
2023-08-17 15:00:01 -07:00
Jamie LiuandgVisor bot b427c9ee51 Fix expected import path for Go cmd/vendor packages.
PiperOrigin-RevId: 557273882
2023-08-15 15:44:34 -07:00
Etienne PerotandgVisor bot 3fb829f070 Add tool to generate a Go library that executes an embedded compressed binary.
This creates a `go_template` that can generate a `go_library` rule which
extracts a compressed binary to a temporary location, then executes it.

This is useful to implement `runsc` subcommands without requiring that these
subcommands' dependencies are linked into the main `runsc` binary.

PiperOrigin-RevId: 557270682
2023-08-15 15:32:43 -07:00
Shambhavi SrivastavaandgVisor bot 42d6cc0b02 Implementing CopyInN
PiperOrigin-RevId: 554542787
2023-08-07 11:42:20 -07:00
Andrei Vagin 51fa9984e7 Update bazel, rules_go and gazelle 2023-08-03 18:22:26 -07:00
Michael PrattandgVisor bot 418052deb7 Remove last remaining !go1.22 build tag
The last remaining !go1.22 build is protecting the definition of
pkg/sync.maptype, which is a copy of runtime.maptype. We need to ensure these
definitions match so we can safely access the hasher field.

At its core, this CL achieves this check by ensuring that
unsafe.Offsetof(maptype{}.Hasher) matches the offset in the runtime version of
the type.

Several things happen along the way to achieve this:

* As of May 2023, runtime.maptype is actually a type alias for
internal/abi.MapType. checkoffset was failing to record the offsets because it
skipped type aliases for no good reason. Simply removing the type alias check
is sufficient to make type aliases work. (This part of the CL is technically
unnecessary because this CL ultimately references internal/abi.MapType
directly in anticipation of removal of the type alias. But there is no reason
not to allow type aliases).

* The checkconst / checkoffset regexp unintentionally does not allow / in
package paths, even though the rest of the package supports /. Fix this.

* checkconst was comparing the literal AST expression string against the
runtime value (i.e., "unsafe.Offsetof(maptype{}.Hasher)" vs "72", which fails
comparison. Switch to getting the resolved constant value from the type
checker.

* nogo/check.importer only loads package facts on direct import (stored in
importer.cache). If a package is not directly imported ImportPackageFact will
not find the facts. Typically packages need to ensure they directly depend on
packages they want facts from (e.g., pkg/sync has a dummy import of runtime in
runtime.go). This doesn't work for internal/abi because we cannot directly
import an internal package. Work around this as a hack by unconditionally
"importing" internal/abi when analyzing any package.

With regard to the last point, not that the nogo/defs.bzl nogo integration only
provides facts from the direct dependencies and the entire stdlib (since the
stdlib is analyzed as one bundle). So this trick only works for a stdlib
package. A bazel package indirect dependency would be missing facts altogether.

PiperOrigin-RevId: 549999084
2023-07-21 11:22:36 -07:00
gVisor bot 988744c29a Internal change.
PiperOrigin-RevId: 538044944
2023-06-05 19:39:47 -07:00
Kevin KrakauerandgVisor bot 8a2b1df3f6 have gVisor use renamed buffer package
PiperOrigin-RevId: 537209194
2023-06-01 21:27:49 -07:00
Andrei VaginandgVisor bot b651cd69a3 Update packages
PiperOrigin-RevId: 532582853
2023-05-16 15:01:22 -07:00
Andrei VaginandgVisor bot 15ba1b7fd0 bazel: set the race config to build runsc-race
PiperOrigin-RevId: 532573939
2023-05-16 14:28:52 -07:00
Jamie LiuandgVisor bot a85c5bd4c6 Fix go_marshal array-of-structs bug.
PiperOrigin-RevId: 531231832
2023-05-11 09:57:56 -07:00
gVisor bot b6927ebbf1 Internal change.
PiperOrigin-RevId: 527062576
2023-04-25 13:44:27 -07:00
Andrei Vagin c4ac0ee726 gopath: switch to the archive mode
With the link mode, we see stale files from previous runs in
bazel-bin/gopath.
2023-03-13 16:25:09 -07:00
Andrei Vagin c302d5403e Stop using go_embed_data
It will be depricated in the next rules_go.
2023-03-08 15:05:58 -08:00
Adin ScannellandgVisor bot 2911d8c3b8 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Ayush RanjanandgVisor bot 50df619297 Use build tags to conditionally enable vfs.checkInvariants.
We don't want these checks in the production binary at all. Even though the
hardware branch predictor will do away with any runtime costs of the if
condition, the code under the "if checkInvariants {...}" could force escapes
to the heap. It could also increase function complexity, making it no longer
inlinable. And these invariant checks lie on hot code paths.

PiperOrigin-RevId: 513398208
2023-03-01 18:32:51 -08:00
Adin ScannellandgVisor bot 00cc9dcb0a Remove //tools/nogo:full flag.
With the latest nogo change, facts are no longer in the build paths. Since full
is only used to speed these paths (and is enabled for full analysis) the full
flag is now redundant and can be removed safely.

PiperOrigin-RevId: 511935530
2023-02-23 18:08:37 -08:00
Adin ScannellandgVisor bot f668e26ae9 Move from facts render to facts validation.
This allows fact information to be validated in the underlying source files,
but requires us to explicitly maintain this in appropriate version-tagged, and
architecture-tagged files. This is more explicit and safer.

This mechanism uses a special regular expression for matching a +checkconst
stanza to validate constant values, sizes and offsets. This applies to both Go
source files and assembly files.

PiperOrigin-RevId: 511867507
2023-02-23 13:17:49 -08:00
Ayush RanjanandgVisor bot a9936ad1a5 Fix apt-get exit code checking bug in tools/install_containerd.sh.
We were not fetching the exit code of apt-get correctly in case of failure.

PiperOrigin-RevId: 511818267
2023-02-23 10:16:36 -08:00
Adin ScannellandgVisor bot 3b1b8e17e3 Add GOOS and GOARCH to nogo findings.
PiperOrigin-RevId: 511689371
2023-02-22 22:14:13 -08:00
Adin ScannellandgVisor bot 0a8c022642 Silence excessive nogo noise.
PiperOrigin-RevId: 511679657
2023-02-22 21:19:17 -08:00
4acf987b22 Run tools/install_containerd.sh without sudo -H.
This script was being run as root. This script clones containerd and builds it.
On some Ubuntu versions, sudo(1) does not change the home directory. On
oldkernel machines from BuildKite, this script was running with
$HOME=/home/agent. As a result, root was writing and creating files in
/home/agent/.cache/go-build/. Other tests that call `go build` that were
scheduled to run on such VMs would fail due to permission issues because
/home/agent/.cache/go-build/ is owned by root.

Run the tools/install_containerd.sh script sudo -H so that the home directory
is set appropriately and all packages are built and installed with root user's
cache in /root/.cache/.

Also fixed lint errors in tools/install_containerd.sh and got rid of redundant
sudo calls. Added the check that the script must be run as root.

Co-authored-by: Andrei Vagin <[email protected]>
Acknowledgements: Andrei Vagin discovered this issue.
PiperOrigin-RevId: 511661564
2023-02-22 19:43:15 -08:00
Andrei VaginandgVisor bot a12c3a3f23 Open-sourcing the systrap platform.
The systrap platform like the ptrace platform uses stub processes to manage
the user address space. The difference is how they intercept system calls and
other events like memory faults, exceptions, etc.

In case of systrap, all events that have to be handled by the Sentry trigger
signals that are handled by a custom signal handler installed on stub
processes. The signal handler switches control to the Sentry.

Here are a few other optimizations:
* On x86, system calls can be replaced with a function call to remove overhead
  of signals.
* For fast interactions of sentry and stub processes, futex wait/wake can
  be a bottle neck, so we use a polling mode.

The platform is launched for the purpose of testing and gathering initial
feedback. It is not yet ready for use in production.

PiperOrigin-RevId: 511650064
2023-02-22 18:22:49 -08:00
Adin ScannellandgVisor bot f46bd4dfc0 Add assembly analysis to nogo.
This temporarily disables many asmdecl checks to minimize concurrent code
changes; these will be fixed separately.

PiperOrigin-RevId: 511619271
2023-02-22 15:57:50 -08:00
Adin ScannellandgVisor bot 6236f90e3a Fix type assertion failures with latest tools packages.
PiperOrigin-RevId: 511564602
2023-02-22 12:23:43 -08:00
Adin ScannellandgVisor bot 5dd4a95711 Process nogo targets across all architectures.
PiperOrigin-RevId: 511343590
2023-02-21 17:06:02 -08:00
Adin ScannellandgVisor bot 8f1c2481b7 Update checklinkname to avoid hard-coded names.
PiperOrigin-RevId: 510524474
2023-02-17 14:40:10 -08:00
Ayush RanjanandgVisor bot 574b815456 Statically link benchmark test binaries.
After update to Go 1.20 in 3217061ac5 ("Bump go version to 1.20"), the
benchmark jobs have been failing on BuildKite. This seems to be happening
because benchmark test binaries are built in Docker containers but are run on
the host. On some hosts, the glibc isn't compatible with glibc in our docker
container. So dynamically linked binaries may fail. Linking them statically
resolves this glibc compatibility issue.

As a result, this change also adds support for static test binaries to
tools/bazeldefs/go.bzl.

PiperOrigin-RevId: 510455271
2023-02-17 09:59:36 -08:00
gVisor bot 61bf8e5ce2 Merge pull request #8532 from avagin:bazel-disable-cgo
PiperOrigin-RevId: 510353175
2023-02-17 00:04:12 -08:00
Adin ScannellandgVisor bot a6f151dd10 Update dependencies use new Kubernetes libraries.
PiperOrigin-RevId: 510293880
2023-02-16 18:07:40 -08:00
Andrei Vagin 8a185d0511 Disable cgo by default
* We build all binaries in a build container but then we execute them in
  another evironments, so we don't want to have a dependency on glibc.

* runsc is build without cgo, so it looks reasonable to build tests with
  the same flags.

* If we build all packeges with the same flags, they all shares the same
  cache.

This change adds the race config to build with the race detector:
2023-02-16 17:22:07 -08:00
Andrei Vagin 3217061ac5 Bump go version to 1.20
Signed-off-by: Andrei Vagin <[email protected]>
2023-02-10 08:32:17 -08:00
Jamie LiuandgVisor bot d669c8000a checkinfo: Also skip vars whose type is a type parameter.
PiperOrigin-RevId: 507497705
2023-02-06 09:13:43 -08:00
Michael PrattandgVisor bot a43c102a95 Add constants to package-level fact
Unexported constants can end up unaddressable in objectpath and thus their
object facts get lost on fact import. Work around this by adding a
package-level fact which is a map of all constants to their value.

Remove the Value facts because it is confusing to have two ways to access the
same thing (especially when one only works sometimes).

PiperOrigin-RevId: 505153453
2023-01-27 10:38:13 -08:00
Adin ScannellandgVisor bot fdf016094d Remove broken links.
PiperOrigin-RevId: 504957670
2023-01-26 15:33:13 -08:00
Michael PrattandgVisor bot 4fce6fc93d Move procid to dynamic facts render
Based on cl/504066914, this generates the proper procid offsets at build time.

Package facts needs an update to properly skip underscore imports, which don't
have facts for some reason (because they are unnamed?).

Drop use of runtime.getprocid given that these generated code is pretty solid.

PiperOrigin-RevId: 504926257
2023-01-26 13:27:57 -08:00
Michael PrattandgVisor bot fc8c693bfe Enable analysis of packages using type parameters
Upstream analyzers support type parameters now, so we no longer need to skip
analysis.

PiperOrigin-RevId: 504383378
2023-01-24 14:56:58 -08:00
Adin ScannellandgVisor bot 234d1c6a9f Move goid to dynamic facts render.
This removes the need for ongoing tags.

This change requires some minor updates to remove dependency cycles, since
the goid package is a base library used by many internals (log, sync, etc.).

PiperOrigin-RevId: 504066914
2023-01-23 13:29:37 -08:00
gVisor bot 7e31274a88 Merge pull request #8095 from amarcu5:master
PiperOrigin-RevId: 503524045
2023-01-20 14:37:58 -08:00
Rahat MahmoodandgVisor bot 492bd3be54 stateify: Handle multi-name fields in struct declarations.
PiperOrigin-RevId: 500268939
2023-01-06 15:32:10 -08:00
Adin ScannellandgVisor bot 80962ae571 Use arch_genrule for arch-specific VDSO data.
Note that the select_arch macro changed in order to allow for its use within
a rule below arch_genrule. The command line settings were being manipulated in
a way that did not correctly propagate the select_arch select constraints.

PiperOrigin-RevId: 499651425
2023-01-04 18:36:14 -08:00
Andrei Vagin 7f94c77962 Update bazel packages
Signed-off-by: Andrei Vagin <[email protected]>
2022-11-29 14:01:41 -08:00
Etienne PerotandgVisor bot 5f9231cd71 Lockdep: Print more info in the "unbalanced unlock" case.
This CL does the following:

- Add the ability for nested locks to have names.
- Give names to all current uses of nested locks in the codebase.
- Truncate `lockdep` debug stack traces to avoid the clutter from the
  `lockdep` code itself
- Simplify `lockdep` to not longer require `classMap`.

PiperOrigin-RevId: 491486620
2022-11-28 17:53:09 -08:00
Fabricio VoznikaandgVisor bot 7614fc1d9d Add tool to analyze stuck task dumps
It creates a histogram of all unique stacks in the dump.
Then prints them in order, marking the ones that were stuck.

PiperOrigin-RevId: 488720415
2022-11-15 12:01:30 -08:00
Liam Miller-CushonandgVisor bot 227da4ac6e Internal change.
PiperOrigin-RevId: 488486099
2022-11-14 15:35:21 -08:00