Commit Graph

2159 Commits

Author SHA1 Message Date
Tamir Duberstein d01240d871 Take addresses as const
PiperOrigin-RevId: 288767927
2020-01-08 13:54:19 -08:00
gVisor bot bb96f52576 Merge pull request #1273 from lubinszARM:pr_ring_3
PiperOrigin-RevId: 288743614
2020-01-08 11:48:34 -08:00
Fabricio Voznika db376e1392 Make /proc/[pid] offset start at TGID_OFFSET
Updates #1195

PiperOrigin-RevId: 288725745
2020-01-08 10:45:12 -08:00
Tamir Duberstein 9df018767c Remove redundant function argument
PacketLooping is already a member on the passed Route.

PiperOrigin-RevId: 288721500
2020-01-08 10:22:51 -08:00
Bert Muthalaly 0cc1e74b57 Add NIC.isLoopback()
...enabling us to remove the "CreateNamedLoopbackNIC" variant of
CreateNIC and all the plumbing to connect it through to where the value
is read in FindRoute.

PiperOrigin-RevId: 288713093
2020-01-08 09:30:20 -08:00
Andrei Vagin a53ac7307a fs/splice: don't report a partialResult error if there is no data loss
PiperOrigin-RevId: 288642552
2020-01-07 23:54:14 -08:00
Adin Scannell e77ad57423 Fix partial_bad_buffer write tests.
The write tests are fitted to Linux-specific behavior, but it is not
well-specified. Tweak the tests to allow for both acceptable outcomes.

PiperOrigin-RevId: 288606386
2020-01-07 17:26:42 -08:00
Ghanan Gowripalan 4e19d165cc Support deprecating SLAAC addresses after the preferred lifetime
Support deprecating network endpoints on a NIC. If an endpoint is deprecated, it
should not be used for new connections unless a more preferred endpoint is not
available, or unless the deprecated endpoint was explicitly requested.

Test: Test that deprecated endpoints are only returned when more preferred
endpoints are not available and SLAAC addresses are deprecated after its
preferred lifetime
PiperOrigin-RevId: 288562705
2020-01-07 13:42:08 -08:00
Ghanan Gowripalan 2031cc4701 Disable auto-generation of IPv6 link-local addresses for loopback NICs
Test: Test that an IPv6 link-local address is not auto-generated for loopback
NICs, even when it is enabled for non-loopback NICS.
PiperOrigin-RevId: 288519591
2020-01-07 10:09:39 -08:00
Kevin Krakauer ed60bc326b Fix readme formatting.
PiperOrigin-RevId: 288402480
2020-01-06 16:49:34 -08:00
Ghanan Gowripalan 8dfd922840 Pass the NIC-internal name to the NIC name function when generating opaque IIDs
Pass the NIC-internal name to the NIC name function when generating opaque IIDs
so implementations can use the name that was provided when the NIC was created.
Previously, explicit NICID to NIC name resolution was required from the netstack
integrator.

Tests: Test that the name provided when creating a NIC is passed to the NIC name
function when generating opaque IIDs.
PiperOrigin-RevId: 288395359
2020-01-06 16:21:31 -08:00
Andrei Vagin 17c18241cd platform/syscall: use syscall + int3 to execute a system call in a stub process
Right now, we need to call ptrace(PTRACE_SYSCALL) and wait() twice to execute
one system call in a stub process. With these changes, we will need to call
ptrace + wait only once.

In addition, this allows to workaround the kernel bug when a stub process
doesn't stop on syscall-exit-stop and starts executing the next system call.

Reported-by: syzbot+37143cafa8dc3b5008ee@syzkaller.appspotmail.com
PiperOrigin-RevId: 288393029
2020-01-06 15:54:53 -08:00
Nicolas Lacasse 51f3ab85e0 Convert memfs into proto-tmpfs.
- Renamed memfs to tmpfs.
- Copied fileRangeSet bits from fs/fsutil/ to fsimpl/tmpfs/
- Changed tmpfs to be backed by filemem instead of byte slice.
- regularFileReadWriter uses a sync.Pool, similar to gofer client.

PiperOrigin-RevId: 288356380
2020-01-06 12:52:55 -08:00
Michael Pratt 354a15a234 Implement rseq(2)
PiperOrigin-RevId: 288342928
2020-01-06 11:42:44 -08:00
Michael Pratt 6410387ff9 Cleanup Shm reference handling
Currently, shm.Registry.FindByID will return Shm instances without taking an
additional reference on them, making it possible for them to disappear.

More explicitly handle references. All callers hold a reference for the
duration that they hold the instance. Registry.shms may transitively hold Shms
with no references, so it must TryIncRef to determine if they are still valid.

PiperOrigin-RevId: 288314529
2020-01-06 09:29:19 -08:00
Ghanan Gowripalan 83ab47e87b Use opaque interface identifiers when generating IPv6 addresses via SLAAC
Support using opaque interface identifiers when generating IPv6 addresses via
SLAAC when configured to do so.

Note, this change does not handle retries in response to DAD conflicts yet.
That will also come in a later change.

Test: Test that when SLAAC addresses are generated, they use opaque interface
identifiers when configured to do so.
PiperOrigin-RevId: 288078605
2020-01-03 18:28:22 -08:00
Zach Koopmans bf53d325dd Remove FIXME comments to close old bug.
PiperOrigin-RevId: 288075400
2020-01-03 17:47:29 -08:00
Ghanan Gowripalan d1d878a801 Support generating opaque interface identifiers as defined by RFC 7217
Support generating opaque interface identifiers as defined by RFC 7217 for
auto-generated IPv6 link-local addresses. Opaque interface identifiers will also
be used for IPv6 addresses auto-generated via SLAAC in a later change.

Note, this change does not handle retries in response to DAD conflicts yet.
That will also come in a later change.

Tests: Test that when configured to generated opaque IIDs, they are properly
generated as outlined by RFC 7217.
PiperOrigin-RevId: 288035349
2020-01-03 13:00:19 -08:00
Jamie Liu 1f384ac42b Add VFS2 support for device special files.
- Add FileDescriptionOptions.UseDentryMetadata, which reduces the amount of
  boilerplate needed for device FDs and the like between filesystems.

- Switch back to having FileDescription.Init() take references on the Mount and
  Dentry; otherwise managing refcounts around failed calls to
  OpenDeviceSpecialFile() / Device.Open() is tricky.

PiperOrigin-RevId: 287575574
2019-12-30 11:36:41 -08:00
Jamie Liu 796f53c0be Add VFS2 support for /proc/filesystems.
Updates #1195

PiperOrigin-RevId: 287269106
2019-12-27 00:13:54 -08:00
Fabricio Voznika 3c125eb219 Initial procfs implementation in VFSv2
Updates #1195

PiperOrigin-RevId: 287227722
2019-12-26 14:45:35 -08:00
gVisor bot 5b9034cc18 Merge pull request #1461 from xiaobo55x:ptrace_sysemu
PiperOrigin-RevId: 287225250
2019-12-26 14:19:34 -08:00
gVisor bot 7b5a59d503 Merge pull request #1460 from lubinszARM:pr_clean_code1
PiperOrigin-RevId: 287221280
2019-12-26 13:42:39 -08:00
gVisor bot 87e4d03fdf Automated rollback of changelist 287029703
PiperOrigin-RevId: 287217899
2019-12-26 13:05:52 -08:00
Ryan Heacock e013c48c78 Enable IP_RECVTOS socket option for datagram sockets
Added the ability to get/set the IP_RECVTOS socket option on UDP endpoints. If
enabled, TOS from the incoming Network Header passed as ancillary data in the
ControlMessages.

Test:
* Added unit test to udp_test.go that tests getting/setting as well as
verifying that we receive expected TOS from incoming packet.
* Added a syscall test
PiperOrigin-RevId: 287029703
2019-12-24 08:49:39 -08:00
Bin Lu 7b83d21856 slight changes to ring0&pagetables for Arm64
There are 2 jobs have been finished in this patch:
1, a comment was added to explain the purpose of the extra NOPs in Vectors().
2, some merge errors were fixed.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-12-24 10:50:11 +08:00
Fabricio Voznika 574e988f2b Fix deadlock in kernfs.Filesystem.revalidateChildLocked
It was calling Dentry.InsertChild with the dentry's mutex
already locked.

Updates #1035

PiperOrigin-RevId: 286962742
2019-12-23 17:32:46 -08:00
Jamie Liu f45df7505b Clean up vfs.FilesystemImpl methods that operate on parent directories.
- Make FilesystemImpl methods that operate on parent directories require
  !rp.Done() (i.e. there is at least one path component to resolve) as
  precondition and postcondition (in cases where they do not finish path
  resolution due to mount boundary / absolute symlink), and require that they
  do not need to follow the last path component (the file being created /
  deleted) as a symlink. Check for these in VFS.

- Add FilesystemImpl.GetParentDentryAt(), which is required to obtain the old
  parent directory for VFS.RenameAt(). (Passing the Dentry to be renamed
  instead has the wrong semantics if the file named by the old path is a mount
  point since the Dentry will be on the wrong Mount.)

- Update memfs to implement these methods correctly (?), including RenameAt.

- Change fspath.Parse() to allow empty paths (to simplify implementation of
  AT_EMPTY_PATH).

- Change vfs.PathOperation to take a fspath.Path instead of a raw pathname;
  non-test callers will need to fspath.Parse() pathnames themselves anyway in
  order to detect absolute paths and select PathOperation.Start accordingly.

PiperOrigin-RevId: 286934941
2019-12-23 13:18:39 -08:00
Zach Koopmans e548ce1805 Add python3-pip as dependency for Kokoro VM images.
bm-tools requires python3 and pip3 in order to run
tests. Add pip3 so that dependencies correctly install
for Kokoro runs with bazel.

PiperOrigin-RevId: 286923840
2019-12-23 11:49:29 -08:00
Ghanan Gowripalan 5bc4ae9d57 Clear any host-specific NDP state when becoming a router
This change supports clearing all host-only NDP state when NICs become routers.
All discovered routers, discovered on-link prefixes and auto-generated addresses
will be invalidated when becoming a router. This is because normally, routers do
not process Router Advertisements to discover routers or on-link prefixes, and
do not do SLAAC.

Tests: Unittest to make sure that all discovered routers, discovered prefixes
and auto-generated addresses get invalidated when transitioning from a host to
a router.
PiperOrigin-RevId: 286902309
2019-12-23 08:55:25 -08:00
Haibo Xu b6e31aadaa Replace syscall.PTRACE_SYSEMU with unix.PTRACE_SYSEMU
Linux PTRACE_SYSEMU support on arm64 was merged to mainline from
V5.3, and the corresponding support in go also enabled recently.

Since the "syscall" package is locked down from go 1.4, so the ptrace
PTRACE_SYSEMU definition can't be added to package "syscall" on arm64.
According to the golang community, updates required by new systems or
versions should use the corresponding package in the golang.org/x/sys
repository instead(https://golang.org/pkg/syscall/).

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I2f917bb2be62f990c3e158e2bb99e094ea03f751
2019-12-23 06:42:03 +00:00
gVisor bot d1528df715 Merge pull request #1026 from lubinszARM:pr_savable
PiperOrigin-RevId: 286667216
2019-12-20 18:07:09 -08:00
Jamie Liu 818eb22b11 Add vfs.ResolvingPath.HandleJump().
PiperOrigin-RevId: 286666533
2019-12-20 17:41:49 -08:00
Jamie Liu 21a14e9532 Add vfs.Dentry.Children().
PiperOrigin-RevId: 286660774
2019-12-20 16:44:54 -08:00
Kevin Krakauer 08c39e2587 Change TODO to track correct bug.
PiperOrigin-RevId: 286639163
2019-12-20 14:19:21 -08:00
Jamie Liu 3eb489ed6c Move VFS2 file description status flags to vfs.FileDescription.
PiperOrigin-RevId: 286616668
2019-12-20 11:53:48 -08:00
Dean Deng 822d847cca Check for valid nfds before copying in an fd set.
Otherwise, CopyInFDSet will try to allocate a negative-length slice.

PiperOrigin-RevId: 286584907
2019-12-20 08:44:53 -08:00
Andrei Vagin 29955a4797 futex: wake one waiter if futex_wake is called with a non-positive value
This change is needed to be compatible with the Linux kernel.

There is no glibc wrapper for the futex system call, so it is easy to
make a mistake and call syscall(__NR_futex, FUTEX_WAKE, addr) without
the fourth argument. This works on Linux, because it wakes one waiter
even if val is nonpositive.

PiperOrigin-RevId: 286494396
2019-12-19 17:26:44 -08:00
Dean Deng 7419e0e5d7 Parameterize mmap tests.
This test suite has existed for quite a while and has become kind of messy.
Various tests can be joined together by parameterizing.

PiperOrigin-RevId: 286482240
2019-12-19 16:07:04 -08:00
Brad Burlage 80c8aecd51 Install python2 in the Dockerfile.
Without it, we get a build failure (inside the container) when trying to build
//runsc.

PiperOrigin-RevId: 286474518
2019-12-19 15:26:00 -08:00
Nicolas Lacasse bb00438f36 Make masterInodeOperations.Truncate take a pointer receiver.
Otherwise a copy happens, which triggers a data race when reading
masterInodeOperations.SimpleFileOperations.uattr, which must be accessed with a
lock held.

PiperOrigin-RevId: 286464473
2019-12-19 14:34:53 -08:00
Andrei Vagin 57ce26c0b4 net/tcp: allow to call listen without bind
When listen(2) is called on an unbound socket, the socket is
automatically bound to a random free port with the local address
set to INADDR_ANY.

PiperOrigin-RevId: 286305906
2019-12-18 18:24:17 -08:00
gVisor bot 98e8246ad1 Merge pull request #890 from lubinszARM:pr_phyap
PiperOrigin-RevId: 286299056
2019-12-18 17:37:30 -08:00
Fabricio Voznika 0d475cdb01 Increase waitForProcessList timeout
It can take more than 10 seconds when running under --race.

PiperOrigin-RevId: 286296060
2019-12-18 17:10:44 -08:00
Jamie Liu 744401297a Add VFS2 plumbing for extended attributes.
PiperOrigin-RevId: 286281274
2019-12-18 15:48:45 -08:00
Ghanan Gowripalan 8e6e87f8e8 Allow 'out-of-line' routing table updates for Router and Prefix discovery events
This change removes the requirement that a new routing table be provided when a
router or prefix discovery event happens so that an updated routing table may
be provided to the stack at a later time from the event.

This change is to address the use case where the netstack integrator may need to
obtain a lock before providing updated routes in response to the events above.

As an example, say we have an integrator that performs the below two operations
operations as described:
A. Normal route update:
  1. Obtain integrator lock
  2. Update routes in the integrator
  3. Call Stack.SetRouteTable with the updated routes
    3.1. Obtain Stack lock
    3.2. Update routes in Stack
    3.3. Release Stack lock
  4. Release integrator lock
B. NDP event triggered route update:
  1. Obtain Stack lock
  2. Call event handler
    2.1. Obtain integrator lock
    2.2. Update routes in the integrator
    2.3. Release integrator lock
    2.4. Return updated routes to update Stack
  3. Update routes in Stack
  4. Release Stack lock

A deadlock may occur if a Normal route update was attemped at the same time an
NDP event triggered route update was attempted. With threads T1 and T2:
1) T1 -> A.1, A.2
2) T2 -> B.1
3) T1 -> A.3 (hangs at A.3.1 since Stack lock is taken in step 2)
4) T2 -> B.2 (hangs at B.2.1 since integrator lock is taken in step 1)

Test: Existing tests were modified to not provide or expect routing table
changes in response to Router and Prefix discovery events.
PiperOrigin-RevId: 286274712
2019-12-18 15:18:33 -08:00
gVisor bot ac3b3bb40e Merge pull request #1322 from lubinszARM:pr_vfp_ring0
PiperOrigin-RevId: 286259750
2019-12-18 14:52:35 -08:00
Ghanan Gowripalan 628948b1e1 Cleanup NDP Tests
This change makes sure that test variables are captured before running tests
in parallel, and removes unneeded buffered channel allocations. This change also
removes unnecessary timeouts.

PiperOrigin-RevId: 286255066
2019-12-18 14:24:39 -08:00
Jay Zhuang 18d6e59b45 Switch to netinet/tcp.h and poll.h to for better platform portability.
PiperOrigin-RevId: 286249699
2019-12-18 13:58:38 -08:00
Michael Pratt 334a513f11 Add Mems_allowed to /proc/PID/status
PiperOrigin-RevId: 286248378
2019-12-18 13:16:28 -08:00