Commit Graph

2910 Commits

Author SHA1 Message Date
Andrei Vagin 37f863f628 tcp: handle listen after shutdown properly
Right now, sentry panics in this case:
panic: close of nil channel

goroutine 67 [running]:
pkg/tcpip/transport/tcp/tcp.(*endpoint).listen(0xc0000ce000, 0x9, 0x0)
        pkg/tcpip/transport/tcp/endpoint.go:2208 +0x170
pkg/tcpip/transport/tcp/tcp.(*endpoint).Listen(0xc0000ce000, 0x9, 0xc0003a1ad0)
        pkg/tcpip/transport/tcp/endpoint.go:2179 +0x50

Fixes #2468

PiperOrigin-RevId: 307896725
2020-04-22 14:17:11 -07:00
Adin Scannell c31641150d Add GitHub pull request template.
This just provides some sane reminders and ticks a box on the GitHub UI. This
change also cleans up the issue template, as there is already an automatic
link to the repository's security disclosure policy.

PiperOrigin-RevId: 307868833
2020-04-22 12:12:49 -07:00
Adin Scannell a27d6329df Remove unnecessary kokoro configurations.
PiperOrigin-RevId: 307841689
2020-04-22 10:15:10 -07:00
Eyal Soha 6d23673e10 Add comments about deepcopy in Layer.incoming()
PiperOrigin-RevId: 307812340
2020-04-22 07:28:39 -07:00
Dean Deng 5e3596a6b8 Fix set/getsockopt in vfs2 override.
Updates #1476.

PiperOrigin-RevId: 307726055
2020-04-21 19:03:20 -07:00
Dean Deng 80d0a95819 Update gofer.filesystem.BoundEndpointAt() to allow path resolution.
Even though BoundEndpointAt is not yet implemented for gofer fs, allow path
resolution errors to be returned so that we can jump to tmpfs, where it is
implemented.

Updates #1476.

PiperOrigin-RevId: 307718335
2020-04-21 18:00:00 -07:00
gVisor bot 0e013d8b00 Don't ignore override if it is longer than layerStates
PiperOrigin-RevId: 307708653
2020-04-21 16:55:28 -07:00
Fabricio Voznika 37e01fd2ea Misc VFS2 fixes
- Fix defer operation ordering in kernfs.Filesystem.AccessAt()
- Add AT_NULL entry in proc/pid/auvx
- Fix line padding in /proc/pid/maps
- Fix linux_dirent serialization for getdents(2)
- Remove file creation flags from vfs.FileDescription.statusFlags()

Updates #1193, #1035

PiperOrigin-RevId: 307704159
2020-04-21 16:31:53 -07:00
gVisor bot eba086642e Merge pull request #1818 from lubinszARM:pr_signal_1
PiperOrigin-RevId: 307680200
2020-04-21 14:26:08 -07:00
Adin Scannell 89822a4461 Move to GitHub's new issue templates.
This allows us to specify a richer configuration for the issue template, that
effectively moves a lot of the "metadata" from the template itself to the main
issue page.

PiperOrigin-RevId: 307666509
2020-04-21 13:14:09 -07:00
Jamie Liu 9b5e305e05 Remove filesystem structure from vfs.Dentry.
This change:

- Drastically simplifies the synchronization model: filesystem structure is
  both implementation-defined and implementation-synchronized.

- Allows implementations of vfs.DentryImpl to use implementation-specific
  dentry types, reducing casts during path traversal.

- Doesn't require dentries representing non-directory files to waste space on a
  map of children.

- Allows dentry revalidation and mount lookup to be correctly ordered (fixed
  FIXME in fsimpl/gofer/filesystem.go).

- Removes the need to have two separate maps in gofer.dentry
  (dentry.vfsd.children and dentry.negativeChildren) for positive and negative
  lookups respectively.

//pkg/sentry/fsimpl/tmpfs/benchmark_test.go:
name                        old time/op  new time/op  delta
VFS2TmpfsStat/1-112          172ns ± 4%   165ns ± 3%   -4.08%  (p=0.002 n=9+9)
VFS2TmpfsStat/2-112          199ns ± 3%   195ns ±10%     ~     (p=0.132 n=8+9)
VFS2TmpfsStat/3-112          230ns ± 2%   216ns ± 2%   -6.15%  (p=0.000 n=8+8)
VFS2TmpfsStat/8-112          390ns ± 2%   358ns ± 4%   -8.33%  (p=0.000 n=9+8)
VFS2TmpfsStat/64-112        2.20µs ± 3%  2.01µs ± 3%   -8.48%  (p=0.000 n=10+8)
VFS2TmpfsStat/100-112       3.42µs ± 9%  3.08µs ± 2%   -9.82%  (p=0.000 n=9+8)
VFS2TmpfsMountStat/1-112     278ns ± 1%   286ns ±15%     ~     (p=0.712 n=8+10)
VFS2TmpfsMountStat/2-112     311ns ± 4%   298ns ± 2%   -4.27%  (p=0.000 n=9+8)
VFS2TmpfsMountStat/3-112     339ns ± 3%   330ns ± 9%     ~     (p=0.070 n=8+9)
VFS2TmpfsMountStat/8-112     503ns ± 3%   466ns ± 3%   -7.38%  (p=0.000 n=8+8)
VFS2TmpfsMountStat/64-112   2.53µs ±16%  2.17µs ± 7%  -14.19%  (p=0.000 n=10+9)
VFS2TmpfsMountStat/100-112  3.60µs ± 4%  3.30µs ± 8%   -8.33%  (p=0.001 n=8+9)

Updates #1035

PiperOrigin-RevId: 307655892
2020-04-21 12:18:07 -07:00
Kevin Krakauer 639c8dd808 Restore euid upon test finish
PiperOrigin-RevId: 307638329
2020-04-21 10:58:00 -07:00
gVisor bot 8b72623e6a Internal change.
PiperOrigin-RevId: 307622320
2020-04-21 09:44:00 -07:00
Dave Bailey 7c0f3bc857 Sentry metrics updates.
Sentry metrics with nanoseconds units are labeled as such, and non-cumulative
sentry metrics are supported.

PiperOrigin-RevId: 307621080
2020-04-21 09:36:43 -07:00
gVisor bot 120d3b50f4 Automated rollback of changelist 307477185
PiperOrigin-RevId: 307598974
2020-04-21 07:16:30 -07:00
Adin Scannell c615aafa21 Add internal nogo analysis & checkescape tool.
See tools/nogo/README.md.

The checkescape tool is able to perform recursive escape analysis, using the
actual generated binary to confirm the results produced by the compiler itself.

As an initial use case, this replaces the manual escape analysis tests used for
go_marshal, and validates that the CopyIn and CopyOut paths will not require
any allocation or stack splits.

Updates #2243

PiperOrigin-RevId: 307532986
2020-04-20 20:58:20 -07:00
Ghanan Gowripalan 782041509f Prevent race when reassigning CancellableTimer
Capture a timer's locker for each instance of a CancellableTimer so that
reassigning a tcpip.CancellableTimer does not cause a data race.

Reassigning a tcpip.CancellableTimer updates its underlying locker. When
a timer fires, it does a read of the timer's locker variable to lock it.
This read of the locker was not synchronized so a race existed where one
goroutine may reassign the timer (updating the locker) and another
handles the timer firing (attempts to lock the timer's locker).

Test: tcpip_test.TestCancellableTimerReassignment
PiperOrigin-RevId: 307499822
2020-04-20 16:32:44 -07:00
Adin Scannell 1a597e01be Add a functional vm_test for root_test.
This change renames the tools/images directory to tools/vm for clarity, and
adds a functional vm_test. Sharding is also added to the same test, and some
documentation added around key flags & variables to describe how they work.

Subsequent changes will add vm_tests for other cases, such as the runtime tests.

PiperOrigin-RevId: 307492245
2020-04-20 15:48:27 -07:00
gVisor bot 07b1b4cc98 Merge pull request #2313 from kevinGC:firstn
PiperOrigin-RevId: 307477185
2020-04-20 14:31:12 -07:00
Ting-Yu Wang 470633d7e9 Fix release.sh. git commands need to be run in git repo.
PiperOrigin-RevId: 307458938
2020-04-20 12:58:32 -07:00
gVisor bot 763d16f912 Merge pull request #2060 from xiaobo55x:rseq
PiperOrigin-RevId: 307453436
2020-04-20 12:31:22 -07:00
Adin Scannell 9ba3086d9d Move runtime_tests.sh to align with other scripts.
PiperOrigin-RevId: 307435879
2020-04-20 11:08:59 -07:00
Jamie Liu e72ce8cce4 Change lingering uses of "memfs" in fsimpl/tmpfs to "tmpfs".
PiperOrigin-RevId: 307422746
2020-04-20 10:10:35 -07:00
Dean Deng 1a940f2b6c Resolve issue with file mode for host fds.
Instead of plumbing error through kernfs.Inode.Mode, panic if err != nil.
The errors that can result from an fstat syscall all indicate that something
is fundamentally wrong, and panicking should be acceptable.

PiperOrigin-RevId: 307406847
2020-04-20 08:51:47 -07:00
Eyal Soha db2a60be67 Don't accept segments outside the receive window
Fixed to match RFC 793 page 69.

Fixes #1607

PiperOrigin-RevId: 307334892
2020-04-19 22:16:14 -07:00
Eyal Soha 08b2fd9bc2 Convert tcp_user_timeout test from packetdrill to packetimpact.
PiperOrigin-RevId: 307328289
2020-04-19 20:49:06 -07:00
gVisor bot ea9bb1c4ea Merge pull request #2235 from xiaobo55x:pcid
PiperOrigin-RevId: 307166482
2020-04-17 22:24:14 -07:00
Adin Scannell 9a233c94f1 Fix watchdog skipStack: the meaning was reversed.
PiperOrigin-RevId: 307166317
2020-04-17 22:19:47 -07:00
Kevin Krakauer e838290e67 prlimit: don't check credentials on self
prlimit was erroneously comparing UIDs and GIDs when getting/setting a process'
own limits. From the manpage:

To set or get the resources of a process other than itself, the caller must have
the CAP_SYS_RESOURCE capability, or the real, effective, and saved set user IDs
of the target process must match the real user ID of the caller and the real,
effective, and saved set group IDs of the target process must match the real
group ID of the caller.

PiperOrigin-RevId: 307127266
2020-04-17 15:33:05 -07:00
Ghanan Gowripalan 486759a37d Support NDP DNS Search List option
Inform the netstack integrator when the netstack receives an NDP Router
Advertisement message with the NDP DNS Search List option with at least
one domain name. The stack will not maintain any state related to the
search list - the integrator is expected to maintain any required state
and invalidate domain names after their lifetime expires, or refresh the
lifetime when a new one is received for a known domain name.

Test:
- header_test.TestNDPDNSSearchListOption
- header_test.TestNDPDNSSearchListOptionSerialize
- header_test.TestNDPSearchListOptionDomainNameLabelInvalidSymbols
- header_test.TestNDPOptionsIterCheck
- stack_test.TestNDPDNSSearchListDispatch
PiperOrigin-RevId: 307109375
2020-04-17 13:56:19 -07:00
Fabricio Voznika a80cd43023 Add test name to boot and gofer log files
This is to make easier to find corresponding logs in
case test fails.

PiperOrigin-RevId: 307104283
2020-04-17 13:28:54 -07:00
Kevin Krakauer a551add5d8 Remove View.First() and View.RemoveFirst()
These methods let users eaily break the VectorisedView abstraction, and
allowed netstack to slip into pseudo-enforcement of the "all headers are
in the first View" invariant. Removing them and replacing with PullUp(n)
breaks this reliance and will make it easier to add iptables support and
rework network buffer management.

The new View.PullUp(n) method is low cost in the common case, when when
all the headers fit in the first View.
2020-04-17 13:25:57 -07:00
gVisor bot 80deebb0bf Merge pull request #1978 from lubinszARM:pr_signal_mm
PiperOrigin-RevId: 307078788
2020-04-17 11:18:11 -07:00
Zach Koopmans 12bde95635 Get /bin/true to run on VFS2
Included:
- loader_test.go RunTest and TestStartSignal VFS2
- container_test.go TestAppExitStatus on VFS2
- experimental flag added to runsc to turn on VFS2

Note: shared mounts are not yet supported.
PiperOrigin-RevId: 307070753
2020-04-17 10:39:19 -07:00
Ting-Yu Wang 4a818d6437 proc net test: Annotate disable-save test with NoRandomSave.
PiperOrigin-RevId: 307069884
2020-04-17 10:34:57 -07:00
Tamir Duberstein 6c225ea2d5 Allow caller-defined sinks for packet sniffing.
PiperOrigin-RevId: 307053624
2020-04-17 09:05:16 -07:00
Tamir Duberstein b4de018a67 Permit setting unknown options
This previously changed in 305699233, but this behaviour turned out to
be load bearing.

PiperOrigin-RevId: 307033802
2020-04-17 06:41:38 -07:00
Bin Lu fe001edb14 Arm64: VDSO support for signal
The vdso is enabled, so we can use the sigreturn trampolines
the vdso provides in arch module.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-04-17 05:07:59 -04:00
Jamie Liu f03996c5e9 Implement pipe(2) and pipe2(2) for VFS2.
Updates #1035

PiperOrigin-RevId: 306968644
2020-04-16 19:27:03 -07:00
Ghanan Gowripalan f367cf8e67 Drop invalid NDP NA messages
Better validate NDP NAs options before updating the link address cache.

Test: stack_test.TestNeighorAdvertisementWithTargetLinkLayerOption
PiperOrigin-RevId: 306962924
2020-04-16 18:33:20 -07:00
Tamir Duberstein e7dcd942ac Properly delegate Wait
PiperOrigin-RevId: 306959393
2020-04-16 18:06:55 -07:00
Mithun Iyer 3b05f576d7 Reset pending connections on listener shutdown.
When the listening socket is read shutdown, we need to reset all pending
and incoming connections. Ensure that the endpoint is not cleaned up
from the demuxer and subsequent bind to same port does not go through.

PiperOrigin-RevId: 306958038
2020-04-16 17:58:08 -07:00
Ghanan Gowripalan b33c3bb4a7 Return detailed errors when iterating NDP options
Test: header_test.TestNDPOptionsIterCheck
PiperOrigin-RevId: 306953867
2020-04-16 17:27:19 -07:00
Bhasker Hariharan 0eda0104a5 Fix data race in tcp_test.
This change makes SynRcvdCountThreshold and the global synRcvdCount into a stack
configurable value. This is required because in cases like mod_proxy which
create multiple Stack instances the count will be a global value that impacts
all Stack instances.

Further the tests relied on modifying the global threshold to simulate tests
where we want to verify SYN cookie based behaviour. This lead to data races due
to the global being modified/read without locks or atomics.

PiperOrigin-RevId: 306947723
2020-04-16 16:49:18 -07:00
Eyal Soha 75e864fc75 Use multierr in packetimpact Connection.Close()
PiperOrigin-RevId: 306930652
2020-04-16 15:15:50 -07:00
Fabricio Voznika 5a8ee1beee Preserve log FD after execve
PiperOrigin-RevId: 306908296
2020-04-16 13:17:00 -07:00
gVisor bot eb7b1903e0 Test TCP behavior when receiving unacceptable segment in CLOSE_WAIT
TCP, in CLOSE-WAIT state, MUST return ACK with proper SEQ and ACK numbers after
recv a seg with OTW SEQ or unacc ACK number, and remain in same state. If the
connection is in a synchronized state, any unacceptable segment (out of window
sequence number or unacceptable acknowledgment number) must elicit only an empty
acknowledgment segment containing the current send-sequence number and an
acknowledgment indicating the next sequence number expected to be received, and
the connection remains in the same state.

PiperOrigin-RevId: 306897984
2020-04-16 12:22:17 -07:00
Fabricio Voznika 28399818fc Make ExtractErrno a function
PiperOrigin-RevId: 306891171
2020-04-16 11:49:27 -07:00
Eyal Soha 09c7e3f6e4 Add tests for segments outside the receive window.
The tests are based on RFC 793 page 69.

Updates #1607

PiperOrigin-RevId: 306768847
2020-04-15 19:37:00 -07:00
Eyal Soha 3d3bf9603d Use hex.Dump for Layer.String() of byte slices.
PiperOrigin-RevId: 306726587
2020-04-15 14:59:15 -07:00