Commit Graph

4926 Commits

Author SHA1 Message Date
Rahat Mahmood 9c198e5df4 Fix error handling on fusefs mount.
Don't propagate arbitrary golang errors up from fusefs because errors
that don't map to an errno result in a sentry panic.

Reported-by: syzbot+697cb635346e456fddfc@syzkaller.appspotmail.com
PiperOrigin-RevId: 346220306
2020-12-07 18:00:54 -08:00
Tamir Duberstein 1aeca3bfb7 Remove detritus
- Remove unused constants
- Correct function doc comment
- Remove useless cast
- Restore comment removed in an earlier change

PiperOrigin-RevId: 346205943
2020-12-07 16:34:39 -08:00
Zach Koopmans 6d30688bd7 Fix tags on benchmark targets.
PiperOrigin-RevId: 346203209
2020-12-07 16:20:12 -08:00
Arthur Sfez 615c3380d2 Export IGMP stats
PiperOrigin-RevId: 346197760
2020-12-07 15:52:25 -08:00
Sam Balana 0e5ba13b33 Remove stale comment
Removes comment lines about MaxUnsolicitedReportDelay. This is already
documented in the comment for GenericMulticastProtocolOptions.

PiperOrigin-RevId: 346185053
2020-12-07 14:51:35 -08:00
gVisor bot d574666dea Merge pull request #4908 from lubinszARM:pr_kvm_ext_dabt
PiperOrigin-RevId: 346143528
2020-12-07 11:48:36 -08:00
gVisor bot 7527371f0f Merge pull request #4874 from zhlhahaha:2022
PiperOrigin-RevId: 346134026
2020-12-07 11:11:17 -08:00
Tamir Duberstein 432964d035 Avoid shadowing `testbench` package
PiperOrigin-RevId: 346109185
2020-12-07 09:28:38 -08:00
Michael Pratt b28dc25aea Remove p9.fidRef.openedMu
openedMu has lock ordering violations. Most locks go through OpenedFlag(),
which is usually taken after renameMu and opMu. On the other hand, Tlopen takes
openedMu before renameMu and opMu (via safelyRead).

Resolving this violation is simple: just drop openedMu. The opened and
openFlags fields are already protected by opMu in most cases, renameMu (for
write) in one case (via safelyGlobal), and only in doWalk by neither.

This is a bit ugly because opMu is supposed to be a "semantic" lock, but it
works. I'm open to other suggestions.

Note that doWalk has a race condition where a FID may open after the open check
but before actually walking. This race existed before this change as well; it
is not clear if it is problematic.

PiperOrigin-RevId: 346108483
2020-12-07 09:23:17 -08:00
Peter Johnston eeb23531eb Support icmpv6 transport protocol
PiperOrigin-RevId: 346101076
2020-12-07 08:44:44 -08:00
gVisor bot a97ceec01b Merge pull request #4932 from lubinszARM:pr_test_exceptions
PiperOrigin-RevId: 345976554
2020-12-06 13:06:37 -08:00
Mithun Iyer 3075ede86e Fix zero receive window advertisements.
With the recent changes db36d948fa, we try
to balance the receive window advertisements between payload lengths vs
segment overhead length. This works fine when segment size are much
higher than the overhead, but not otherwise. In cases where the segment
length is smaller than the segment overhead, we may end up not
advertising zero receive window for long time and end up tail-dropping
segments. This is especially pronounced when application socket reads
are slow or stopped. In this change we do not grow the right edge of
the receive window for smaller segment sizes similar to Linux.
Also, we keep track of the socket buffer usage and let the window grow
if the application is actively reading data.

Fixes #4903

PiperOrigin-RevId: 345832012
2020-12-05 01:48:00 -08:00
Ghanan Gowripalan df2dbe3e38 Remove stack.ReadOnlyAddressableEndpointState
Startblock:
  has LGTM from asfez
  and then
  add reviewer tamird
PiperOrigin-RevId: 345815146
2020-12-04 22:04:23 -08:00
Jamie Liu b80021afd2 Overlay runsc regular file mounts with regular files.
Fixes #4991

PiperOrigin-RevId: 345800333
2020-12-04 19:13:24 -08:00
Jamie Liu 8a45c81616 Allow use of SeqAtomic with pointer-containing types.
Per runtime.memmove, pointers are always copied atomically, as this is required
by the GC. (Also, the init() safety check doesn't work because it gets renamed
to <prefix>init() by template instantiation.)

PiperOrigin-RevId: 345800302
2020-12-04 19:07:17 -08:00
Adin Scannell 7a1de8583d Remove invalid test case.
The next test case is perfectly valid, which creates a test directory
with appropriate permissions and ensures that you can't create a file.

This test case assumes that the root directory has certain permissions.
In this case, we may have EROFS instead of a permission error, but it's
perfectly plausible that no error occurs at all. The test is not valid.

PiperOrigin-RevId: 345764412
2020-12-04 15:11:55 -08:00
Adin Scannell 216abfb6df Update containerd tests for 1.4+ to 1.4.3.
PiperOrigin-RevId: 345764404
2020-12-04 15:05:46 -08:00
Adin Scannell 1371b73b4b Initialize has_tid for correctness.
PiperOrigin-RevId: 345763209
2020-12-04 14:59:54 -08:00
Zach Koopmans 4b198b18e1 Fix load-benchmarks-images call.
make load-benchmarks-images is empty with the deleted line.

PiperOrigin-RevId: 345741855
2020-12-04 13:14:09 -08:00
Bruno Dal Bo fd28ccfaa4 Introduce IPv4 options serializer and add RouterAlert to IGMP
PiperOrigin-RevId: 345701623
2020-12-04 10:10:56 -08:00
Jamie Liu 5c16707568 Avoid fallocate(FALLOC_FL_PUNCH_HOLE) when ManualZeroing is in effect.
PiperOrigin-RevId: 345696124
2020-12-04 09:46:41 -08:00
Michael Pratt 6708c8c97e Require sync.RWMutex to lock and unlock from the same goroutine
This is the RWMutex equivalent to the preceding sync.Mutex CL.

Updates #4804

PiperOrigin-RevId: 345681051
2020-12-04 08:20:08 -08:00
Jing Chen a78cef0ed7 Implement command IPC_INFO for semctl.
PiperOrigin-RevId: 345589628
2020-12-03 19:57:51 -08:00
Fabricio Voznika 9eb77281c4 Update containerd to 1.3.9
PiperOrigin-RevId: 345564927
2020-12-03 16:55:44 -08:00
gVisor bot cae3149b2a Internal change.
PiperOrigin-RevId: 345538979
2020-12-03 14:47:16 -08:00
Dean Deng bec8cea651 Surface usage message for `runsc do`.
c.Usage() only returns a string; f.Usage() will print the usage message.

PiperOrigin-RevId: 345500123
2020-12-03 11:47:30 -08:00
Adin Scannell 3186b50dff Add BuildKite pipeline.
PiperOrigin-RevId: 345490319
2020-12-03 11:06:57 -08:00
Peter Johnston 3ff1aef544 Make `stack.Route` thread safe
Currently we rely on the user to take the lock on the endpoint that owns the
route, in order to modify it safely. We can instead move
`Route.RemoteLinkAddress` under `Route`'s mutex, and allow non-locking and
thread-safe access to other fields of `Route`.

PiperOrigin-RevId: 345461586
2020-12-03 08:54:24 -08:00
Etienne Perot 6f60a2b0a2 Implement `fcntl` options `F_GETSIG` and `F_SETSIG`.
These options allow overriding the signal that gets sent to the process when
I/O operations are available on the file descriptor, rather than the default
`SIGIO` signal. Doing so also populates `siginfo` to contain extra information
about which file descriptor caused the event (`si_fd`) and what events happened
on it (`si_band`). The logic around which FD is populated within `si_fd`
matches Linux's, which means it has some weird edge cases where that value may
not actually refer to a file descriptor that is still valid.

This CL also ports extra S/R logic regarding async handler in VFS2.
Without this, async I/O handlers aren't properly re-registered after S/R.

PiperOrigin-RevId: 345436598
2020-12-03 06:20:29 -08:00
Adin Scannell 80552b936d Support partitions for other tests.
PiperOrigin-RevId: 345399936
2020-12-03 01:00:21 -08:00
Jamie Liu f933952687 Remove FileReadWriteSeeker from vfs.
Previous experience has shown that these types of wrappers tends to create two
kinds of problems: hidden allocations (e.g. each call to
FileReadWriteSeeker.Read/Write allocates a usermem.BytesIO on the heap) and
hidden lock ordering problems (e.g. VFS1 splice deadlocks). Since this is only
needed by fsimpl/verity, move it there.

PiperOrigin-RevId: 345377830
2020-12-02 21:50:57 -08:00
Jamie Liu f559db5690 Do not unconditionally allocate in kernel.FDTable.setAll().
`slice := *(*[]unsafe.Pointer)(...)` makes a copy of the slice header, which
then escapes because of the conditional `atomic.StorePointer(&f.slice, &slice)`
from table expansion. This occurs even when the table doesn't expand, and when
it can't (e.g. `close()` => `f.setAll(nil)`). Fix this by avoiding the copy
until after table expansion.

Before this CL:
```
TEXT pkg/sentry/kernel/kernel.(*FDTable).setAll(SB) pkg/sentry/kernel/fd_table_unsafe.go
  fd_table_unsafe.go:119        0x7f00005f50e0          64488b0c25f8ffffff              MOVQ FS:0xfffffff8, CX
  fd_table_unsafe.go:119        0x7f00005f50e9          483b6110                        CMPQ 0x10(CX), SP
  fd_table_unsafe.go:119        0x7f00005f50ed          0f864d040000                    JBE 0x7f00005f5540
  fd_table_unsafe.go:119        0x7f00005f50f3          4883c480                        ADDQ $-0x80, SP
  fd_table_unsafe.go:119        0x7f00005f50f7          48896c2478                      MOVQ BP, 0x78(SP)
  fd_table_unsafe.go:119        0x7f00005f50fc          488d6c2478                      LEAQ 0x78(SP), BP
  fd_table_unsafe.go:120        0x7f00005f5101          488b8424a8000000                MOVQ 0xa8(SP), AX
  fd_table_unsafe.go:120        0x7f00005f5109          4885c0                          TESTQ AX, AX
  fd_table_unsafe.go:120        0x7f00005f510c          7411                            JE 0x7f00005f511f
  fd_table_unsafe.go:120        0x7f00005f510e          488b8c24b0000000                MOVQ 0xb0(SP), CX
  fd_table_unsafe.go:120        0x7f00005f5116          4885c9                          TESTQ CX, CX
  fd_table_unsafe.go:120        0x7f00005f5119          0f8500040000                    JNE 0x7f00005f551f
  fd_table_unsafe.go:124        0x7f00005f511f          488d05da115700                  LEAQ 0x5711da(IP), AX
  fd_table_unsafe.go:124        0x7f00005f5126          48890424                        MOVQ AX, 0(SP)
  fd_table_unsafe.go:124        0x7f00005f512a          e8d19fa1ff                      CALL runtime.newobject(SB)
  fd_table_unsafe.go:124        0x7f00005f512f          488b7c2408                      MOVQ 0x8(SP), DI
  fd_table_unsafe.go:124        0x7f00005f5134          488b842488000000                MOVQ 0x88(SP), AX
  fd_table_unsafe.go:124        0x7f00005f513c          488b4820                        MOVQ 0x20(AX), CX
  fd_table_unsafe.go:124        0x7f00005f5140          488b5108                        MOVQ 0x8(CX), DX
  fd_table_unsafe.go:124        0x7f00005f5144          488b19                          MOVQ 0(CX), BX
  fd_table_unsafe.go:124        0x7f00005f5147          488b4910                        MOVQ 0x10(CX), CX
  fd_table_unsafe.go:124        0x7f00005f514b          48895708                        MOVQ DX, 0x8(DI)
  fd_table_unsafe.go:124        0x7f00005f514f          48894f10                        MOVQ CX, 0x10(DI)
  fd_table_unsafe.go:124        0x7f00005f5153          833df6e1120100                  CMPL $0x0, runtime.writeBarrier(SB)
  fd_table_unsafe.go:124        0x7f00005f515a          660f1f440000                    NOPW 0(AX)(AX*1)
  fd_table_unsafe.go:124        0x7f00005f5160          0f8589030000                    JNE 0x7f00005f54ef
  fd_table_unsafe.go:124        0x7f00005f5166          48891f                          MOVQ BX, 0(DI)
  fd_table_unsafe.go:124        0x7f00005f5169          48897c2470                      MOVQ DI, 0x70(SP)
  fd_table_unsafe.go:127        0x7f00005f516e          8bb424a0000000                  MOVL 0xa0(SP), SI
  fd_table_unsafe.go:127        0x7f00005f5175          39d6                            CMPL DX, SI
  fd_table_unsafe.go:127        0x7f00005f5177          0f8c5f030000                    JL 0x7f00005f54dc
  ...
```

After this CL:
```
TEXT pkg/sentry/kernel/kernel.(*FDTable).setAll(SB) pkg/sentry/kernel/fd_table_unsafe.go
  fd_table_unsafe.go:119        0x7f00005f50e0          64488b0c25f8ffffff              MOVQ FS:0xfffffff8, CX
  fd_table_unsafe.go:119        0x7f00005f50e9          488d4424e8                      LEAQ -0x18(SP), AX
  fd_table_unsafe.go:119        0x7f00005f50ee          483b4110                        CMPQ 0x10(CX), AX
  fd_table_unsafe.go:119        0x7f00005f50f2          0f868e040000                    JBE 0x7f00005f5586
  fd_table_unsafe.go:119        0x7f00005f50f8          4881ec98000000                  SUBQ $0x98, SP
  fd_table_unsafe.go:119        0x7f00005f50ff          4889ac2490000000                MOVQ BP, 0x90(SP)
  fd_table_unsafe.go:119        0x7f00005f5107          488dac2490000000                LEAQ 0x90(SP), BP
  fd_table_unsafe.go:120        0x7f00005f510f          488b9424c0000000                MOVQ 0xc0(SP), DX
  fd_table_unsafe.go:120        0x7f00005f5117          660f1f840000000000              NOPW 0(AX)(AX*1)
  fd_table_unsafe.go:120        0x7f00005f5120          4885d2                          TESTQ DX, DX
  fd_table_unsafe.go:120        0x7f00005f5123          0f8406040000                    JE 0x7f00005f552f
  fd_table_unsafe.go:120        0x7f00005f5129          488b9c24c8000000                MOVQ 0xc8(SP), BX
  fd_table_unsafe.go:120        0x7f00005f5131          4885db                          TESTQ BX, BX
  fd_table_unsafe.go:120        0x7f00005f5134          0f852b040000                    JNE 0x7f00005f5565
  fd_table_unsafe.go:124        0x7f00005f513a          488bb424a0000000                MOVQ 0xa0(SP), SI
  fd_table_unsafe.go:124        0x7f00005f5142          488b7e20                        MOVQ 0x20(SI), DI
  fd_table_unsafe.go:127        0x7f00005f5146          4c8b4708                        MOVQ 0x8(DI), R8
  fd_table_unsafe.go:127        0x7f00005f514a          448b8c24b8000000                MOVL 0xb8(SP), R9
  fd_table_unsafe.go:127        0x7f00005f5152          4539c1                          CMPL R8, R9
  fd_table_unsafe.go:127        0x7f00005f5155          0f8d4a020000                    JGE 0x7f00005f53a5
  ...
```

PiperOrigin-RevId: 345363242
2020-12-02 19:40:43 -08:00
Zeling Feng 8b692f5931 Make testutil.RandomID safe for concurrent uses
testutil.RandomID was using Rand.Read which is not safe for concurrent use.
It caused name conflicts in packetimpact tests when they are run in parallel.
Adding a mutex to protect the Rand.Read operation.

PiperOrigin-RevId: 345360062
2020-12-02 19:14:51 -08:00
Jamie Liu ed8bdf461b Consolidate most synchronization primitive linknames in the sync package.
PiperOrigin-RevId: 345359823
2020-12-02 19:08:32 -08:00
Arthur Sfez bdaae08ee2 Extract ICMPv4/v6 specific stats to their own types
This change lets us split the v4 stats from the v6 stats, which will be
useful when adding stats for each network endpoint.

PiperOrigin-RevId: 345322615
2020-12-02 15:17:20 -08:00
Arthur Sfez 6a26930eeb Abandon reassembly of a packet if fragments overlap
However, receiving duplicated fragments will not cause reassembly to
fail. This is what Linux does too:
https://github.com/torvalds/linux/blob/38525c6/net/ipv4/inet_fragment.c#L355

PiperOrigin-RevId: 345309546
2020-12-02 14:12:01 -08:00
Adin Scannell 24d6eb58e5 Skip generating an empty (broken) test case.
It's possible that all the cases in a given batch are excluded if
the offsets line up just right, which will cause the test to fail.
Don't generate an invalid test in this case.

PiperOrigin-RevId: 345276588
2020-12-02 11:40:27 -08:00
Ayush Ranjan 1375a87a20 [netstack] Refactor common utils out of netstack to socket package.
Moved AddressAndFamily() and ConvertAddress() to socket package from netstack.
This helps because these utilities are used by sibling netstack packages.

Such sibling dependencies can later cause circular dependencies. Common utils
shared between siblings should be moved up to the parent.

PiperOrigin-RevId: 345275571
2020-12-02 11:34:42 -08:00
Adin Scannell dbd4a6e3e5 Add BuildKite agent.
This has no effect on the continuous integration system, and simply
publishes a cached container image containing the agent and metrics
agent with known provenance.

PiperOrigin-RevId: 345274375
2020-12-02 11:28:26 -08:00
Adin Scannell 7ccb0b6a7c Fix chown test.
PiperOrigin-RevId: 345265342
2020-12-02 10:53:52 -08:00
Dean Deng b11f40db1e Clean up verity tests.
Refactor some utilities and rename some others for clarity.

PiperOrigin-RevId: 345247836
2020-12-02 09:34:15 -08:00
Adin Scannell 496851d27b Skip CanKillAllPIDs when running natively.
This is quite disruptive to run in some environments.

PiperOrigin-RevId: 345247206
2020-12-02 09:28:14 -08:00
Ayush Ranjan f156fb6531 [netstack] Add back EndpointInfo struct in tcp.
This was removed in an earlier commit. This should remain as it allows to add
tcp-only state to be exposed.

PiperOrigin-RevId: 345246155
2020-12-02 09:21:59 -08:00
Adin Scannell 9f02d2653b Fix containerd.sh for later Ubuntu and Debian-based distributions.
PiperOrigin-RevId: 345245285
2020-12-02 09:15:58 -08:00
Jing Chen b26dd6d9b7 Add /proc/sys/kernel/sem.
PiperOrigin-RevId: 345178956
2020-12-02 00:13:24 -08:00
Ghanan Gowripalan 41675ebc63 Deflake stack_test.TestRouterSolicitation
...by using the fake clock.

TestRouterSolicitation no longer runs its sub-tests in parallel now that
the sub-tests are not long-running - the fake clock simulates time
moving forward.

PiperOrigin-RevId: 345165794
2020-12-01 21:58:28 -08:00
Ghanan Gowripalan 0c49739422 Correctly lock when listing neighbor entries
PiperOrigin-RevId: 345162450
2020-12-01 21:34:52 -08:00
Adin Scannell 93d29719cc Drop jobs for bazel remote execution.
PiperOrigin-RevId: 345147980
2020-12-01 19:20:47 -08:00
Zeling Feng aa419cef4b Avoid wrong error messages
Stop showing wrong timeout values in packetimpact test error messages. e.g.
"got frames ... want ... during -123ms"

PiperOrigin-RevId: 345144938
2020-12-01 18:53:57 -08:00
Etienne Perot c140b0c493 Typo fix.
PiperOrigin-RevId: 345062676
2020-12-01 11:31:25 -08:00