Commit Graph

2944 Commits

Author SHA1 Message Date
Ayush Ranjan ad0ac73626 [rack] Set up TLP timer and configure timeout.
This change implements TLP details enumerated in
https://tools.ietf.org/html/draft-ietf-tcpm-rack-08#section-7.5.1.

Fixes #5083

PiperOrigin-RevId: 351467357
2021-01-12 16:00:26 -08:00
Adin Scannell 4e03e87547 Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor
fixes are also included and tests added where appropriate.

PiperOrigin-RevId: 351425971
2021-01-12 12:38:22 -08:00
Adin Scannell a20da70829 Fix Go branch for arm64.
This requires several changes:
* Templates must preserve relevant tags.
* Pagetables templates are split into two targets, each preserving tags.
* The binary VDSO is similarly split into two targets, with some juggling.
* The top level tools/go_branch.sh now does a crossbuild of ARM64 as well,
  and checks and merges the results of the two branches together.

Fixes #5178

PiperOrigin-RevId: 351304330
2021-01-11 22:33:36 -08:00
Adin Scannell e06c2b1264 Make segment range type split safe.
This allows for use in restricted contexts.

Updates #5039

PiperOrigin-RevId: 351265378
2021-01-11 17:00:24 -08:00
Adin Scannell 4c4de66443 Make ilist split safe.
This allows for use in restricted contexts.

Updates #5039

PiperOrigin-RevId: 351220385
2021-01-11 13:18:01 -08:00
gVisor bot 70de1db82e Merge pull request #4933 from lubinszARM:pr_kvm_el0_exceptions
PiperOrigin-RevId: 350862699
2021-01-08 17:08:36 -08:00
Etienne Perot 11787a601e Create console test library.
This creates a TTY pair and runs `/bin/sh` in interactive mode within it.
It provides useful helper functions to interact with the shell and read the
output of commands run within it.

This is meant to be used for testing upcoming changes allowing `runsc exec` to
work in `-detach=false -tty=true` mode.

PiperOrigin-RevId: 350841006
2021-01-08 14:51:50 -08:00
gVisor bot bf343394d4 Merge pull request #5207 from avagin:arm64-cross
PiperOrigin-RevId: 350691246
2021-01-07 20:48:58 -08:00
Ting-Yu Wang b1de1da318 netstack: Refactor tcpip.Endpoint.Read
Read now takes a destination io.Writer, count, options. Keeping the method name
Read, in contrast to the Write method.

This enables:
* direct transfer of views under VV
* zero copy

It also eliminates the need for sentry to keep a slice of view because
userspace had requested a read that is smaller than the view returned, removing
the complexity there.

Read/Peek/ReadPacket are now consolidated together and some duplicate code is
removed.

PiperOrigin-RevId: 350636322
2021-01-07 14:17:18 -08:00
Andrei Vagin 599a3d0fb4 Implement the semtimedop syscall
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-01-07 11:49:40 -08:00
Ghanan Gowripalan 7817e3b5e4 Do not filter frames in ethernet link endpoint
Ethernet frames are usually filtered at the hardware-level so there is
no need to filter the frames in software.

For test purposes, a new link endpoint was introduced to filter frames
based on their destination.

PiperOrigin-RevId: 350422941
2021-01-06 14:02:45 -08:00
Ghanan Gowripalan abe9d9f67f Support add/remove IPv6 multicast group sock opt
IPv4 was always supported but UDP never supported joining/leaving IPv6
multicast groups via socket options.

Add: IPPROTO_IPV6, IPV6_JOIN_GROUP/IPV6_ADD_MEMBERSHIP
Remove: IPPROTO_IPV6, IPV6_LEAVE_GROUP/IPV6_DROP_MEMBERSHIP

Test: integration_test.TestUDPAddRemoveMembershipSocketOption
PiperOrigin-RevId: 350396072
2021-01-06 11:41:42 -08:00
gVisor bot 0c4118d5b8 Merge pull request #5177 from lubinszARM:pr_kernel_global
PiperOrigin-RevId: 350375461
2021-01-06 10:05:31 -08:00
Adin Scannell ab32fa2481 Make type sanity checking happen only in race builds.
This adds significant costs to startup, since it is done for
every type in the system. Since the state package already saves
sanity checks for race builds, use this for type registration.

PiperOrigin-RevId: 350259336
2021-01-05 18:15:27 -08:00
Kevin Krakauer ce7a4440ca Fix panic when parsing SO_TIMESTAMP cmsg
PiperOrigin-RevId: 350223482
2021-01-05 14:45:47 -08:00
Adin Scannell b06e5bc5b0 Add benchmarks targets to BuildKite.
This includes minor fix-ups:

* Handle SIGTERM in runsc debug, to exit gracefully.
* Fix cmd.debug.go opening all profiles as RDONLY.
* Fix the test name in fio_test.go, and encode the block size in the test.

PiperOrigin-RevId: 350205718
2021-01-05 13:21:54 -08:00
Andrei Vagin 2a200811d4 fs/fuse: check that a task has a specified file descriptor
Reported-by: syzbot+814105309d2ae8651084@syzkaller.appspotmail.com
PiperOrigin-RevId: 350159452
2021-01-05 09:47:30 -08:00
Dean Deng 807a080d95 Add missing error checks for FileDescription.Init.
Syzkaller discovered this bug in pipefs by doing something quite strange:
creat(&(0x7f0000002a00)='./file1\x00', 0x0)
mount(&(0x7f0000000440)=ANY=[], &(0x7f00000002c0)='./file1\x00', &(0x7f0000000300)='devtmpfs\x00', 0x20000d, 0x0)
creat(&(0x7f0000000000)='./file1/file0\x00', 0x0)

This can be reproduced with:
touch mymount
mkfifo /dev/mypipe
mount -o ro -t devtmpfs devtmpfs mymount
echo 123 > mymount/mypipe

PiperOrigin-RevId: 349687714
2020-12-31 09:51:01 -08:00
Adin Scannell ffa9a715aa Simplify profiling and benchmarks.
- Tweak the benchmarks to work with b.N where appropriate. In many cases,
  b.N was simply being ignored. This creates an implicit dependency in the
  user passing a reasonable benchtime (less than or equal to the actual
  runtime of the test, or using the X syntax) otherwise the test runs
  forever.
- In cases where the above is impossible, explicitly set benchtime from
  the test wrapper, to prevent the above behavior (tensorflow).
- Drop the *Reverse variants, which are simply hey benchmarks. We should
  just add a hey benchmark. The platforms benchmarks already include a
  native platform, and thus these benchmarks are incredibly confusing.
  (In other words, BenchmarkNginxReverse has nothing to do with an nginx
  benchmark for runsc.)
- Remove the redunant Harness object, which contains no state, in order
  to slightly simplify the code.
- Make Block and Heap profiling actually work, but setting appropriate
  runtime parameters (and plumbing them through the config).
- Split the profiling into two phases: start and stop, since some will
  need to be started early, and others will need to happen at the end.

PiperOrigin-RevId: 349495377
2020-12-29 18:29:12 -08:00
Adin Scannell 85c1c3ed4b Make profiling commands synchronous.
This allows for a model of profiling when you can start collection, and
it will terminate when the sandbox terminates. Without this synchronous
call, it is effectively impossible to collect length blocking and mutex
profiles.

PiperOrigin-RevId: 349483418
2020-12-29 16:23:01 -08:00
Robin Luk 7e91b3cdec arm64 kvm: revert some kpti related codes, and configure upper pagetable as global
In order to improve the performance, some kpti related codes(TCR.A1) have
been reverted, and set kernel pagetable as global.

Signed-off-by: Robin Luk <lubin.lu@antgroup.com>
2020-12-29 19:35:17 +08:00
Andrei Vagin d079159876 vfs1: don't allow to open socket files
open() has to return ENXIO in this case.

O_PATH isn't supported by vfs1.

PiperOrigin-RevId: 348820478
2020-12-23 11:11:07 -08:00
Nayana Bidari 7c8ba72b02 Move SO_BINDTODEVICE to socketops.
PiperOrigin-RevId: 348696094
2020-12-22 14:44:02 -08:00
Tamir Duberstein 202e9fa369 Correctly log sniffed ARP packets
This condition was inverted in 360006d.

PiperOrigin-RevId: 348679088
2020-12-22 12:52:19 -08:00
Peter Johnston fee2cd640f Invoke address resolution upon subsequent traffic to Failed neighbor
Removes the period of time in which subseqeuent traffic to a Failed neighbor
immediately fails with ErrNoLinkAddress. A Failed neighbor is one in which
address resolution fails; or in other words, the neighbor's IP address cannot
be translated to a MAC address.

This means removing the Failed state for linkAddrCache and allowing transitiong
out of Failed into Incomplete for neighborCache. Previously, both caches would
transition entries to Failed after address resolution fails. In this state, any
subsequent traffic requested within an unreachable time would immediately fail
with ErrNoLinkAddress. This does not follow RFC 4861 section 7.3.3:

  If address resolution fails, the entry SHOULD be deleted, so that subsequent
  traffic to that neighbor invokes the next-hop determination procedure again.
  Invoking next-hop determination at this point ensures that alternate default
  routers are tried.

The API for getting a link address for a given address, whether through the link
address cache or the neighbor table, is updated to optionally take a callback
which will be called when address resolution completes. This allows `Route` to
handle completing link resolution internally, so callers of (*Route).Resolve
(e.g. endpoints) don’t have to keep track of when it completes and update the
Route accordingly.

This change also removes the wakers from LinkAddressCache, NeighborCache, and
Route in favor of the callbacks, and callers that previously used a waker can
now just pass a callback to (*Route).Resolve that will notify the waker on
resolution completion.

Fixes #4796

Startblock:
  has LGTM from sbalana
  and then
  add reviewer ghanan
PiperOrigin-RevId: 348597478
2020-12-22 01:37:05 -08:00
Ghanan Gowripalan 620de250a4 Prefer matching labels and longest matching prefix
...when performing source address selection for IPv6.

These are defined in RFC 6724 section 5 rule 6 (prefer matching label)
and rule 8 (use longest matching prefix).

This change also considers ULA of global scope instead of its own scope,
as per RFC 6724 section 3.1:

   Also, note that ULAs are considered as global, not
   site-local, scope but are handled via the prefix policy table as
   discussed in Section 10.6.

Test: stack_test.TestIPv6SourceAddressSelectionScope

Startblock:
  has LGTM from peterjohnston
  and then
  add reviewer brunodalbo
PiperOrigin-RevId: 348580996
2020-12-21 22:26:10 -08:00
Andrei Vagin 946cb909e6 Don't modify a packet header when it can be used by other endpoints
Reported-by: syzbot+48c43f82fe7738fceae9@syzkaller.appspotmail.com
PiperOrigin-RevId: 348540796
2020-12-21 15:50:33 -08:00
Kevin Krakauer 981faa2c12 RLock Endpoint in raw.Endpoint.HandlePacket
PiperOrigin-RevId: 348530530
2020-12-21 14:44:39 -08:00
Chong Cai 433fd0e646 Set verityMu to be state nosave
PiperOrigin-RevId: 348092999
2020-12-17 14:23:02 -08:00
Nicolas Lacasse 1ea241e4cc Fix seek on /proc/pid/cmdline when task is zombie.
PiperOrigin-RevId: 348056159
2020-12-17 11:16:06 -08:00
Ayush Ranjan 028271b530 [netstack] Implement IP(V6)_RECVERR socket option.
PiperOrigin-RevId: 348055514
2020-12-17 11:10:41 -08:00
Fabricio Voznika 30860902f6 Set process group and session on host TTY
Closes #5128

PiperOrigin-RevId: 348052446
2020-12-17 10:58:18 -08:00
Ayush Ranjan 74788b1b61 [netstack] Implement MSG_ERRQUEUE flag for recvmsg(2).
Introduces the per-socket error queue and the necessary cmsg mechanisms.

PiperOrigin-RevId: 348028508
2020-12-17 08:47:24 -08:00
Tamir Duberstein 4640fc4f35 Remove duplicate `return`
PiperOrigin-RevId: 347974624
2020-12-17 00:40:33 -08:00
Ghanan Gowripalan c740865f86 Cleanup locking in multicast group protocol tests
Startblock:
  has LGTM from asfez
  and then
  add reviewer tamird
PiperOrigin-RevId: 347928471
2020-12-16 17:26:06 -08:00
gVisor bot 0ac6636aaf Automated rollback of changelist 346565589
PiperOrigin-RevId: 347911316
2020-12-16 15:41:03 -08:00
gVisor bot 2ec6e44c9e Merge pull request #4880 from lubinszARM:pr_tlbi_02
PiperOrigin-RevId: 347890782
2020-12-16 13:52:58 -08:00
Nayana Bidari 0c92b3782a Add support to count the number of packets SACKed.
sacked_out is required in RACK to check the number of duplicate
acknowledgements during updating the reorder window. If there is no reordering
and the value for sacked_out is greater than the classic threshold value 3,
then reorder window is set to zero.
It is calculated by counting the number of segments sacked in the ACK and is
reduced when a cumulative ACK is received which covers the SACK blocks. This
value is set to zero when the connection enters recovery.

PiperOrigin-RevId: 347872246
2020-12-16 12:19:21 -08:00
Mithun Iyer b645fcd241 Ensure correctness of saved receive window
When the scaled receive window size > 65535 (max uint16), we advertise
the scaled value as 65535, but are not adjusting the saved receive
window value when doing so. This would keep our current window
calculation logic to be incorrect, as the saved receive window value
is different from what was advertised.

Fixes #4903

PiperOrigin-RevId: 347771340
2020-12-16 00:24:28 -08:00
Ghanan Gowripalan c55e5bda4d Validate router alert's data length
RFC 2711 specifies that the router alert's length field is always 2
so we should make sure only 2 bytes are read from a router alert
option's data field.

Test: header.TestIPv6OptionsExtHdrIterErr
PiperOrigin-RevId: 347727876
2020-12-15 17:45:22 -08:00
Andrei Vagin 97406b20a1 Internal change.
PiperOrigin-RevId: 347720083
2020-12-15 16:51:35 -08:00
Ghanan Gowripalan 50c658a9f6 Don't split enabled flag across multicast group state
Startblock:
  has LGTM from asfez
  and then
  add reviewer brunodalbo
PiperOrigin-RevId: 347716242
2020-12-15 16:28:53 -08:00
Jing Chen 1e56a2f9a2 Implement command SEM_INFO and SEM_STAT for semctl.
PiperOrigin-RevId: 347711998
2020-12-15 16:06:06 -08:00
Chong Cai 7aa674eb68 Change violation mode to an enum
PiperOrigin-RevId: 347706953
2020-12-15 15:40:04 -08:00
Ayush Ranjan f6407de6ba [syzkaller] Avoid AIOContext from resurrecting after being marked dead.
syzkaller reported the closing of a nil channel. This is only possible when the
AIOContext was destroyed twice.

Some scenarios that could lead to this:
- It died and then some called aioCtx.Prepare() on it and then killed it again
  which could cause the double destroy. The context could have been destroyed
  in between the call to LookupAIOContext() and Prepare().
- aioManager was destroyed but it did not update the contexts map. So
  Lookup could still return a dead AIOContext and then someone could call
  Prepare on it and kill it again.

So added a check in aioCtx.Prepare() for the context being dead. This will
prevent a dead context from resurrecting.
Also refactored code to destroy the aioContext consistently. Earlier we were not
munmapping the aioContexts that were destroyed upon aioManager destruction.

Reported-by: syzbot+ef6a588d0ce6059991d2@syzkaller.appspotmail.com
PiperOrigin-RevId: 347704347
2020-12-15 15:27:35 -08:00
Ayush Ranjan cc28d36845 [netstack] Make recvmsg(2) call to host in hostinet even if dst is empty.
We want to make the recvmsg syscall to the host regardless of if the dst is
empty or not so that:
- Host can populate the control messages if necessary.
- Host can return sender address.
- Host can return appropriate errors.

Earlier because we were using the IOSequence.CopyOutFrom() API, the usermem
package does not even call the Reader function if the destination is empty (as
an optimization).

PiperOrigin-RevId: 347684566
2020-12-15 13:48:33 -08:00
gVisor bot e605144938 Internal change.
PiperOrigin-RevId: 347671070
2020-12-15 12:41:02 -08:00
gVisor bot 5843a5007c Merge pull request #4722 from zhlhahaha:2010
PiperOrigin-RevId: 347660920
2020-12-15 11:54:04 -08:00
Nayana Bidari b15acae9a6 Fix error code for connect in raw sockets.
PiperOrigin-RevId: 347650354
2020-12-15 11:07:48 -08:00
Ting-Yu Wang 25ebddbddf Fix a data race in packetEPs
packetEPs may get into a state that `len < cap`, casuing append() modifying the
original slice storage.

Reported-by: syzbot+978dd0e9c2600ab7a76b@syzkaller.appspotmail.com
PiperOrigin-RevId: 347634351
2020-12-15 09:55:40 -08:00