Commit Graph

6402 Commits

Author SHA1 Message Date
Arthur Sfez b8689e0586 Simplify TOS and TClass UDP tests
This adds helpers to send both of these control messages via sendmsg,
and most of the initialization is moved into the SetUp body.

The parametrization is now more meaningful. The kDualStack is actually
impactful, which means DifferentTOSAndTClass test has been removed. The
IPv4-mapped IPv6 scenario is now tested in the SetAndReceiveTOSOrTClass.

PiperOrigin-RevId: 426313619
2022-02-03 21:57:29 -08:00
Tony Gong 0bb778a9dd Add temporary address property
Remove the AddressConfigSlaacTemp address configuration type
and add a boolean representing temporality. This enables support
for statically-configured temporary addresses (such as an address
configured by an out-of-stack DHCPv6 client). Like temporary addresses
generated via SLAAC, such addresses are preferred over addresses that
are not temporary during IPv6 source address selection.

Added a test case to the IPv6 source address selection tests which
asserts that an address with the static temporary config type is
preferred over a non-temporary address.

PiperOrigin-RevId: 426301838
2022-02-03 20:21:14 -08:00
Etienne Perot 10d1a49c5b Fuse: `DeviceFD.Read`: Lock `DeviceFD` ahead of other locks.
Syzkaller reports a "unlocking an unlocked mutex" here:
a5ce865145/pkg/sentry/fsimpl/fuse/dev.go (L154)
... which can only happen if `fd.fs` changes in the middle. By locking
`DeviceFD` earlier, we follow the lock ordering specified in
a5ce865145/pkg/sentry/fsimpl/fuse/connection.go (L42)
hopefully fixing the issue.

Reported-by: syzbot+f211c42d52f93416457d@syzkaller.appspotmail.com
PiperOrigin-RevId: 426288804
2022-02-03 18:51:20 -08:00
gVisor bot 350f05d6cd Merge pull request #7138 from avagin:fuse-test
PiperOrigin-RevId: 426270625
2022-02-03 16:57:22 -08:00
Bhasker Hariharan 7345bd99ea Make shared memory file location configurable.
PiperOrigin-RevId: 426268960
2022-02-03 16:46:41 -08:00
Rahat Mahmood 55ef371668 Return well-defined error on short payload in FUSE.
Errors from syscalls without a well-defined translation to errnos
result in sentry panics.

Reported-by: syzbot+907201b840bb25d94e00@syzkaller.appspotmail.com
PiperOrigin-RevId: 426248731
2022-02-03 15:14:36 -08:00
Andrei Vagin 237e45d23a filters: don't allow to create new executable mappings
PiperOrigin-RevId: 426244201
2022-02-03 14:54:09 -08:00
Andrei Vagin 8b456152da Run a new fuse server in a new thread 2022-02-03 13:50:24 -08:00
Andrei Vagin 9d2df1a6ca Enable fuse tests 2022-02-03 13:50:24 -08:00
Arthur Sfez 56de63a4cb Remove unused parameter in UDP tests instantiation
The variant kDualStack is never used by any test. It just duplicates
kIpv6 case. Because the parameters are now just kIpv4 and kIpv6, use
an int to encode the address family, instead of the enum.

PiperOrigin-RevId: 426224701
2022-02-03 13:31:10 -08:00
gVisor bot 70fba80730 Merge pull request #6937 from YaroslavLitvinov:yaro/fix-fuse
PiperOrigin-RevId: 426223561
2022-02-03 13:24:54 -08:00
Arthur Sfez 2d9f7fc7ea Add TOS control message for ICMP & RAW sockets
PiperOrigin-RevId: 426208980
2022-02-03 12:19:06 -08:00
Andrei Vagin e31c3f18da kvm: sentry executable mappings have to be read-only
The sentry guest page tables must not allow to execute writable memory regions.

PiperOrigin-RevId: 426183789
2022-02-03 10:49:57 -08:00
Nicolas Lacasse 34f41dfcbf Hold a reference while calling p9.pathNode.removeWithName() callback.
This prevents a racing clunk() call from destroying the file while the callback
is running, leading to potential data races.

PiperOrigin-RevId: 426180506
2022-02-03 10:29:42 -08:00
Etienne Perot 95d883a92e Refactor task start and exit from a PID namespace into separate functions.
PiperOrigin-RevId: 426083905
2022-02-03 01:47:27 -08:00
Lucas Manning 66da66de30 Fix incorrect behavior for qdisc wakeups.
Without this fix, the qdisc dispatch loop writes at most one batch,
then waits for another wakeup before writing any more packets. All
packets in the queue should be written to the link endpoint after
a wakeup.

PiperOrigin-RevId: 426053587
2022-02-02 21:51:29 -08:00
Etienne Perot a5ce865145 fuse: Attempt to fix five data races.
I am not fully familiar with this code, but I added some `checklocks`
annotations wherever it seemed appropriate and obvious from existing comments.

PiperOrigin-RevId: 426042114
2022-02-02 20:20:06 -08:00
Bhasker Hariharan bcba5136d0 Remove stale nic.DeliverNetworkPacket comment.
Fixes #7080

PiperOrigin-RevId: 425799488
2022-02-01 22:44:35 -08:00
Bhasker Hariharan 404b90fa4a Fix stale comment on Endpoint.ReadContext.
Fixes #7109

PiperOrigin-RevId: 425799066
2022-02-01 22:38:02 -08:00
Fabricio Voznika 5a642df6b3 Reorder cmd groups
Also fixed gofer which was added twice.

PiperOrigin-RevId: 425709601
2022-02-01 14:03:11 -08:00
Lucas Manning 0f8db423e2 Fix cgroupv2 bug that set the wrong iops throttle.
PiperOrigin-RevId: 425483482
2022-01-31 16:08:11 -08:00
Rahat Mahmood d1dadc9c19 Remove dentry_cache_limit mount option from mqfs.
The dentry cache limit should only be set at filesystem creation.
Mqfs filesystems are created during IPC namespace creation and
mount(2)s return a reference to the shared filesystem
object. Modifying the cache limit once the filesystem is in use can
cause the cache to exceed the limit. Since this mount option is rarely
(never?) used, use a static cache size and remove the mount option.

Reported-by: syzbot+e89efb5faa374468b6bb@syzkaller.appspotmail.com
PiperOrigin-RevId: 425436253
2022-01-31 12:41:46 -08:00
Jamie Liu 5ef032d4df Implement faccessat2.
PiperOrigin-RevId: 425432076
2022-01-31 12:25:27 -08:00
Ayush Ranjan 2a3d59997f Enable reference count leak checking for lisafs.
Also add DoRepeatedLeakCheck() to refsvfs2 package.

Updates #5466

PiperOrigin-RevId: 425004987
2022-01-28 19:14:08 -08:00
Bhasker Hariharan 44f0f2dc40 Exclude tcp_noracedetector_test.go from gotsan runs.
PiperOrigin-RevId: 424989750
2022-01-28 17:13:57 -08:00
Ayush Ranjan e29fd32d0a Get rid of unnecessary lisafs.Inode allocations.
lisafs.Inode is a heavy struct with linux.Statx in it. However the cost of
copying it on return is lower than that of an allocation.

Additionally unclutter the filesystem.doCreateAt function signature. It already
is quite complex. lisafs had added more complexity earlier. Revert that.

PiperOrigin-RevId: 424972317
2022-01-28 15:38:05 -08:00
Adin Scannell 62665f881d Remove unnecessary use of _impl pkg rules.
Updates bazelbuild/rules_pkg#263

PiperOrigin-RevId: 424953384
2022-01-28 14:08:28 -08:00
Ayush Ranjan 3f42b2da94 Fix semantics of Mount RPC in lisafs.
Earlier lisafs let the client choose where the connection will be mounted.
Because the client can be compromised, we can not trust the Mount RPC to
dictate the mount path. Instead, decide the mount path on startup on the server
as per the sandbox configuration.

lisafs made the following two assumptions where were incorrect:
- runsc/fsgofer always chroot()s the gofer process. This is currently always
  the case but in the future this might not be true.
- Non root mountpoints will not always correspond to the same directory inside
  the root mount. For instance, if application sets bind mount
  `-v host/dir:app/dir`, then it is not necessary that the app/dir endpoint is
  placed at path "app/dir" inside the root endpoint. This is currently the case
  for runsc/fsgofer, but it might not be in the future.

To support attach paths, make the client do a normal Walk RPC to the attach
point. The Mount RPC now mounts the connection to an endpoint that was
predetermined during startup according to sandbox configuration.

PiperOrigin-RevId: 424948561
2022-01-28 13:50:17 -08:00
Ghanan Gowripalan 4fcd3c77ea (Re)introduce packetsocket link endpoint
The packetsocket link endpoint is used to enable a packet endpoint to
receive packets right before they are sent to the driver for outgoing
packets or right after they are recieved from the driver for incoming
packets.

Before this change, only packets that are sent/received by the
`stack.nic` were delivered to packet endpoints. However, the packet
endpoint should also receive packets that don't reach `stack.nic`.
Such an example can be when the interface is bridged and an incoming
packet is sent out through a sibling bridge port instead of being
delivered to a `stack.nic`.

The packetsocket link endpoint must wrap a link endpoint that
populates the link headers for ingress packets. It should ideally
be placed as low in the link endpoint heirarchy as possible so that
packets are probed as close to device drivers as possible.

2d9b33c0fd
removed the original packetsocket link endpoint which only allowed
low-level capturing of outbound packets but not inbound packets.

The CL mentioned above is cl/395761629.

PiperOrigin-RevId: 424947620
2022-01-28 13:43:55 -08:00
Ayush Ranjan 575a6f5003 Introduce filesystem tree nodes to lisafs.
This is very similar to p9 in design and helps address all the discussed
security concerns around the old lisafs design.

In p9, the path tree grows unbounded. Once a path is walked, those path nodes
exist for the lifetime of the server. That hurts memory performance and usage.
Additionally, nodes are allocated separately from FidRefs which are allocated
separately from Files. Each path node also has 3 hashmaps tracking various
things. This leads to a LOT of allocations.

In lisafs, we cut down almost all the additional allocations. Nodes have a
bounded lifetime. Once all refs on node are dropped, the node is removed from
the filesystem tree. In the overwhelming common case, where the client is not
compromised and is behaving correctly (gofer client in sentry), the lifecycle
of the ControlFD and Node are equivalent. So lisafs allocates them together.

lisafs also only uses 1 hashmap in each node to track children. This too has
been optimized. Experimentation showed that majority of directories have at
most 3 children to track. So we only allocate the hashmap once we hit 4
children. Before that, we statically track 3 children using hardcoded pointers.

Tested: All 221 syscall tests pass with lisafs.
PiperOrigin-RevId: 424933787
2022-01-28 12:41:25 -08:00
Andrei Vagin e98016263b kvm/filters: specify exact set of ioctl-s that are allowed
* make filters more precise.
* create all vCPU-s before installing filters.

PiperOrigin-RevId: 424908294
2022-01-28 10:57:42 -08:00
Bhasker Hariharan 2083e858ad Add support to provide a sharedmem path to sharedmem.
PiperOrigin-RevId: 424744312
2022-01-27 17:17:42 -08:00
Yaroslav Litvinov b7ccfa5084 Fixes #7086,#6964,#3413,#7001.
Also adds fuse fsync, rename, flock support.
2022-01-27 13:07:42 +02:00
Ghanan Gowripalan f54fcc6e11 Drop LinkEndpoint.WriteRawPacket
PiperOrigin-RevId: 424490855
2022-01-26 18:33:55 -08:00
Lucas Manning 6a28dc7c59 Correct fragmentation reference counting.
Before this change the only reference on the packet after reassembly
processing was held by the reassembler in the holes array. This meant that
after the reassembly cleanup job, there were no references left on the
packet, leading to use after free bugs.

PiperOrigin-RevId: 424479461
2022-01-26 17:26:49 -08:00
Adin Scannell b5962471e1 Increase buildkite parallelism.
Since there is very little wasted work for Buildkite, increasing the
parallelsim will decrease throw-away work on cancelation or failure.

This aims to achieve ~3 minutes per individiaul test instance.

PiperOrigin-RevId: 424469351
2022-01-26 16:31:09 -08:00
Ghanan Gowripalan ed2f45ace3 Populate link header from packet buffer fields
The arguments passed to LinkEndpoint.AddHeader are all available in
the packet buffer so just get the values from the packet buffer.

PiperOrigin-RevId: 424463821
2022-01-26 16:10:03 -08:00
Ghanan Gowripalan ad021f48c0 Add link-layer headers in nic
This removes the need for the stack to add a link header out-of-line the
write path when delivering outbound packets to a packet socket.

PiperOrigin-RevId: 424444109
2022-01-26 14:30:36 -08:00
Ghanan Gowripalan abd993f608 Don't pass link addresses in rx path
...as they are not used in all cases expect in the packet endpoint
which can get the link address directly from the link header.

PiperOrigin-RevId: 424427195
2022-01-26 13:24:35 -08:00
gVisor bot c1fa5be7ac Fix typo for GetAbsoluteTestTmpdir
This wasn't caught as there are no presubmit tests that run with
the ANDROID config.

PiperOrigin-RevId: 424395984
2022-01-26 11:18:04 -08:00
Adin Scannell c18ec0b53c Fix race build error.
This adds a test to smoke-tests to ensure that the race build does not
break again. In debugging this issue, a race in the nogo tool itself
was discovered, and a related fix is included.

PiperOrigin-RevId: 424393624
2022-01-26 11:08:21 -08:00
Bhasker Hariharan b57e94c303 Enable leak checker for tcp_conntrack tests.
PiperOrigin-RevId: 424374964
2022-01-26 09:59:02 -08:00
Andrei Vagin daea5b7674 kvm: Check that VMX and SVM are disabled in guest PCID
PiperOrigin-RevId: 424267563
2022-01-25 23:23:34 -08:00
Bhasker Hariharan ee08e56d4c Add leak checking to transport internal network tests.
PiperOrigin-RevId: 424267559
2022-01-25 23:17:26 -08:00
Bhasker Hariharan c89b6d2611 Add leak checking to tcp tests.
PiperOrigin-RevId: 424258607
2022-01-25 22:04:57 -08:00
Bhasker Hariharan d3cce99370 Refactor tcp_tests to separate individual tests.
This change should reduce the run time of the tcp_test target as well as allow
us to add leakchecking code to each test individually rather than create
standalone main_test.go file.

It also cleans up the BUILD file in the tcp directory so that the only tests in
the BUILD file are the whitebox tests and blackbox tests are now segregated to a
separate directory.

PiperOrigin-RevId: 424225303
2022-01-25 18:03:27 -08:00
Andrei Vagin e3c34d68d3 Disable VMX and SVM in guest PCID.
The origin version converts KVM cpuid entries into cpuid.Static
to be able to modify it. But such conversion has side-effects
that we need to avoid and so it looks reasonable to modify KVM
cpuid entries directly.

PiperOrigin-RevId: 424221630
2022-01-25 17:41:53 -08:00
Andrei Vagin 18dca1bf99 kvm: fix a race condition between seccompMMapHandler and machine.Destroy
A machine file descriptor has to be closed only when we are sure that
it isn't used by seccompMMapHandler.

PiperOrigin-RevId: 424207803
2022-01-25 16:30:44 -08:00
Jamie Liu edb6bd399e Add caller for the Execve checkpoint.
Binary fields are VFS2-only.

PiperOrigin-RevId: 424176912
2022-01-25 14:16:07 -08:00
Adin Scannell b92bb28e6a Fix release tags generation.
PiperOrigin-RevId: 424151576
2022-01-25 12:35:46 -08:00