Commit Graph

986 Commits

Author SHA1 Message Date
Ian Gudger 6a59e7f510 Rename DowngradableRWMutex to RWmutex.
Also renames TMutex to Mutex.

These custom mutexes aren't any worse than the standard library versions (same
code), so having both seems redundant.

PiperOrigin-RevId: 290873587
2020-01-21 19:36:12 -08:00
gVisor bot f6225b111b Merge pull request #1609 from xiaobo55x:uname
PiperOrigin-RevId: 290849438
2020-01-21 17:59:00 -08:00
gVisor bot b3405a719c Merge pull request #1275 from lubinszARM:pr_ring0_5
PiperOrigin-RevId: 290839263
2020-01-21 16:09:25 -08:00
Mithun Iyer 7e6fbc6afe Add a new TCP stat for current open connections.
Such a stat accounts for all connections that are currently
established and not yet transitioned to close state.
Also fix bug in double increment of CurrentEstablished stat.

Fixes #1579

PiperOrigin-RevId: 290827365
2020-01-21 15:43:39 -08:00
Rahat Mahmood ad1968ed56 Implement sysfs.
PiperOrigin-RevId: 290822487
2020-01-21 15:13:26 -08:00
gVisor bot 16694ad2ba Merge pull request #1274 from lubinszARM:pr_ring0_4
PiperOrigin-RevId: 290811598
2020-01-21 13:56:48 -08:00
Fabricio Voznika d46c397a1c Add line break to /proc/net files
Some files were missing the last line break.

PiperOrigin-RevId: 290808898
2020-01-21 13:28:24 -08:00
Dean Deng 2ba6198851 Add syscalls for lgetxattr, fgetxattr, lsetxattr, and fsetxattr.
Note that these simply will use the same logic as getxattr and setxattr, which
is not yet implemented for most filesystems.

PiperOrigin-RevId: 290800960
2020-01-21 12:43:18 -08:00
gVisor bot 5f82f092e7 Merge pull request #1558 from kevinGC:iptables-write-input-drop
PiperOrigin-RevId: 290793754
2020-01-21 12:08:52 -08:00
Haibo Xu c0e39a8271 Enable uname syscall support on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I206f38416a64d7c6a8531d8eb305c6ea239616b8
2020-01-20 02:57:25 +00:00
Nicolas Lacasse 10401599e1 Include the cgroup name in the superblock options in /proc/self/mountinfo.
Java 11 parses /proc/self/mountinfo for cgroup information. Java 11.0.4 uses
the mount path to determine what cgroups existed, but Java 11.0.5 reads the
cgroup names from the superblock options.

This CL adds the cgroup name to the superblock options if the filesystem type
is "cgroup". Since gVisor doesn't actually support cgroups yet, we just infer
the cgroup name from the path.

PiperOrigin-RevId: 290434323
2020-01-18 09:34:04 -08:00
Eyal Soha 47d85257d3 Filter out received packets with a local source IP address.
CERT Advisory CA-96.21 III. Solution advises that devices drop packets which
could not have correctly arrived on the wire, such as receiving a packet where
the source IP address is owned by the device that sent it.

Fixes #1507

PiperOrigin-RevId: 290378240
2020-01-17 18:26:20 -08:00
Nicolas Lacasse f1a5178c58 Fix data race in MountNamespace.resolve.
We must hold fs.renameMu to access Dirent.parent.

PiperOrigin-RevId: 290340804
2020-01-17 14:21:27 -08:00
Nicolas Lacasse 80d0f93044 Fix data race in tty.queue.readableSize.
We were setting queue.readable without holding the lock.

PiperOrigin-RevId: 290306922
2020-01-17 11:22:10 -08:00
Fabricio Voznika 8e8d0f96f6 Add /proc/[pid]/cgroups file
Updates #1195

PiperOrigin-RevId: 290298266
2020-01-17 10:41:44 -08:00
Fabricio Voznika ff99609858 Add /proc/net/* files
Updates #1195

PiperOrigin-RevId: 290285420
2020-01-17 10:21:46 -08:00
Haibo Xu acf2d6dcc3 Enable stat syscall support on arm64.
x86 and arm64 use a different stat struct in Linux
kernel, so the stat() syscall implementation has
to handle the file stat data separately.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: If3986e915a667362257a54e7fbbcc1fe18951015
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/1493 from xiaobo55x:stat f15a216d9297eb9a96d2c483d396a9919145d7fa
PiperOrigin-RevId: 290274287
2020-01-17 09:51:28 -08:00
Dean Deng 345df7cab4 Add explanation for implementation of BSD full file locks.
PiperOrigin-RevId: 290272560
2020-01-17 08:11:52 -08:00
Adin Scannell 19b4653147 Remove unused rpcinet.
PiperOrigin-RevId: 290198756
2020-01-16 20:21:09 -08:00
Dean Deng 7a45ae7e67 Implement setxattr for overlays.
PiperOrigin-RevId: 290186303
2020-01-16 18:15:02 -08:00
Fabricio Voznika ab48112e41 Add IfChange/ThenChange reminders in fs/proc
There is a lot of code duplication for VFSv2 and this
serves as remind to keep the copies in sync.

Updates #1195

PiperOrigin-RevId: 290139234
2020-01-16 15:05:40 -08:00
Nicolas Lacasse 70d7c52bd7 Implement tmpfs.SetStat with a size argument.
This is similar to 'Truncate' in vfs1.

Updates https://github.com/google/gvisor/issues/1197

PiperOrigin-RevId: 290139140
2020-01-16 14:39:55 -08:00
Fabricio Voznika 3dd3275da7 Add more files to /proc/[pid]/*
Files not implemented require VFSv2 plumbing into the kernel.
Also, cgroup is not implemented yet.

Updates #1195

PiperOrigin-RevId: 290129176
2020-01-16 14:10:05 -08:00
Dean Deng 07f2584979 Plumb getting/setting xattrs through InodeOperations and 9p gofer interfaces.
There was a very bare get/setxattr in the InodeOperations interface. Add
context.Context to both, size to getxattr, and flags to setxattr.
Note that extended attributes are passed around as strings in this
implementation, so size is automatically encoded into the value. Size is
added in getxattr so that implementations can return ERANGE if a value is larger
than can fit in the user-allocated buffer. This prevents us from unnecessarily
passing around an arbitrarily large xattr when the user buffer is actually too
small.

Don't use the existing xattrwalk and xattrcreate messages and define our
own, mainly for the sake of simplicity.

Extended attributes will be implemented in future commits.

PiperOrigin-RevId: 290121300
2020-01-16 12:56:33 -08:00
Fabricio Voznika 7b7c31820b Add remaining /proc/* and /proc/sys/* files
Except for one under /proc/sys/net/ipv4/tcp_sack.
/proc/pid/* is still incomplete.

Updates #1195

PiperOrigin-RevId: 290120438
2020-01-16 12:30:21 -08:00
gVisor bot fea1ce655d Merge pull request #1272 from lubinszARM:pr_ring0_2
PiperOrigin-RevId: 290113719
2020-01-16 11:56:09 -08:00
Haibo Xu 420d335fc9 Enable clone syscall support on arm64.
sys_clone has many flavors in Linux, and amd64 chose
a different one from x86(different arguments order).
Ref kernel/fork.c for more info.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I6c8cbc685f4a6e786b171715ab68292fc95cbf48
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/1545 from xiaobo55x:clone 156bd2dfbc63ef5291627b0578ddea77997393b2
PiperOrigin-RevId: 290093953
2020-01-16 10:28:11 -08:00
Nicolas Lacasse d6fb1ec6c7 Add timestamps to VFS2 tmpfs, and implement some of SetStat.
PiperOrigin-RevId: 289962040
2020-01-15 16:32:55 -08:00
gVisor bot 2ebd21478e Merge pull request #1540 from laijs:fix-PCIDs
PiperOrigin-RevId: 289925133
2020-01-15 13:48:51 -08:00
lubinszARM ff78a72170 enable pkg/sentry/arch to support arm64 basically
Signed-off-by: Bin Lu <bin.lu@arm.com>
Change-Id: I9cce23db4e5caec82ce42b4970fdb7f7e8c08f1d
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/773 from lubinszARM:pr_arch_basic 3fe2fd8e6286766bbe489ef971dce204f924feba
PiperOrigin-RevId: 289795569
2020-01-14 22:24:28 -08:00
Tamir Duberstein 50625cee59 Implement {g,s}etsockopt(IP_RECVTOS) for UDP sockets
PiperOrigin-RevId: 289718534
2020-01-14 13:33:23 -08:00
Tamir Duberstein debd213da6 Allow dual stack sockets to operate on AF_INET
Fixes #1490
Fixes #1495

PiperOrigin-RevId: 289523250
2020-01-13 14:47:22 -08:00
Kevin Krakauer 36641a2195 Only allow INPUT modifications. 2020-01-13 14:14:49 -08:00
Kevin Krakauer 31e49f4b19 Merge branch 'master' into iptables-write-input-drop 2020-01-13 12:22:15 -08:00
gVisor bot b30cfb1df7 Merge pull request #1528 from kevinGC:iptables-write
PiperOrigin-RevId: 289479774
2020-01-13 11:26:26 -08:00
Ian Gudger 27500d529f New sync package.
* Rename syncutil to sync.
* Add aliases to sync types.
* Replace existing usage of standard library sync package.

This will make it easier to swap out synchronization primitives. For example,
this will allow us to use primitives from github.com/sasha-s/go-deadlock to
check for lock ordering violations.

Updates #1472

PiperOrigin-RevId: 289033387
2020-01-09 22:02:24 -08:00
gVisor bot ee3158f713 Merge pull request #1423 from xiaobo55x:strace
PiperOrigin-RevId: 288965915
2020-01-09 13:58:24 -08:00
Eyal Soha 8643933d6e Change BindToDeviceOption to store NICID
This makes it possible to call the sockopt from go even when the NIC has no
name.

PiperOrigin-RevId: 288955236
2020-01-09 13:07:53 -08:00
Lai Jiangshan fdfa05ff2c Avoid panic when c.PCIDs is nil
When PCID is disabled, there would throw a panic
when dropPageTables() access to c.PCID without check.

Signed-off-by: Lai Jiangshan <eag0628@gmail.com>
2020-01-09 09:18:33 +00:00
Kevin Krakauer 781a68eeb6 It works! It drops some packets. 2020-01-08 21:39:13 -08:00
Kevin Krakauer 06e2366e96 Merge branch 'iptables-write' into iptables-write-input-drop 2020-01-08 20:05:02 -08:00
Kevin Krakauer ae060a63d9 More GH comments. 2020-01-08 17:30:08 -08:00
Ian Lewis fbb2c008e2 Return correct length with MSG_TRUNC for unix sockets.
This change calls a new Truncate method on the EndpointReader in RecvMsg for
both netlink and unix sockets.  This allows readers such as sockets to peek at
the length of data without actually reading it to a buffer.

Fixes #993 #1240

PiperOrigin-RevId: 288800167
2020-01-08 17:24:05 -08:00
Dean Deng 565b641483 Define sizes for extent headers and entries separately to improve clarity.
PiperOrigin-RevId: 288799694
2020-01-08 16:58:12 -08:00
Kevin Krakauer f26a576984 Addressed GH comments 2020-01-08 16:35:01 -08:00
Ting-Yu Wang b3ae8a62cf Fix slice bounds out of range panic in parsing socket control message.
Panic found by syzakller.

PiperOrigin-RevId: 288799046
2020-01-08 16:32:34 -08:00
Kevin Krakauer 0999ae8b34 Getting a panic when running tests. For some reason the filter table is
ending up with the wrong chains and is indexing -1 into rules.
2020-01-08 15:57:25 -08:00
Tamir Duberstein d530df2f95 Introduce tcpip.SockOptBool
...and port V6OnlyOption to it.

PiperOrigin-RevId: 288789451
2020-01-08 15:40:48 -08:00
Kevin Krakauer b2a881784c Built dead-simple traversal, but now getting depedency cycle error :'( 2020-01-08 14:48:47 -08:00
Tamir Duberstein a271bccfc6 Rename tcpip.SockOpt{,Int}
PiperOrigin-RevId: 288772878
2020-01-08 14:20:07 -08:00