Commit Graph

4461 Commits

Author SHA1 Message Date
gVisor bot 7d64bc1fdf Merge pull request #3875 from btw616:fix/issue-3874
PiperOrigin-RevId: 334428344
2020-09-29 11:51:10 -07:00
Toshi Kikuchi f15182243e Discard IP fragments as soon as it expires
Currently expired IP fragments are discarded only if another fragment for the
same IP datagram is received after timeout or the total size of the fragment
queue exceeded a predefined value.

Test: fragmentation.TestReassemblingTimeout

Fixes #3960

PiperOrigin-RevId: 334423710
2020-09-29 11:29:50 -07:00
gVisor bot b6fb11a290 Migrates uses of deprecated map types to recommended types.
PiperOrigin-RevId: 334419854
2020-09-29 11:13:03 -07:00
Bin Lu aee4b8df75 arm64 kvm: keep sentry-tls and usr-tls separately
Currently there is a problem with the preservation of usr-tls, which leads
to the contamination of sentry tls.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-09-29 17:42:05 +08:00
Ghanan Gowripalan 5075d0342f Trim Network/Transport Endpoint/Protocol
* Remove Capabilities and NICID methods from NetworkEndpoint.

* Remove linkEP and stack parameters from NetworkProtocol.NewEndpoint.
The LinkEndpoint can be fetched from the NetworkInterface. The stack
is passed to the NetworkProtocol when it is created so the
NetworkEndpoint can get it from its protocol.

* Remove stack parameter from TransportProtocol.NewEndpoint.
Like the NetworkProtocol/Endpoint, the stack is passed to the
TransportProtocol when it is created.

PiperOrigin-RevId: 334332721
2020-09-29 02:05:50 -07:00
Bin Lu eefcc478c3 arm64 kvm: remove some redundant codes to improve the preformance
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-09-29 16:02:34 +08:00
Ghanan Gowripalan 48915bdedb Move IP state from NIC to NetworkEndpoint/Protocol
* Add network address to network endpoints.
Hold network-specific state in the NetworkEndpoint instead of the stack.
This results in the stack no longer needing to "know" about the network
endpoints and special case certain work for various endpoints
(e.g. IPv6 DAD).

* Provide NetworkEndpoints with an NetworkInterface interface.
Instead of just passing the NIC ID of a NIC, pass an interface so the
network endpoint may query other information about the NIC such as
whether or not it is a loopback device.

* Move NDP code and state to the IPv6 package.
NDP is IPv6 specific so there is no need for it to live in the stack.

* Control forwarding through NetworkProtocols instead of Stack
Forwarding should be controlled on a per-network protocol basis so
forwarding configurations are now controlled through network protocols.

* Remove stack.referencedNetworkEndpoint.
Now that addresses are exposed via AddressEndpoint and only one
NetworkEndpoint is created per interface, there is no need for a
referenced NetworkEndpoint.

* Assume network teardown methods are infallible.

Fixes #3871, #3916

PiperOrigin-RevId: 334319433
2020-09-29 00:20:41 -07:00
Bhasker Hariharan 028e045da9 Fix 1 zero window advertisement bug and a TCP test flake.
In TestReceiveBufferAutoTuning we now send a keep-alive packet to measure the
current window rather than a 1 byte segment as the returned window value in the
latter case is reduced due to the 1 byte segment now being held in the receive
buffer and can cause the test to flake if the segment overheads were to change.

In getSendParams in rcv.go we were advertising a non-zero window even if
available window space was zero after we received the previous segment. In such
a case newWnd and curWnd will be the same and we end up advertising a tiny but
non-zero window and this can cause the next segment to be dropped.

PiperOrigin-RevId: 334314070
2020-09-28 23:31:43 -07:00
Howard Zhang f474d107af add related arm64 syscall for vfs2
arm64 vfs2: Add support for io_submit/fallocate/
sendfile/newfstatat/readahead/fadvise64

Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2020-09-29 10:01:03 +08:00
Jamie Liu ba44298a39 Don't leak dentries returned by sockfs.NewDentry().
PiperOrigin-RevId: 334263322
2020-09-28 16:44:33 -07:00
Nayana Bidari 237b761f9a Fix lingering of TCP socket in the initial state.
When the socket is set with SO_LINGER and close()'d in the initial state, it
should not linger and return immediately.

PiperOrigin-RevId: 334263149
2020-09-28 16:39:12 -07:00
Ghanan Gowripalan a5acc0616c Support creating protocol instances with Stack ref
Network or transport protocols may want to reach the stack. Support this
by letting the stack create the protocol instances so it can pass a
reference to itself at protocol creation time.

Note, protocols do not yet use the stack in this CL but later CLs will
make use of the stack from protocols.

PiperOrigin-RevId: 334260210
2020-09-28 16:24:04 -07:00
Dean Deng a0e0ba690f Support inotify in overlayfs.
Fixes #1479, #317.

PiperOrigin-RevId: 334258052
2020-09-28 16:11:16 -07:00
Dean Deng fa995da840 Fix kernfs race condition.
Do not release dirMu between checking whether to create a child and actually
inserting it.

Also fixes a bug in fusefs which was causing it to deadlock under the new
lock ordering. We do not need to call kernfs.Dentry.InsertChild from newEntry
because it will always be called at the kernfs filesystem layer.

Updates #1193.

PiperOrigin-RevId: 334049264
2020-09-27 15:39:53 -07:00
Dean Deng 2a60f92291 Clean up kcov.
Previously, we did not check the kcov mode when performing task work. As a
result, disabling kcov did not do anything.

Also avoid expensive atomic RMW when consuming coverage data. We don't need the
swap if the value is already zero (which is most of the time), and it is ok if
there are slight inconsistencies due to a race between coverage data generation
(incrementing the value) and consumption (reading a nonzero value and writing
zero).

PiperOrigin-RevId: 334049207
2020-09-27 15:33:51 -07:00
Ghanan Gowripalan a376a0baf3 Remove generic ICMP errors
Generic ICMP errors were required because the transport dispatcher was
given the responsibility of sending ICMP errors in response to transport
packet delivery failures. Instead, the transport dispatcher should let
network layer know it failed to deliver a packet (and why) and let the
network layer make the decision as to what error to send (if any).

Fixes #4068

PiperOrigin-RevId: 333962333
2020-09-26 19:24:41 -07:00
Bhasker Hariharan ebc81fadfc Add openat() to list of permitted syscalls in gotsan runs.
PiperOrigin-RevId: 333853498
2020-09-25 19:36:01 -07:00
Jamie Liu d79cf4808d Disable flaky java11 tests.
Regarding ThreadCpuTimeArray.java: The test starts 10 threads, each of which
does some computation, then blocks. When all threads are blocked, the test
sleeps for 200ms, then checks that less than 100ns of CPU time in userspace
elapse over the course of the sleep; AFAICT, the 100ns of slop is because a
thread indicates that it's in the WAITING state before it actually blocks, and
because signals can cause threads to be temporarily woken. gVisor's CPU clocks
have a granularity of 10ms (the interval of Kernel.cpuClockTicker is
//pkg/abi/linux.ClockTick), so a single tick pushes the test over the
threshold.

PiperOrigin-RevId: 333830287
2020-09-25 16:28:00 -07:00
gVisor bot f2b469916e Merge pull request #4077 from zhlhahaha:1973
PiperOrigin-RevId: 333805533
2020-09-25 14:11:51 -07:00
Marek Majkowski 6f5114446a Swallow SO_RCVBUFFORCE and SO_SNDBUFFORCE errors on SOCK_RAW sockets
In --network=sandbox mode, we create SOCK_RAW sockets on the given
network device. The code tries to force-set 4MiB rcv and snd buffers
on it, but in certain situations it might fail. There is no reason
for refusing the sandbox startup in such case - we should bump the
buffers to max availabe size and just move on.
2020-09-25 13:23:52 +02:00
Bin Lu 71c523b8f9 arm64: some minor changes
This patch adds minor changes for Arm64 platform:
  1, add SetRobustList/GetRobustList support for arm64 syscall module.
  2, add newfstatat support for arm64 vfs2 syscall module.
  3, add tls value in ProtoBuf.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-09-25 03:32:57 -04:00
Howard Zhang ae1141778e fix seccomp test for ARM64
As open syscall is not support on ARM64, change syscall
from 'open' to 'openat' in no_match_name_allow

Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2020-09-25 14:49:13 +08:00
Howard Zhang d47209b86d fix TestUserLog for multi-arch
based on arch, apply different syscall number for
sched_rr_get_interval

Signed-off-by: Howard Zhang <howard.zhang@arm.com>
2020-09-25 14:48:37 +08:00
Min Le 2c849c72b9 make sure use the kernel space after change ASID
after the SWITCH_TO_APP_PAGETABLE, the ASID is changed
to the application ASID, but there are still some
instruction before ERET, since these instruction is
not use the kernel address space, it may use the application's
TLB, which will cause fault, this patch can make sure that
after SWITCH_TO_APP_PAGETABLE sentry is still use kernel
address space which is mapped as Global.

Signed-off-by: Min Le <lemin.lm@antgroup.com>
2020-09-25 12:19:00 +08:00
gVisor bot 74870fc203 Merge pull request #4018 from didier-durand:patch-1
PiperOrigin-RevId: 333611788
2020-09-24 15:33:05 -07:00
Tamir Duberstein ada4d8a337 Remove useless endpoint construction
PiperOrigin-RevId: 333591566
2020-09-24 13:57:28 -07:00
Ayush Ranjan 832d91b805 [vfs] kernfs: Do not hold reference on the inode when opening FD.
The FD should hold a reference on the dentry they were opened on which in turn
holds a reference on the inode it points to.

PiperOrigin-RevId: 333589223
2020-09-24 13:48:01 -07:00
gVisor bot 5f8c653542 Merge pull request #4019 from didier-durand:patch-2
PiperOrigin-RevId: 333588387
2020-09-24 13:42:34 -07:00
Chong Cai 90d9d0e7bd Correct FS_IOC_GETFLAGS value
The previous value was for unix

PiperOrigin-RevId: 333571962
2020-09-24 12:29:35 -07:00
Ayush Ranjan 2a10bc1e43 [vfs] [2/2] kernfs: kernfs: Internally use kernfs.Dentry instead of vfs.Dentry.
Update signatures for:
- All methods in inodeDirectory
- deferDecRef() and Filesystem.droppedDentries
- newSyntheticDirectory()
- `slot`s used in OrderedChildren and subsequent methods like
  replaceChildLocked() and checkExistingLocked()
- stepExistingLocked(), walkParentDirLocked(), checkCreateLocked()

Updates #1193

PiperOrigin-RevId: 333558866
2020-09-24 11:30:45 -07:00
Zach Koopmans c3fc69022a Fix Nginx Startup and Size Benchmarks.
Changes in Nginx Benchmarks in network_tests also affect Startup/Size
Nginx Benchmarks. Make sure the commands line up.

PiperOrigin-RevId: 333543697
2020-09-24 10:32:01 -07:00
Adin Scannell 0a7075f38a Add basic stateify annotations.
Updates #1663

PiperOrigin-RevId: 333539293
2020-09-24 10:13:04 -07:00
Bhasker Hariharan 5d50c91c4d Change segment/pending queue to use receive buffer limits.
segment_queue today has its own standalone limit of MaxUnprocessedSegments but
this can be a problem in UnlockUser() we do not release the lock till there are
segments to be processed. What can happen is as handleSegments dequeues packets
more keep getting queued and we will never release the lock. This can keep
happening even if the receive buffer is full because nothing can read() till we
release the lock.

Further having a separate limit for pending segments makes it harder to track
memory usage etc. Unifying the limits makes it easier to reason about memory in
use and makes the overall buffer behaviour more consistent.

PiperOrigin-RevId: 333508122
2020-09-24 07:15:06 -07:00
Andrei Vagin 0a232a5e8c test/syscall/mknod: Don't use a hard-coded file name
PiperOrigin-RevId: 333461380
2020-09-24 00:48:35 -07:00
gVisor bot 53d569a976 Merge pull request #4071 from avagin:travis
PiperOrigin-RevId: 333454489
2020-09-23 23:47:42 -07:00
Andrei Vagin 3838e83a98 fuse: don't call dentry.InsertChild
It is called from the kernfs code (OpenAt and revalidateChildLocked()).

For RemoveChildLocked, it is opposed. We need to call it from fuse.RmDir and
fuse.Unlink.

PiperOrigin-RevId: 333453218
2020-09-23 23:34:43 -07:00
Tiwei Bie 71f8cab91b Fix socket record leak in VFS2
VFS2 socket record is not removed from the system-wide
socket table when the socket is released, which will lead
to a memory leak. This patch fixes this issue.

Fixes: #3874

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
2020-09-24 14:16:12 +08:00
Tiwei Bie 332e1716fc Rename kernel.SocketEntry to kernel.SocketRecord
SocketEntry can be confusing with the template types as the 'Entry'
is usually used as a suffix for list element types, e.g. socketEntry
in the same package. Suggested by Dean (@dean-deng).

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
2020-09-24 14:16:12 +08:00
Dean Deng 03898a087d Clean up inotify tests.
Mostly simplifies SKIP_IF statements and adds some more documentation.
Also, mknod is now supported by gofer fs, so remove SKIP_IFs related to this.

PiperOrigin-RevId: 333449932
2020-09-23 23:02:04 -07:00
Dean Deng 6410e74a96 Add more descriptive comments on mount options.
PiperOrigin-RevId: 333447255
2020-09-23 22:41:40 -07:00
Andrei Vagin 2111cba9ce make: specify /dev/null for the tail tool 2020-09-23 21:05:45 -07:00
Ayush Ranjan 08bbad6907 [vfs] kernfs: Enable leak checking consistently.
There were some instances where we were not enabling leak checking.

PiperOrigin-RevId: 333418571
2020-09-23 18:45:16 -07:00
Chong Cai 9c8a6796fd Let underlying fs handle LockFD in verity fs
PiperOrigin-RevId: 333412836
2020-09-23 18:05:08 -07:00
Ayush Ranjan fc1bf0d756 Remove unused scripts.
PiperOrigin-RevId: 333408633
2020-09-23 17:38:02 -07:00
Ghanan Gowripalan e02e7e999a Remove unused field from neighborEntry
PiperOrigin-RevId: 333405169
2020-09-23 17:17:50 -07:00
Chong Cai 994062ec9c Set verity underlying fs mount as internal
PiperOrigin-RevId: 333404727
2020-09-23 17:12:13 -07:00
Zeling Feng c3c66ea428 Clean up flag.* usage in packetimpact's runner.RegisterFlags
PiperOrigin-RevId: 333400865
2020-09-23 16:51:34 -07:00
gVisor bot d00207ff48 Internal change.
PiperOrigin-RevId: 333287864
2020-09-23 07:29:31 -07:00
Julian Elischer 99decaadd6 Extract ICMP error sender from UDP
Store transport protocol number on packet buffers for use in ICMP error
generation.

Updates #2211.

PiperOrigin-RevId: 333252762
2020-09-23 02:28:43 -07:00
Dean Deng b54dbdfdc6 Handle EOF properly in splice/sendfile.
Use HandleIOErrorVFS2 instead of custom error handling.

PiperOrigin-RevId: 333227581
2020-09-22 22:31:24 -07:00