Commit Graph

5813 Commits

Author SHA1 Message Date
Andrei Vagin 14d6cb4436 platform/kvm: fix a race condition in vCPU.unlock()
Right now, it contains the code:

  origState := atomic.LoadUint32(&c.state)
  atomicbitops.AndUint32(&c.state, ^vCPUUser)

The problem here is that vCPU.bounce that is called from another thread can add
vCPUWaiter when origState has been read but vCPUUser isn't cleared yet. In this
case, vCPU.unlock doesn't notify other threads about changes and c.bounce will
be stuck in the futex_wait call.

PiperOrigin-RevId: 389697411
2021-08-09 12:32:31 -07:00
Ghanan Gowripalan 34ec00c5e7 Run raw IP socket syscall tests on Fuchsia
+ Do not check for CAP_NET_RAW on Fuchsia

  Fuchsia does not support capabilities the same way Linux does. Instead
  emulate the check for CAP_NET_RAW by checking if a raw IP sockets may
  be created.

PiperOrigin-RevId: 389663218
2021-08-09 10:20:21 -07:00
Zach Koopmans c07dc3828a [SMT] Refactor runsc mititgate
Refactor mitigate to use /sys/devices/system/cpu/smt/control instead
of individual CPU control files.

PiperOrigin-RevId: 389215975
2021-08-06 11:10:54 -07:00
Rahat Mahmood 569f605f43 Correctly handle interruptions in blocking msgqueue syscalls.
Reported-by: syzbot+63bde04529f701c76168@syzkaller.appspotmail.com
Reported-by: syzbot+69866b9a16ec29993e6a@syzkaller.appspotmail.com
PiperOrigin-RevId: 389084629
2021-08-05 20:16:54 -07:00
Rahat Mahmood 15853bdc88 Replace unsafe use of fork() in msgqueue tests.
Msgqueue tests were using fork() to run create a separate thread of
execution for passing messages back and forth over a queue. However,
the child process after a fork() may only use async-signal-safe
functions, which at a minimum exclude gtest asserts.

Instead, use threads.

PiperOrigin-RevId: 389073744
2021-08-05 18:47:30 -07:00
Rahat Mahmood a72efae969 Skip mmap test cases if underlying FS doesn't support maps.
For file-based mmap tests, the underlying file system may not support
mmaps depending on the sandbox configuration. This is case when
caching is disabled for goferfs.

PiperOrigin-RevId: 389052722
2021-08-05 16:39:49 -07:00
Michael Pratt 99325baf5d Bump gVisor build tags to go1.19
Go's dev.typeparams branch already claims to be Go 1.18, so our !go1.18 build
tags breaking testing gVisor with that branch.

Normally I would not want to bump the build tags this early, but I plan to
extend checklinkname to check the assumptions in these files and remove the
build tags ASAP. So we just go ahead and bump the tags until then to unblock
testing.

PiperOrigin-RevId: 389037239
2021-08-05 15:25:00 -07:00
Kevin Krakauer caf9403f62 Automated rollback of changelist 384508720
PiperOrigin-RevId: 389035388
2021-08-05 15:16:24 -07:00
gVisor bot 42301ae7db Merge pull request #6372 from avagin:AlignedAtomic
PiperOrigin-RevId: 388985968
2021-08-05 11:45:57 -07:00
Adin Scannell 919a7da6d7 Reload the configuration during postinst rather than restarting.
Fixes #6408

PiperOrigin-RevId: 388978814
2021-08-05 11:17:44 -07:00
Andrei Vagin 376e890432 Reduce overhead of AlignedAtomic types
AlignedAtomicUint64 is 15 bytes and it takes 16 bytes in structures.  On
32-bit systems, variables and structure fields is guaranteed to be
32-bit aligned and this means that we need only 12 bytes to find 8
contiguous bytes.
2021-08-04 21:17:21 -07:00
Nicolas Lacasse 43e3d29b97 Implement PR_SET_CHILD_SUBREAPER when the calling task is PID 1.
In this case, the task is already a subreaper, so setting this bit is a noop.

Updates #2323

PiperOrigin-RevId: 388828034
2021-08-04 18:12:37 -07:00
Chong Cai b9780f96be Add verity_randread benchmark test
PiperOrigin-RevId: 388819374
2021-08-04 17:18:02 -07:00
Chong Cai cbb99336ce Add Fs controls
Add Fs controls and implement "cat" command.

PiperOrigin-RevId: 388812540
2021-08-04 16:44:11 -07:00
Adam Barth 681e541904 Use GetAbsoluteTestTmpdir() rather than hard-code "/tmp"
This change makes these tests easier to run on systems that have their temp
directory in another location.

PiperOrigin-RevId: 388601202
2021-08-03 19:54:35 -07:00
Chong Cai 8caf231cb1 Add Lifecycle controls
Also change runsc pause/resume cmd to access Lifecycle instead of
containerManager.

PiperOrigin-RevId: 388534928
2021-08-03 13:49:26 -07:00
gVisor bot 15d1d9fdfd Merge pull request #6398 from chenfengjin:fix_apt_install
PiperOrigin-RevId: 388533368
2021-08-03 13:41:17 -07:00
gVisor bot 8363a98c4f Merge pull request #6171 from sudo-sturbia:msgqueue/syscalls2
PiperOrigin-RevId: 388497055
2021-08-03 11:05:39 -07:00
Chong Cai ceab3327c5 Add verity open_read_close benchmark test
PiperOrigin-RevId: 388494554
2021-08-03 10:56:32 -07:00
Zyad A. Ali 6ef2f177fb Implement MSG_COPY option for msgrcv(2).
Implement Queue.Copy and add more tests for it.

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali eb638ee583 Implement stubs for msgsnd(2) and msgrcv(2).
Add support for msgsnd and msgrcv and enable syscall tests.

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali 930984a1aa Implement Queue.Receive.
Receive implements the behaviour of msgrcv(2) without the MSG_COPY flag.

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali 527c369299 Implement Queue.Send.
Send implements the functionality of msgsnd(2).

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali 61bb9b254e Add blocking and general tests for msgsnd(2) and msgrcv(2).
Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali addbf18979 Add non-blocking tests for msgsnd(2) and msgrcv(2).
Updates #135
2021-08-03 18:13:24 +02:00
Fengjin Chen 7b300f556c Add -y to install docker-ce when build image 2021-08-02 12:40:22 +08:00
gVisor bot 4f6c1f3093 Merge pull request #6350 from sudo-sturbia:cgroupfs
PiperOrigin-RevId: 388129112
2021-08-01 18:51:52 -07:00
Zeling Feng 979d6e7d77 Support RTM_DELLINK
This change will allow us to remove the default link in a packetimpact test so
we can reduce indeterministic behaviors as required in https://fxbug.dev/78430.
This will also help with testing #1388.

Updates #578, #1388.

PiperOrigin-RevId: 387896847
2021-07-30 15:41:36 -07:00
gVisor bot c9aac64e0f Merge pull request #6257 from zhlhahaha:2193-1
PiperOrigin-RevId: 387885663
2021-07-30 14:43:13 -07:00
Michael Pratt 62ea5c0a22 checklinkname: rudimentary type-checking of linkname directives
This CL introduces a 'checklinkname' analyzer, which provides rudimentary
type-checking that verifies that function signatures on the local and remote
sides of //go:linkname directives match expected values.

If the Go standard library changes the definitions of any of these function,
checklinkname will flag the change as a finding, providing an error informing
the gVisor team to adapt to the upstream changes. This allows us to eliminate
the majority of gVisor's forward-looking negative build tags, as we can catch
mismatches in testing [1].

The remaining forward-looking negative build tags are covering shared struct
definitions, which I hope to add to checklinkname in a future CL.

[1] Of course, semantics/requirements can change without the signature
changing, so we still must be careful, but this covers the common case.

PiperOrigin-RevId: 387873847
2021-07-30 13:42:15 -07:00
gVisor bot 095b0d8348 Explicitly encode the pcap packet headers to reduce CPU cost of pcap generation.
PiperOrigin-RevId: 387513118
2021-07-28 22:46:06 -07:00
Jamie Liu 72c2b74ac3 Add Uid/Gid/Groups fields to VFS2 /proc/[pid]/status.
For comparison:

```
$ docker run --rm -it ubuntu:focal bash -c 'cat /proc/self/status'
Name:	cat
Umask:	0022
State:	R (running)
Tgid:	1
Ngid:	0
Pid:	1
PPid:	0
TracerPid:	0
Uid:	0	0	0	0
Gid:	0	0	0	0
FDSize:	64
Groups:
NStgid:	1
NSpid:	1
NSpgid:	1
NSsid:	1
VmPeak:	    2660 kB
VmSize:	    2660 kB
VmLck:	       0 kB
VmPin:	       0 kB
VmHWM:	     528 kB
VmRSS:	     528 kB
...

$ docker run --runtime=runsc-vfs2 --rm -it ubuntu:focal bash -c 'cat /proc/self/status'
Name:	cat
State:	R (running)
Tgid:	1
Pid:	1
PPid:	0
TracerPid:	0
Uid:	0	0	0	0
Gid:	0	0	0	0
FDSize:	4
Groups:
VmSize:	10708 kB
VmRSS:	3124 kB
VmData:	316 kB
...
```

Fixes #6374

PiperOrigin-RevId: 387465655
2021-07-28 16:41:35 -07:00
gVisor bot 01f7dd442b Merge pull request #6358 from zhlhahaha:2232
PiperOrigin-RevId: 387442805
2021-07-28 14:54:22 -07:00
Chong Cai 6bf7d0514b Add verity read benchmark tests
PiperOrigin-RevId: 387431049
2021-07-28 14:03:46 -07:00
Jamie Liu 44efc282fe Lock gofer.dentry.dataMu before SetAttr RPC modifying file size.
PiperOrigin-RevId: 387427887
2021-07-28 13:50:12 -07:00
Howard Zhang d393d696b2 tunning hasSlot function and fix store wrong value in usedSlots
Make hasSlot scan allocated slot, rather than the whole slice.
It is supposed to store physicalStart in usedSlot.

Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2021-07-28 11:37:54 +08:00
Jamie Liu 964fb3ca76 Use go:build directives in generated files.
Build constraints are now inferred from go:build directives rather than +build
directives. +build directives are still emitted in generated files as required
in Go 1.16 and earlier.

Note that go/build/constraint was added in Go 1.16, so gVisor now requires Go
1.16.

PiperOrigin-RevId: 387240779
2021-07-27 18:14:05 -07:00
Andrei Vagin 68cf8cc9a2 Don't create an extra fd bitmap to allocate a new fd. 2021-07-27 13:16:02 +08:00
gVisor bot 9a96e00f0f Merge pull request #6292 from btw616:local-timezone
PiperOrigin-RevId: 386988406
2021-07-26 16:47:13 -07:00
Michael Pratt a42d3fd0ae Fix per-analyzer overrides of default-disabled groups
Currently behavior of config groups with `default: false` is buggy. The
intention is that adding an empty suppression section for that group to a
specific analyzer config should enable reporting for that analyzer. i.e.,

```
groups:
  - name: foo
    regex: "^foo/"
    default: false
global:
  ...
analyzers:
  asmdecl:
    foo: # Enabled.
```

This should enable the foo group only for asmdecl. Unfortunately, today the
actual behavior depends on the contents of the `global:` section. If `global:`
contains an entry for foo, then it will work as described. If `global:` does
_not_ contain an entry for foo, then the group default (disabled) always
applies and the individual analyzer options have no effect.

The cause of this is confusion in `AnalyzerConfig.shouldReport`, which doesn't
distinguish between explicit suppression via a global suppression/exclude and
simply having no configuration at all. Make this more explicit, so that the no
configuration case can continue to per-analyzer configuration before falling
back to the group default.

The last test case in the added test fails without this change.

This re-enables several opted-in analyzers for external dependencies, which
have gained a few more false positives to suppress.

PiperOrigin-RevId: 386904725
2021-07-26 10:26:43 -07:00
Jamie Liu 9ba8c40a3a Clean up logic for when a VFS2 gofer regular file close causes a flushf.
PiperOrigin-RevId: 386577891
2021-07-23 19:53:54 -07:00
Chong Cai d247938363 Add verity open benchmark test
PiperOrigin-RevId: 386533065
2021-07-23 14:35:42 -07:00
Rahat Mahmood 3d0a930005 Don't panic on user-controlled state in semaphore syscalls.
Reported-by: syzbot+beb099a67f670386a367@syzkaller.appspotmail.com
PiperOrigin-RevId: 386521361
2021-07-23 13:37:33 -07:00
Lucas Manning 0eea96057a Add support for SIOCGIFCONF ioctl in hostinet.
PiperOrigin-RevId: 386511818
2021-07-23 12:52:44 -07:00
Kevin Krakauer dc000e7b7a update bug number in loopback tests
PiperOrigin-RevId: 386511209
2021-07-23 12:47:23 -07:00
Kevin Krakauer ea0d9a8f48 buildkite: deflake itimer test
The self-admittedly arbitrary threshold of 20% of alarms being sent to the main
thread was being breached. I saw a run of of ~20-23% [1]. We should allow for a
little more breathing room.

1 - https://buildkite.com/gvisor/pipeline/builds/7400

PiperOrigin-RevId: 386503482
2021-07-23 12:07:57 -07:00
Rahat Mahmood c3c5c55d13 Handle EINTR from socket syscalls in send/recv benchmark.
The benchmark check fails if any of the socket syscalls fail with
EINTR. We see this manifest in S/R lifecycles since S/R has a high
probability of aborting these syscalls with EINTR.

PiperOrigin-RevId: 386480365
2021-07-23 10:24:39 -07:00
Ghanan Gowripalan aa26981700 Move socket_test_util to //test/util
...and rename the library to socket_util.

PiperOrigin-RevId: 386348306
2021-07-22 16:37:15 -07:00
Kevin Krakauer 24487496a3 VFS2: remove ext code
We opted to move forward with FUSE instead.

PiperOrigin-RevId: 386344258
2021-07-22 16:16:51 -07:00
Andrei Vagin 0690c25e06 kvm: set CR0.NE = 1
CR0.NE enables internal x87 floating point error reporting when set, else
enables PC style x87 error detection.

On AMD, the #MF exception isn't generated if CR0.NE isn't set.

PiperOrigin-RevId: 386340269
2021-07-22 15:55:31 -07:00