Commit Graph

6025 Commits

Author SHA1 Message Date
Arthur Sfez 6c1237da03 Reply to invalid ACKs even when accept queue is full
Before checking if there is space in the accept queue, the listener
should verify that the cookie is valid. If it is not, instead of
silently dropping the packet, reply with an RST.

Fixes #6683

PiperOrigin-RevId: 400807346
2021-10-04 13:57:27 -07:00
Arthur Sfez 429821b0a9 Test listener receiving an invalid ACK while the accept queue is full
Updates #6683

PiperOrigin-RevId: 400745768
2021-10-04 09:52:31 -07:00
Ghanan Gowripalan 3bab5e5667 Read lock when getting connections
We should avoid taking the write lock to avoid contention when looking
for a packet's tracked connection.

No need to reap timed out connections when looking for connections
as the reaper (which runs periodically) will handle that.

PiperOrigin-RevId: 400322514
2021-10-01 17:03:41 -07:00
Ghanan Gowripalan 51c4fbb840 Drop ConnTrack.handlePacket
Move the hook specific logic to the IPTables hook functions.

This lets us avoid having to perform checks on the hook to determine
what action to take.

Later changes will drop the need for handlePacket's return value,
reducing the value of this function that all hooks call into.

PiperOrigin-RevId: 400298023
2021-10-01 14:58:57 -07:00
Ghanan Gowripalan 6e83c4b751 Drop conn.tcbHook
...as the packet's direction gives us the information that tcbHook is
used to derive.

PiperOrigin-RevId: 400280102
2021-10-01 13:37:37 -07:00
Ghanan Gowripalan 8603cce51d Annotate checklocks on mutex protected fields
...to catch lock-related bugs in nogo tests.

Updates #6566.

PiperOrigin-RevId: 400265818
2021-10-01 12:36:21 -07:00
gVisor bot eac4d9ab2a Merge pull request #6551 from sudo-sturbia:msgqueue/procfs
PiperOrigin-RevId: 400258924
2021-10-01 12:04:17 -07:00
Ghanan Gowripalan 788bbc2904 Drop IPTables.checkPackets
...and have `CheckOutputPackets`, `CheckPostroutingPackets` call their
equivalent methods that operate on a single packet buffer directly.

This is so that the `Check{Output, Postrouting}Packets` methods may
leverage any hook-specific work that `Check{Output, Postrouting}`
may perform.

Note: Later changes will add hook-specific logic to the
`Check{Output, Postrouting}` methods.
PiperOrigin-RevId: 400255651
2021-10-01 11:49:25 -07:00
Ghanan Gowripalan 8073370009 Let connection handle tracked packets
...to save a call to `ConnTrack.connFor` when callers already have a
reference to the ConnTrack entry.

PiperOrigin-RevId: 400244955
2021-10-01 11:05:14 -07:00
Zach Koopmans 9d2d2f7592 [bm-dashboard] Upgrade vulnerable node packages.
Note: this code is auto generated using npm update.
PiperOrigin-RevId: 400227038
2021-10-01 09:56:59 -07:00
Fabricio Voznika 94623ccf51 Use root context to mount volumes
Fixes #6643

PiperOrigin-RevId: 400218778
2021-10-01 09:23:26 -07:00
Tamir Duberstein 0db2ab9329 Move pendingEndpoints to acceptQueue
This obsoletes the need for the pendingMu and pending, since they are redundant
with acceptMu and pendingAccepted.

Fixes #6671.

PiperOrigin-RevId: 400162391
2021-10-01 04:01:20 -07:00
Tamir Duberstein 84f1578e9e Test syn and accept queue behavior on shutdown
Enhance the backlog test to exercise the syn queue.

Updates #6671.

PiperOrigin-RevId: 400094530
2021-09-30 20:46:27 -07:00
Andrei Vagin 9fff9469a2 kernel: print PID in addition to TID in task log messages
For multithreads processes, it is hard to read logs without knowing task pids.

And let's print a decimal return codeo for syscalls. A hex return code are
usefull for system calls that return addresses. For other syscalls, the decimal
form is more readable.

PiperOrigin-RevId: 400035449
2021-09-30 15:07:28 -07:00
Michael Pratt c122663548 Skip analysis of standard library packages using generics
The upstream analysis packages we depend on do not yet support analysis of code
using Go 1.18 type parameter features, making analysis of the Go tip standard
library choke and crash. Skip these packages for now.

PiperOrigin-RevId: 400030256
2021-09-30 14:49:19 -07:00
Michael Pratt b4d4f4bd86 Add timer_create and timer_settime to filters
Go 1.18 (as of golang.org/cl/324129) uses per-thread timers created and set
with timer_create/timer_settime for more accurate CPU pprof profiling.

Add these syscalls to the allowed syscall filters.

PiperOrigin-RevId: 399941561
2021-09-30 08:46:04 -07:00
Tamir Duberstein db88937abb Setup sniffer teardown earlier
This prevents an iptables failure from deadlocking the test.

PiperOrigin-RevId: 399822238
2021-09-29 18:19:20 -07:00
Tamir Duberstein f4340b0c9f Avoid comparisons to zero value of acceptQueue
PiperOrigin-RevId: 399765414
2021-09-29 13:45:47 -07:00
Tamir Duberstein 36b36a8a73 Rename accepted -> acceptQueue
Rename cap -> capacity to avoid collision with the builtin.

PiperOrigin-RevId: 399753630
2021-09-29 12:54:49 -07:00
Tamir Duberstein 5aa37994c1 Remove syncRcvdCount
This is redundant with listenContext.pendingEndpoints

PiperOrigin-RevId: 399722472
2021-09-29 10:50:09 -07:00
Etienne Perot 65698b627e Move `safecopy.ReplaceSignalHandler` into `sighandling` package.
PiperOrigin-RevId: 399560357
2021-09-28 16:56:39 -07:00
Tamir Duberstein fa4c30c635 Inline handleSynSegment
This function has only one caller.

Remove segment reference count manipulation since it is only used
synchronously.

PiperOrigin-RevId: 399525343
2021-09-28 14:13:07 -07:00
Ghanan Gowripalan ed083bac40 Support naive Masquerade NAT target
* Does not accept a port range (Issue #5772).
* Does not support checking for tuple conflits (Issue #5773).

PiperOrigin-RevId: 399524088
2021-09-28 14:07:35 -07:00
Etienne Perot e251f6cc5c Move `sighandling` package out of `sentry`.
PiperOrigin-RevId: 399295737
2021-09-27 15:31:05 -07:00
Tamir Duberstein dc64617d54 Implement S/R for Stats
PiperOrigin-RevId: 399276940
2021-09-27 14:12:00 -07:00
Ayush Ranjan 1fe0a6691f Prevent PacketData from being modified.
PacketData should not be modified and should be treated readonly because it
represents packet payload. The old DeleteFront method allowed callers to modify
the underlying buffer which should not be allowed.

Added a way to consume from the PacketData instead of deleting from it.
Updated call points to use that instead.

Reported-by: syzbot+faee5cb350f769a52d1b@syzkaller.appspotmail.com
PiperOrigin-RevId: 399268473
2021-09-27 13:35:22 -07:00
Tamir Duberstein 455924ee1b Store pending endpoints in a set
There's no need for synthetic keys here.

PiperOrigin-RevId: 399263134
2021-09-27 13:12:25 -07:00
Zyad A. Ali 82e2e89405 Add procfs files for SysV message queues. 2021-09-27 19:51:11 +02:00
gVisor bot 2e25547e04 Merge pull request #6570 from sudo-sturbia:ipc/proc
PiperOrigin-RevId: 398849334
2021-09-24 17:51:25 -07:00
Andrei Vagin e3657847cb Update the comment for Task.netns
Task.netns can be accessed atomically, so Task.mu isn't needed to access it.

PiperOrigin-RevId: 398773947
2021-09-24 11:25:13 -07:00
gVisor bot b510c98464 Merge pull request #6647 from avagin:task-netns
PiperOrigin-RevId: 398763161
2021-09-24 10:41:42 -07:00
Zyad A. Ali 057a9843b8 Run proc's static-file tests in a container.
Some /proc files are static in gVisor, but can be updated in native
linux. To test the values of these files, move them to a separate test
and run it using "container" tag to avoid faulty comparisons in native.

Since a separate IPC namespace is used, update shm comparisons to check
the actual value, not an interval.
2021-09-24 14:15:23 +02:00
Ayush Ranjan 12175748ab Allow lisafs client to send more data than MaxMessageSize using chunks.
The p9 client does the same. This allows applications to read/write >= 2MB of
data. This enables the read write benchmarks to work with lisafs.

Updates #5466

PiperOrigin-RevId: 398659947
2021-09-23 23:33:45 -07:00
Andrei Vagin dcbbd67cac kernel: allow to access Task.netns without taking Task.mu
This allows to avoind unnecessary lock-ordering dependencies on task.mu.
2021-09-23 18:28:08 -07:00
Rahat Mahmood 2b77663330 Create the cgroupfs mount point in sysfs.
Create the /sys/fs/cgroup directory when cgroups are available. This
creates the empty directory to serve as the mountpoint, actually
mounting cgroups is left to the launcher/userspace. This is consistent
with Linux behaviour.

Without this mountpoint, getdents(2) on /sys/fs indicates an empty
directory even if the launcher mounts cgroupfs at /sys/fs/cgroup. The
launcher can't create the mountpoint directory since sysfs doesn't
support mkdir.

PiperOrigin-RevId: 398596698
2021-09-23 15:54:02 -07:00
gVisor bot 93ac155775 Merge pull request #6573 from avagin:kvm-seccomp-mmap
PiperOrigin-RevId: 398572735
2021-09-23 14:08:10 -07:00
Ghanan Gowripalan 8627db006b Pass AddressableEndpoint to IPTables
...instead of an address.

This allows a later change to more precisely select an address
based on the NAT type (source vs. destination NAT).

PiperOrigin-RevId: 398559901
2021-09-23 13:18:10 -07:00
Tamir Duberstein 1df5ad1c7a Implement S/R for TransportEndpointStats
PiperOrigin-RevId: 398559780
2021-09-23 13:12:32 -07:00
Ghanan Gowripalan 2e4f26ac5e Compose ICMP endpoint with datagram-based endpoint
An ICMP endpoint's write path can use the datagram-based endpoint.

Updates #6565.
Test: Datagram-based generic socket + ICMP/ping syscall tests.
PiperOrigin-RevId: 398539844
2021-09-23 11:47:15 -07:00
Ghanan Gowripalan d480289adb Introduce method per iptables hook
...to make it clear what arguments are needed per hook.

PiperOrigin-RevId: 398538776
2021-09-23 11:41:00 -07:00
Tamir Duberstein 603de33b76 Avoid listenContext.listenEP when it is the receiver
This circular reference is misleading at best, and the various code and
commentary that claim `listenEP` can be nil are impossible by
definition.

Add checklocks annotations to enforce preconditions.

PiperOrigin-RevId: 398517574
2021-09-23 10:23:15 -07:00
gVisor bot 861c6c8977 Merge pull request #6617 from Stig124:docs-apt
PiperOrigin-RevId: 398393055
2021-09-22 20:21:54 -07:00
Jamie Liu de750eb1d3 Add Execve and ExitNotifyParent checkpoints.
Call sites for the two checkpoints aren't added yet.

PiperOrigin-RevId: 398375903
2021-09-22 18:12:06 -07:00
Ghanan Gowripalan d877254511 Track UDP connections
This will enable NAT to be performed on UDP packets that are sent
in response to packets sent by the stack.

This will also enable ICMP errors to be properly NAT-ed in response
to UDP packets (#5916).

Updates #5915.

PiperOrigin-RevId: 398373251
2021-09-22 17:55:49 -07:00
Etienne Perot 440fc07f70 Make benchmark `String()` output prettier.
PiperOrigin-RevId: 398372542
2021-09-22 17:50:30 -07:00
Tamir Duberstein cea0a1aa75 Fold rcv_test into tcp_test
This prevents go module errors of the form
 found packages tcp (accept.go) and rcv (rcv_test.go) in ...

PiperOrigin-RevId: 398370042
2021-09-22 17:34:32 -07:00
Etienne Perot 6b7f58b2ac Add `NewCondition` helper in `bigquery.go`.
PiperOrigin-RevId: 398366805
2021-09-22 17:15:02 -07:00
Bruno Dal Bo 586f147cd6 Do not rate limit ICMP Echos by default
As per https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
linux does not limit ICMP Echos by default.

icmp_ratemask - INTEGER
	Mask made of ICMP types for which rates are being limited.
	Significant bits: IHGFEDCBA9876543210
	Default mask:     0000001100000011000 (6168)

	Bit definitions (see include/linux/icmp.h):
		0 Echo Reply
		3 Destination Unreachable *
		4 Source Quench *
		5 Redirect
		8 Echo Request
		B Time Exceeded *
		C Parameter Problem *
		D Timestamp Request
		E Timestamp Reply
		F Info Request
		G Info Reply
		H Address Mask Request
		I Address Mask Reply

	* These are rate limited by default (see default mask above)

Equivalently for ICMPv6.

Lay out foundation for ICMP rate masks, exposing that configuration will be
addressed later when the need arises (#6521).

Fixes #6519

PiperOrigin-RevId: 398337963
2021-09-22 15:07:05 -07:00
Carmen Hanish 4f67756752 Change EcdsaVerify to specifically P-384 and compute the SHA384 digest.
PiperOrigin-RevId: 398336708
2021-09-22 15:01:56 -07:00
Andrei Vagin 8544a8f427 kvm: check that safecopy is handled correctly in the guest ring0
Signed-off-by: Andrei Vagin <avagin@google.com>
2021-09-22 14:39:36 -07:00