Commit Graph

229 Commits

Author SHA1 Message Date
Nayana Bidari 0a52b64794 - Add more comments for the TCP_INFO struct fields.
PiperOrigin-RevId: 354595623
2021-01-29 13:15:57 -08:00
Nayana Bidari 99988e45ed Add support for more fields in netstack for TCP_INFO
This CL adds support for the following fields:
- RTT, RTTVar, RTO
- send congestion window (sndCwnd) and send slow start threshold (sndSsthresh)
- congestion control state(CaState)
- ReorderSeen

PiperOrigin-RevId: 354195361
2021-01-27 16:14:50 -08:00
Dean Deng f52f0101bb Implement F_GETLK fcntl.
Fixes #5113.

PiperOrigin-RevId: 353313374
2021-01-22 13:58:16 -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
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
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
Jing Chen 1e56a2f9a2 Implement command SEM_INFO and SEM_STAT for semctl.
PiperOrigin-RevId: 347711998
2020-12-15 16:06:06 -08:00
Adin Scannell 4cba3904f4 Remove existing nogo exceptions.
PiperOrigin-RevId: 347047550
2020-12-11 12:06:49 -08:00
Ayush Ranjan af4afdc0e0 [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 Chen a78cef0ed7 Implement command IPC_INFO for semctl.
PiperOrigin-RevId: 345589628
2020-12-03 19:57:51 -08:00
Etienne Perot 6f60a2b0a2 Implement `fcntl` options `F_GETSIG` and `F_SETSIG`.
These options allow overriding the signal that gets sent to the process when
I/O operations are available on the file descriptor, rather than the default
`SIGIO` signal. Doing so also populates `siginfo` to contain extra information
about which file descriptor caused the event (`si_fd`) and what events happened
on it (`si_band`). The logic around which FD is populated within `si_fd`
matches Linux's, which means it has some weird edge cases where that value may
not actually refer to a file descriptor that is still valid.

This CL also ports extra S/R logic regarding async handler in VFS2.
Without this, async I/O handlers aren't properly re-registered after S/R.

PiperOrigin-RevId: 345436598
2020-12-03 06:20:29 -08:00
Jing Chen b26dd6d9b7 Add /proc/sys/kernel/sem.
PiperOrigin-RevId: 345178956
2020-12-02 00:13:24 -08:00
Chong Cai bc91ae17f6 Add SHA512 to merkle tree library
PiperOrigin-RevId: 339377254
2020-10-27 19:12:35 -07:00
Jing Chen e5c1b035ab Introduce SemidDs struct for amd64 and arm64.
PiperOrigin-RevId: 338756277
2020-10-23 16:12:12 -07:00
Jamie Liu 6bad4851d4 Implement MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ.
cf. 2a36ab717e8f "rseq/membarrier: Add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ"

PiperOrigin-RevId: 336186795
2020-10-08 16:23:04 -07:00
Jamie Liu 1336af78d5 Implement membarrier(2) commands other than *_SYNC_CORE.
Updates #267

PiperOrigin-RevId: 335713923
2020-10-06 13:55:16 -07:00
Rahat Mahmood 4f462b0ed9 Convert uses of the binary package in kernel to go-marshal.
PiperOrigin-RevId: 335077195
2020-10-02 12:24:24 -07:00
Kevin Krakauer 6f8d64f422 ip6tables: redirect support
Adds support for the IPv6-compatible redirect target. Redirection is a limited
form of DNAT, where the destination is always the localhost.

Updates #3549.

PiperOrigin-RevId: 334698344
2020-09-30 16:04:26 -07:00
Chong Cai 38704d9b66 Implement ioctl with measure in verity fs
PiperOrigin-RevId: 334682753
2020-09-30 14:45:12 -07:00
Kevin Krakauer 7fbb45e8ed iptables: refactor to make targets extendable
Like matchers, targets should use a module-like register/lookup system. This
replaces the brittle switch statements we had before.

The only behavior change is supporing IPT_GET_REVISION_TARGET. This makes it
much easier to add IPv6 redirect in the next change.

Updates #3549.

PiperOrigin-RevId: 334469418
2020-09-29 15:02:25 -07:00
Chong Cai 90d9d0e7bd Correct FS_IOC_GETFLAGS value
The previous value was for unix

PiperOrigin-RevId: 333571962
2020-09-24 12:29:35 -07:00
Andrei Vagin c6e749fb32 fs/fuse: Move the 'marshal' and 'primitive' packages to the 'pkg' directory. 2020-09-16 12:19:30 -07:00
Boyuan He 8ab32686e2 fuse_open: add padding to open out request 2020-09-16 12:19:30 -07:00
Boyuan He 2051260e82 Implement FUSE_UNLINK
Fixes #3696
2020-09-16 12:19:30 -07:00
Craig Chi 70cfea2377 Fix comments of TODO issues. 2020-09-16 12:19:30 -07:00
Craig Chi 2fbbe3b768 Add comments for exported attributes 2020-09-16 12:19:30 -07:00
Craig Chi bf8efe8cdf Implement FUSE_SETATTR
This commit implements FUSE_SETATTR command. When a system call modifies
the metadata of a regular file or a folder by chown(2), chmod(2),
truncate(2), utime(2), or utimes(2), they should be translated to
corresponding FUSE_SETATTR command and sent to the FUSE server.

Fixes #3332
2020-09-16 12:19:30 -07:00
Craig Chi 4181e8c974 Add fh support for revise attr and fstat(2) test
According to Linux 4.4's FUSE behavior, the flags and fh attributes in
FUSE_GETATTR are only used in read, write, and lseek. fstat(2) doesn't
use them either. Add tests to ensure the requests sent from FUSE module
are consistent with Linux's.

Updates #3655
2020-09-16 12:19:30 -07:00
Jinmou Li 98faed55e6 Implement FUSE_WRITE
This commit adds basic write(2) support for FUSE.
2020-09-16 12:19:30 -07:00
Craig Chi 18f1e1c91b Implement FUSE_CREATE
FUSE_CREATE is called when issuing creat(2) or open(2) with O_CREAT. It
creates a new file on the FUSE filesystem.

Fixes #3825
2020-09-16 12:19:30 -07:00
Jinmou Li e91c026672 Downgrade FUSE minor version support and clarify comments 2020-09-16 12:19:30 -07:00
Craig Chi 1d8029022e fuse: remove unused marshalling functions
This commit removes unused marshalling functions in linux abi package
and moves self-defined FUSEInitRes wrapper to fuse package.

Updates #3707
2020-09-16 12:19:30 -07:00
Craig Chi 449986264f Support multiple FUSE kernel versions of FUSE_INIT response struct
The fuse_init_out struct changes in different FUSE kernel versions. A
FUSE server may implement older versions of fuse_init_out, but they
share common attributes from the beginning. Implement variable-length
marshallable interface to support older versions of ABI.

Fixes #3707
2020-09-16 12:19:30 -07:00
Ridwan Sharif d51ddcefdc fuse: use safe go_marshal API for FUSE
Until #3698 is resolved, this change is needed to ensure we're not
corrupting memory anywhere.
2020-09-16 12:19:30 -07:00
Ridwan Sharif 4a5857d644 fuse: Implement IterDirents for directory file description
Fixes #3255.

This change adds support for IterDirents. You can now use `ls` in
the FUSE sandbox.

Co-authored-by: Craig Chi <craigchi@google.com>
2020-09-16 12:19:30 -07:00
Ridwan Sharif bc07df8887 Implement FUSE_RMDIR
Fixes #3587

Co-authored-by: Craig Chi <craigchi@google.com>
2020-09-16 12:19:30 -07:00
Jinmou Li 713400d6b0 Implement FUSE_READ
Fixes #3206
2020-09-16 12:19:30 -07:00
Boyuan He 4d26c9929d Implement FUSE_MKDIR
Fixes #3392
2020-09-16 12:19:30 -07:00
Boyuan He 733d013f97 Implement FUSE_READLINK
Fixes #3316
2020-09-16 12:19:30 -07:00
Boyuan He b50c03b571 Implement FUSE_SYMLINK
Fixes #3452
2020-09-16 12:19:30 -07:00
Boyuan He b53e10f391 Implement FUSE_MKNOD
Fixes #3492
2020-09-16 12:19:30 -07:00
Boyuan He 947088e10a Implement FUSE_RELEASE/RELEASEDIR
Fixes #3314
2020-09-16 12:19:30 -07:00
Boyuan He 32044f94e9 Implement FUSE_OPEN/OPENDIR
Fixes #3174
2020-09-16 12:19:30 -07:00
Andrei Vagin d6ee3ae6d7 Implement FUSE_LOOKUP
Fixes #3231

Co-authored-by: Boyuan He <heboyuan@google.com>
2020-09-16 12:19:30 -07:00
Rahat Mahmood 9ef1c79922 Rename marshal.Task to marshal.CopyContext.
CopyContext is a better name for the interface because from
go-marshal's perspective, the interface has nothing to do with a
task. A kernel.Task happens to implement the interface, but so can
other things like MemoryManager and IO sequences.

PiperOrigin-RevId: 331959678
2020-09-16 02:10:12 -07:00
Rahat Mahmood d201feb8c5 Enable automated marshalling for the syscall package.
PiperOrigin-RevId: 331940975
2020-09-15 23:38:57 -07:00
Ian Lewis dcd532e2e4 Add support for OCI seccomp filters in the sandbox.
OCI configuration includes support for specifying seccomp filters. In runc,
these filter configurations are converted into seccomp BPF programs and loaded
into the kernel via libseccomp. runsc needs to be a static binary so, for
runsc, we cannot rely on a C library and need to implement the functionality
in Go.

The generator added here implements basic support for taking OCI seccomp
configuration and converting it into a seccomp BPF program with the same
behavior as a program generated by libseccomp.

- New conditional operations were added to pkg/seccomp to support operations
  available in OCI.
- AllowAny and AllowValue were renamed to MatchAny and EqualTo to better reflect
  that syscalls matching the conditionals result in the provided action not
  simply SCMP_RET_ALLOW.
- BuildProgram in pkg/seccomp no longer panics if provided an empty list of
  rules. It now builds a program with the architecture sanity check only.
- ProgramBuilder now allows adding labels that are unused. However, backwards
  jumps are still not permitted.

Fixes #510

PiperOrigin-RevId: 331938697
2020-09-15 23:19:17 -07:00
Chong Cai cb2e3c946a Implement gvisor verity fs ioctl with GETFLAGS
PiperOrigin-RevId: 331905347
2020-09-15 19:01:59 -07:00
Rahat Mahmood 3ca73841d7 Move the 'marshal' and 'primitive' packages to the 'pkg' directory.
PiperOrigin-RevId: 331256608
2020-09-11 17:42:49 -07:00
gVisor bot 360f1535c7 Implement ioctl with enable verity
ioctl with FS_IOC_ENABLE_VERITY is added to verity file system to enable
a file as verity file. For a file, a Merkle tree is built with its data.
For a directory, a Merkle tree is built with the root hashes of its
children.

PiperOrigin-RevId: 330604368
2020-09-08 15:54:21 -07:00