Commit Graph
2925 Commits
Author SHA1 Message Date
Dean DengandgVisor bot c317e94de6 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 ScannellandgVisor bot caec235b70 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 ScannellandgVisor bot 2dd3db9918 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
Andrei VaginandgVisor bot 52f5d74eaa 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 BidariandgVisor bot 440e31439b Move SO_BINDTODEVICE to socketops.
PiperOrigin-RevId: 348696094
2020-12-22 14:44:02 -08:00
Tamir DubersteinandgVisor bot eb2bff384c Correctly log sniffed ARP packets
This condition was inverted in 037fba4.

PiperOrigin-RevId: 348679088
2020-12-22 12:52:19 -08:00
Peter JohnstonandgVisor bot 819c36de67 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 GowripalanandgVisor bot dda0b4095e 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 VaginandgVisor bot 6c6ee968a4 Don't modify a packet header when it can be used by other endpoints
Reported-by: [email protected]
PiperOrigin-RevId: 348540796
2020-12-21 15:50:33 -08:00
Kevin KrakauerandgVisor bot 4daf8b3b7b RLock Endpoint in raw.Endpoint.HandlePacket
PiperOrigin-RevId: 348530530
2020-12-21 14:44:39 -08:00
Chong CaiandgVisor bot 10edd10897 Set verityMu to be state nosave
PiperOrigin-RevId: 348092999
2020-12-17 14:23:02 -08:00
Nicolas LacasseandgVisor bot dad54f748f Fix seek on /proc/pid/cmdline when task is zombie.
PiperOrigin-RevId: 348056159
2020-12-17 11:16:06 -08:00
Ayush RanjanandgVisor bot 4bc318854f [netstack] Implement IP(V6)_RECVERR socket option.
PiperOrigin-RevId: 348055514
2020-12-17 11:10:41 -08:00
Fabricio VoznikaandgVisor bot f9aad26cc4 Set process group and session on host TTY
Closes #5128

PiperOrigin-RevId: 348052446
2020-12-17 10:58:18 -08:00
Ayush RanjanandgVisor bot 130220dd6c [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 DubersteinandgVisor bot 2a7379a2b8 Remove duplicate return
PiperOrigin-RevId: 347974624
2020-12-17 00:40:33 -08:00
Ghanan GowripalanandgVisor bot 34fe1f8ede 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 3d92cfeaaf Automated rollback of changelist 346565589
PiperOrigin-RevId: 347911316
2020-12-16 15:41:03 -08:00
gVisor bot d12888b7db Merge pull request #4880 from lubinszARM:pr_tlbi_02
PiperOrigin-RevId: 347890782
2020-12-16 13:52:58 -08:00
Nayana BidariandgVisor bot d39ac99daa 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 IyerandgVisor bot 310a9b5574 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 GowripalanandgVisor bot c4e02f5af9 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 VaginandgVisor bot 751466b0f9 Internal change.
PiperOrigin-RevId: 347720083
2020-12-15 16:51:35 -08:00
Ghanan GowripalanandgVisor bot 1df135aac1 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 ChenandgVisor bot 070e277b6e Implement command SEM_INFO and SEM_STAT for semctl.
PiperOrigin-RevId: 347711998
2020-12-15 16:06:06 -08:00
Chong CaiandgVisor bot 258ac635a9 Change violation mode to an enum
PiperOrigin-RevId: 347706953
2020-12-15 15:40:04 -08:00
Ayush RanjanandgVisor bot f28a1e36bd [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: [email protected]
PiperOrigin-RevId: 347704347
2020-12-15 15:27:35 -08:00
Ayush RanjanandgVisor bot 3be1f4bb2a [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 0b9cb83699 Internal change.
PiperOrigin-RevId: 347671070
2020-12-15 12:41:02 -08:00
gVisor bot c3e6cfc680 Merge pull request #4722 from zhlhahaha:2010
PiperOrigin-RevId: 347660920
2020-12-15 11:54:04 -08:00
Nayana BidariandgVisor bot 83448813a5 Fix error code for connect in raw sockets.
PiperOrigin-RevId: 347650354
2020-12-15 11:07:48 -08:00
Ting-Yu WangandgVisor bot 9982ab6198 Fix a data race in packetEPs
packetEPs may get into a state that `len < cap`, casuing append() modifying the
original slice storage.

Reported-by: [email protected]
PiperOrigin-RevId: 347634351
2020-12-15 09:55:40 -08:00
Fabricio VoznikaandgVisor bot 5e7c3c37c3 Update containerd/cgroups
PiperOrigin-RevId: 347532687
2020-12-14 21:18:06 -08:00
Ayush RanjanandgVisor bot 17d539fe08 [netstack] Update raw socket and hostinet control message parsing.
There are surprisingly few syscall tests that run with hostinet. For example
running the following command only returns two results:
`bazel query test/syscalls:all | grep hostnet`

I think as a result, as our control messages evolved, hostinet was left
behind. Update it to support all control messages netstack supports.

This change also updates sentry's control message parsing logic to make it up to
date with all the control messages we support.

PiperOrigin-RevId: 347508892
2020-12-14 18:00:55 -08:00
Nayana BidariandgVisor bot ff7848a5ae Move SO_LINGER option to socketops.
PiperOrigin-RevId: 347437786
2020-12-14 12:03:27 -08:00
Dean DengandgVisor bot a2a83f840c Do not check for reference leaks after saving.
We should not assert that all resources are dropped after saving.

PiperOrigin-RevId: 347420131
2020-12-14 10:47:01 -08:00
Nayana BidariandgVisor bot abf1c4bc0d Move SO_ERROR and SO_OOBINLINE option to socketops.
SO_OOBINLINE option is set/get as boolean value, which is the same as linux.
As we currently do not support disabling this option, we always return it as
true.

PiperOrigin-RevId: 347413905
2020-12-14 10:22:32 -08:00
Toshi KikuchiandgVisor bot 54484bf8fa Reduce the memory overhead in IP fragment management
- Deep-copy pkt.Data and hold it instead of shallow-copy (vv.Clone).
  This allows the pkt's backing array, which includes the header portion,
  to be freed.
- Remove fragHeap. The fragments are now held in holes struct instead.
- Stop reserving the initial capacity of holes slice.

PiperOrigin-RevId: 347198744
2020-12-12 15:32:03 -08:00
Bruno Dal BoandgVisor bot b4774b4aec Introduce IPv6 extension header serialization facilities
Adds IPv6 extension header serializer and Hop by Hop options serializer.
Add RouterAlert option serializer and use it in MLD.

Fixed #4996

Startblock:
  has LGTM from marinaciocea
  and then
  add reviewer ghanan
PiperOrigin-RevId: 347174537
2020-12-12 09:07:44 -08:00
gVisor bot 0dc9ae98d0 Internal change.
PiperOrigin-RevId: 347091372
2020-12-11 16:06:01 -08:00
Dean DengandgVisor bot 02375d859e Make fixes to vfs2 leak checking.
PiperOrigin-RevId: 347089828
2020-12-11 15:55:41 -08:00
Dean DengandgVisor bot f2b3ef13bc Add runsc symbolize command.
This command takes instruction pointers from stdin and converts them into their
corresponding file names and line/column numbers in the runsc source code. The
inputs are not interpreted as actual addresses, but as synthetic values that are
exposed through /sys/kernel/debug/kcov. One can extract coverage information
from kcov and translate those values into locations in the source code by
running symbolize on the same runsc binary.

This will allow us to generate syzkaller coverage reports.

PiperOrigin-RevId: 347089624
2020-12-11 15:43:22 -08:00
Nayana BidariandgVisor bot df60ee40d3 Fix panic when IPv4 address is used in sendmsg for IPv6 sockets
We do not rely on error for getsockopt options(which have boolean values)
anymore. This will cause issue in sendmsg where we used to return error
for IPV6_V6Only option. Fix the panic by returning error (for sockets other
than TCP and UDP) if the address does not match the type(AF_INET/AF_INET6) of
the socket.

PiperOrigin-RevId: 347063838
2020-12-11 13:31:28 -08:00
Adin ScannellandgVisor bot 69f0412910 Remove existing nogo exceptions.
PiperOrigin-RevId: 347047550
2020-12-11 12:06:49 -08:00
Ayush RanjanandgVisor bot 8f6c40d2c6 [netstack] Decouple tcpip.ControlMessages from the IP control messges.
tcpip.ControlMessages can not contain Linux specific structures which makes it
painful to convert back and forth from Linux to tcpip back to Linux when passing
around control messages in hostinet and raw sockets.

Now we convert to the Linux version of the control message as soon as we are
out of tcpip.

PiperOrigin-RevId: 347027065
2020-12-11 10:33:58 -08:00
Jing ChenandgVisor bot a0854b0b3a Make semctl IPC_INFO cmd return the index of highest used entry.
PiperOrigin-RevId: 346973338
2020-12-11 04:22:04 -08:00
Chong CaiandgVisor bot 2e6955a055 Change merkle root file name to avoid collision
PiperOrigin-RevId: 346923826
2020-12-10 20:53:00 -08:00
Bhasker HariharanandgVisor bot 19d15674e4 Disable host reassembly for fragments.
fdbased endpoint was enabling fragment reassembly on the host AF_PACKET socket
to ensure that fragments are delivered inorder to the right dispatcher. But this
prevents fragments from being delivered to gvisor at all and makes testing of
gvisor's fragment reassembly code impossible.

The potential impact from this is minimal since IP Fragmentation is not really
that prevelant and in cases where we do get fragments we may deliver the
fragment out of order to the TCP layer as multiple network dispatchers may
process the fragments and deliver a reassembled fragment after the next packet
has been delivered to the TCP endpoint. While not desirable I believe the impact
from this is minimal due to low prevalence of fragmentation.

Also removed PktType and Hatype fields when binding the socket as these are not
used when binding. Its just confusing to have them specified.

See: https://man7.org/linux/man-pages/man7/packet.7.html
"Fields used for binding are
       sll_family (should be AF_PACKET), sll_protocol, and sll_ifindex."

Fixes #5055

PiperOrigin-RevId: 346919439
2020-12-10 20:08:59 -08:00
Ghanan GowripalanandgVisor bot 155bec7f48 Use specified source address for IGMP/MLD packets
This change also considers interfaces and network endpoints enabled up
up to the point all work to disable them are complete. This was needed
so that protocols can perform shutdown work while being disabled (e.g.
sending a packet which requires the endpoint to be enabled to obtain a
source address).

Bug #4682, #4861
Fixes #4888

Startblock:
  has LGTM from peterjohnston
  and then
  add reviewer brunodalbo
PiperOrigin-RevId: 346869702
2020-12-10 14:50:20 -08:00
Bhasker HariharanandShentubot 59b6de71b6 Add support for IP_RECVORIGDSTADDR IP option.
Fixes #5004

PiperOrigin-RevId: 346643745
2020-12-09 15:58:53 -08:00