Commit Graph

1854 Commits

Author SHA1 Message Date
henry.tjf bc9de939fd tty: fix sending SIGTTOU on tty write
How to reproduce:
  $ echo "timeout 10 ls" > foo.sh
  $ chmod +x foo.sh
  $ ./foo.sh
  (will hang here for 10 secs, and the output of ls does not show)

When "ls" process writes to stdout, it receives SIGTTOU signal, and
hangs there. Until "timeout" process timeouts, and kills "ls" process.

The expected result is: "ls" writes its output into tty, and terminates
immdedately, then "timeout" process receives SIGCHLD and terminates.

The reason for this failure is that we missed the check for TOSTOP (if
set, background processes will receive the SIGTTOU signal when they do
write).

We use drivers/tty/n_tty.c:n_tty_write() as a reference.

Fixes: #862

Reported-by: chris.zn <chris.zn@antfin.com>
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
Signed-off-by: chenglang.hy <chenglang.hy@antfin.com>
2019-09-24 14:18:22 +00:00
Haibo Xu a26276b949 Enable pkg/bits support on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I490716f0e6204f0b3a43f71931b10d1ca541e128
2019-09-24 07:03:19 +00:00
Haibo Xu 2db866c45f Enable pkg/sleep support on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I9071e698c1f222e0fdf3b567ec4cbd97f0a8dde9
2019-09-24 06:42:26 +00:00
Nicolas Lacasse d5b3dd7cb4 Run all runtime tests in a single container.
This makes them run much faster. Also cleaned up the log reporting.

PiperOrigin-RevId: 270799808
2019-09-23 17:43:42 -07:00
Nicolas Lacasse f2ea8e6b24 Always set HOME env var with `runsc exec`.
We already do this for `runsc run`, but need to do the same for `runsc exec`.

PiperOrigin-RevId: 270793459
2019-09-23 17:06:02 -07:00
Adin Scannell 6c88f674af Add test for concurrent reads and writes.
PiperOrigin-RevId: 270789146
2019-09-23 16:44:30 -07:00
Bhasker Hariharan 9846da5e65 Fix bug in RstCausesPollHUP.
The test is checking the wrong poll_fd for POLLHUP. The only
reason it passed till now was because it was also checking
for POLLIN which was always true on the other fd from the
previous poll!

PiperOrigin-RevId: 270780401
2019-09-23 16:00:50 -07:00
Nicolas Lacasse 112736c579 Add test that runsc exec inherits the same environment as run.
PiperOrigin-RevId: 270764996
2019-09-23 14:47:30 -07:00
Andrei Vagin 03ee55cc62 netstack: convert more socket options to {Set,Get}SockOptInt
PiperOrigin-RevId: 270763208
2019-09-23 14:39:14 -07:00
Brad Burlage e6cf60bc0e Fix runsc checksum artifact name.
scripts/build.sh uses sha512sum, not sha256sum.

PiperOrigin-RevId: 270713604
2019-09-23 10:58:18 -07:00
gVisor bot 4aeedd47bf internal BUILD file cleanup.
PiperOrigin-RevId: 270680704
2019-09-23 08:25:13 -07:00
Jamie Liu fb55c2bd0d Change vfs.Dirent.Off to NextOff.
"d_off is the distance from the start of the directory to the start of the next
linux_dirent." - getdents(2).

PiperOrigin-RevId: 270349685
2019-09-20 14:24:29 -07:00
Ian Gudger 002f1d4aae Allow waiting for LinkEndpoint worker goroutines to finish.
Previously, the only safe way to use an fdbased endpoint was to leak the FD.
This change makes it possible to safely close the FD.

This is the first step towards having stoppable stacks.

Updates #837

PiperOrigin-RevId: 270346582
2019-09-20 14:10:02 -07:00
Jianfeng Tan 223481e927 fix set hostname
Previously, when we set hostname:

$ strace hostname abc
...
sethostname("abc", 3) = -1 ENAMETOOLONG (File name too long)
...

According to man 2 sethostname:

"The len argument specifies the number of bytes in name. (Thus, name
does not require a terminating null byte.)"

We wrongly use the CopyStringIn() to check terminating zero byte in
the implementation of sethostname syscall.

To fix this, we use CopyInBytes() instead.

Fixes: #861

Reported-by: chenglang.hy <chenglang.hy@antfin.com>
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
2019-09-20 17:57:25 +00:00
Jianfeng Tan 329b6653ff Implement /proc/net/tcp6
Fixes: #829

Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
Signed-off-by: Jielong Zhou <jielong.zjl@antfin.com>
2019-09-20 17:20:08 +00:00
Jamie Liu e9af227a61 Fix p9 integration of flipcall.
- Do not call Rread.SetPayload(flipcall packet window) in p9.channel.recv().

- Ignore EINTR from ppoll() in p9.Client.watch().

- Clean up handling of client socket FD lifetimes so that p9.Client.watch()
  never ppoll()s a closed FD.

- Make p9test.Harness.Finish() call clientSocket.Shutdown() instead of
  clientSocket.Close() for the same reason.

- Rework channel reuse to avoid leaking channels in the following case (suppose
  we have two channels):

  sendRecvChannel
    len(channels) == 2 => idx = 1
    inuse[1] = ch0
                                        sendRecvChannel
                                          len(channels) == 1 => idx = 0
                                          inuse[0] = ch1
    inuse[1] = nil
  sendRecvChannel
    len(channels) == 1 => idx = 0
    inuse[0] = ch0
                                          inuse[0] = nil
    inuse[0] == nil => ch0 leaked

- Avoid deadlocking p9.Client.watch() by calling channelsWg.Wait() without
  holding channelsMu.

- Bump p9test:client_test size to medium.

PiperOrigin-RevId: 270200314
2019-09-19 22:52:56 -07:00
Robert Tonic e975184bc5 Update InstallUDSFilters documentation to be accurate to functionality. 2019-09-19 17:44:46 -04:00
Robert Tonic 46beb91912 Fix documentation, clean up seccomp filter installation, rename helpers.
Filter installation has been streamlined and functions renamed. 
Documentation has been fixed to be standards compliant, and missing 
documentation added. gofmt has also been applied to modified files.
2019-09-19 17:10:50 -04:00
Adin Scannell 75781ab3ef Remove defer from hot path and ensure Atomic is applied consistently.
PiperOrigin-RevId: 270114317
2019-09-19 13:39:32 -07:00
gVisor bot 1c0324d5a1 Merge pull request #876 from xiaobo55x:hostcpu
PiperOrigin-RevId: 270094324
2019-09-19 12:03:38 -07:00
Kevin Krakauer 0a8a75f3da Job control: controlling TTYs and foreground process groups.
Adresses a deadlock with the rolled back change:
b6a5b950d2
Creating a session from an orphaned process group was causing a lock to be
acquired twice by a single goroutine. This behavior is addressed, and a test
(OrphanRegression) has been added to pty.cc.

Implemented the following ioctls:
- TIOCSCTTY - set controlling TTY
- TIOCNOTTY - remove controlling tty, maybe signal some other processes
- TIOCGPGRP - get foreground process group. Also enables tcgetpgrp().
- TIOCSPGRP - set foreground process group. Also enabled tcsetpgrp().

Next steps are to actually turn terminal-generated control characters (e.g. C^c)
into signals to the proper process groups, and to send SIGTTOU and SIGTTIN when
appropriate.

PiperOrigin-RevId: 270088599
2019-09-19 11:36:47 -07:00
Robert Tonic ac38a7ead0 Place the host UDS mounting behind --fsgofer-host-uds-allowed.
This commit allows the use of the `--fsgofer-host-uds-allowed` flag to 
enable mounting sockets and add the appropriate seccomp filters.
2019-09-19 12:37:15 -04:00
Hang Su d72c63664b Accelerate byte lookup in string with `bytealg/indexbyte`
`bytealg/indexbyte` will use AVX or SSE instruction set, if possible,
which could accelerate `CopyStringIn` function by 28%.

In worst case(CPU doesn't support SSE), `bytealg/indexbyte`
will degenerate to traversal lookup. When dealing with
short strings, `bytealg/indexbyte` has the same performance level as
before.

Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
Signed-off-by: Hang Su <darcy.sh@antfin.com>
2019-09-19 22:16:52 +08:00
Nicolas Lacasse 28f431335b Shard the runtime tests.
Default of 20 shards was arbitrary and will need fine-tuning in later CLs.

PiperOrigin-RevId: 269922871
2019-09-18 17:04:53 -07:00
Fabricio Voznika a1f8446921 Fix dev.sh --refresh to create target dir
PiperOrigin-RevId: 269921234
2019-09-18 16:56:01 -07:00
Haibo Xu cabe10e603 Enable pkg/sentry/hostcpu support on arm64.
Signed-off-by: Haibo Xu haibo.xu@arm.com
Change-Id: I333872da9bdf56ddfa8ab2f034dfc1f36a7d3132
2019-09-18 23:51:42 +00:00
Adin Scannell c98e7f0d19 Signalfd support
Note that the exact semantics for these signalfds are slightly different from
Linux. These signalfds are bound to the process at creation time. Reads, polls,
etc. are all associated with signals directed at that task. In Linux, all
signalfd operations are associated with current, regardless of where the
signalfd originated.

In practice, this should not be an issue given how signalfds are used. In order
to fix this however, we will need to plumb the context through all the event
APIs. This gets complicated really quickly, because the waiter APIs are all
netstack-specific, and not generally exposed to the context.  Probably not
worthwhile fixing immediately.

PiperOrigin-RevId: 269901749
2019-09-18 15:16:42 -07:00
Adin Scannell 461123ea35 Move the component into the repository structure.
The RELEASE file must be at the top-level for the signed
repository to work correctly.

PiperOrigin-RevId: 269897109
2019-09-18 14:57:12 -07:00
Bin Lu 38bc0b6b6a enable syscalls/linux to support arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
Change-Id: I45af8a54304f8bb0e248ab15f4e20b173ea9e430
2019-09-18 10:13:06 +00:00
Bin Lu 8e73e2cec5 enable kvm/testutil to support arm64
enable kvm/testutil to support arm64

The Arm64 user-mode execution stat consists of:
1, X0- X30
2, PC, SP, PSTATE
3, TPIDR_EL0, used for TLS
4, V0-V31: 32 128-bit registers for floating point and simd
5, FPSR

Currently, we first try to achieve goals 1 and 2.

This patch provids basic test utils for goals 1 & 2

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-09-18 09:57:59 +00:00
Andrei Vagin b63d56b0b4 scripts/build.sh: fix kokoro failure "KOKORO_BUILD_NIGHTLY: unbound variable"
PiperOrigin-RevId: 269690988
2019-09-17 17:26:01 -07:00
Ghanan Gowripalan 60fe8719e1 Automated rollback of changelist 268047073
PiperOrigin-RevId: 269658971
2019-09-17 14:47:09 -07:00
Nicolas Lacasse 062190d983 Follow-up fixes for image tests.
- Fix ARG syntax in Dockerfiles.
- Fix curl commands in Dockerfiles.
- Fix some paths in proctor binaries.
- Check error from Walk in search helper.

PiperOrigin-RevId: 269641686
2019-09-17 13:29:19 -07:00
Andrei Vagin 3b7119a7c9 platform/ptrace: log exit code for stub processes
PiperOrigin-RevId: 269631877
2019-09-17 12:45:22 -07:00
Ian Gudger 747320a7aa Update remaining users of LinkEndpoints to not refer to them as an ID.
PiperOrigin-RevId: 269614517
2019-09-17 11:31:00 -07:00
Adin Scannell 191297ecbe Fix artifact pattern for repositories.
PiperOrigin-RevId: 269468986
2019-09-16 18:41:13 -07:00
Nicolas Lacasse 24b7eb2f86 Refactor and clean up image tests.
* Use multi-stage builds in Dockerfiles.
* Combine all proctor binaries into a single binary.
* Change the TestRunner interface to reduce code duplication.

PiperOrigin-RevId: 269462101
2019-09-16 17:51:22 -07:00
Michael Pratt 56cb004218 Migrate from gflags to absl flags
absl flags are more modern and we can easily depend on them directly.

The repo now successfully builds with --incompatible_load_cc_rules_from_bzl.

PiperOrigin-RevId: 269387081
2019-09-16 11:58:27 -07:00
Fabricio Voznika 010b093258 Bring back to life features lost in recent refactor
- Sandbox logs are generated when running tests
- Kokoro uploads the sandbox logs
- Supports multiple parallel runs
- Revive script to install locally built runsc with docker

PiperOrigin-RevId: 269337274
2019-09-16 08:17:00 -07:00
Andrei Vagin 239a07aabf gvisor: return ENOTDIR from the unlink syscall
ENOTDIR has to be returned when a component used as a directory in
pathname is not, in  fact,  a directory.

PiperOrigin-RevId: 269037893
2019-09-13 21:44:57 -07:00
Adin Scannell 2bbf73d9ed Remove stale configurations.
PiperOrigin-RevId: 268947847
2019-09-13 11:39:55 -07:00
Adin Scannell a8834fc555 Update p9 to support flipcall.
PiperOrigin-RevId: 268845090
2019-09-12 23:37:31 -07:00
Adin Scannell 7c6ab6a219 Implement splice methods for pipes and sockets.
This also allows the tee(2) implementation to be enabled, since dup can now be
properly supported via WriteTo.

Note that this change necessitated some minor restructoring with the
fs.FileOperations splice methods. If the *fs.File is passed through directly,
then only public API methods are accessible, which will deadlock immediately
since the locking is already done by fs.Splice. Instead, we pass through an
abstract io.Reader or io.Writer, which elide locks and use the underlying
fs.FileOperations directly.

PiperOrigin-RevId: 268805207
2019-09-12 17:43:27 -07:00
Michael Pratt df5d377521 Remove go_test from go_stateify and go_marshal
They are no-ops, so the standard rule works fine.

PiperOrigin-RevId: 268776264
2019-09-12 15:10:17 -07:00
gVisor bot 78cfbbda4b Merge pull request #843 from nlacasse:version
PiperOrigin-RevId: 268772451
2019-09-12 14:55:24 -07:00
Ghanan Gowripalan 857940d30d Automated rollback of changelist 268047073
PiperOrigin-RevId: 268757842
2019-09-12 13:52:25 -07:00
Adin Scannell 574eda8880 Update repository directory structure.
Currently it will not work with apt out of the box, as we
require the dists/ prefix, along with a distribution name.

This tweaks the overall structure to allow for the same URL
prefix to be used for all repositories, and enables multiple
architectures.

Fixes #852

PiperOrigin-RevId: 268756104
2019-09-12 13:44:18 -07:00
Nicolas Lacasse e2528cae76 Bump bazel toolchain.
This fixes the RBE warning:
DEBUG: rbe_default not using checked in configs; Bazel version 0.29.1 was
picked/selected but no checked in config was found in map[...]
PiperOrigin-RevId: 268747944
2019-09-12 13:04:50 -07:00
Adin Scannell 69f2c41b7a Drop unavailable package.
PiperOrigin-RevId: 268614014
2019-09-11 22:30:28 -07:00
Adin Scannell 96a25e080c Ensure appropriate tools are installed on image.
PiperOrigin-RevId: 268608466
2019-09-11 22:13:26 -07:00