summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-03-05 22:19:23 -0800
committerShentubot <shentubot@google.com>2019-03-05 22:20:17 -0800
commitfcba4e8f040ab4b40e04b9315d718d7e5aa44635 (patch)
tree4b33e78a90d5d3f8de8e98faa79660bbc6e94146
parent1718fdd1a8e16f36433b069a0f5d88ea7bdb65f5 (diff)
Add uncaught signal message to the user log
This help troubleshoot cases where the container is killed and the app logs don't show the reason. PiperOrigin-RevId: 236982883 Change-Id: I361892856a146cea5b04abaa3aedbf805e123724
-rw-r--r--runsc/boot/BUILD1
-rw-r--r--runsc/boot/compat.go25
2 files changed, 20 insertions, 6 deletions
diff --git a/runsc/boot/BUILD b/runsc/boot/BUILD
index 4984231d7..daa197437 100644
--- a/runsc/boot/BUILD
+++ b/runsc/boot/BUILD
@@ -46,6 +46,7 @@ go_library(
"//pkg/sentry/fs/tty",
"//pkg/sentry/inet",
"//pkg/sentry/kernel",
+ "//pkg/sentry/kernel:uncaught_signal_go_proto",
"//pkg/sentry/kernel/auth",
"//pkg/sentry/kernel/kdefs",
"//pkg/sentry/limits",
diff --git a/runsc/boot/compat.go b/runsc/boot/compat.go
index 572b5b472..37d0c31fd 100644
--- a/runsc/boot/compat.go
+++ b/runsc/boot/compat.go
@@ -26,6 +26,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/log"
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
rpb "gvisor.googlesource.com/gvisor/pkg/sentry/arch/registers_go_proto"
+ ucspb "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/uncaught_signal_go_proto"
"gvisor.googlesource.com/gvisor/pkg/sentry/strace"
spb "gvisor.googlesource.com/gvisor/pkg/sentry/unimpl/unimplemented_syscall_go_proto"
)
@@ -73,12 +74,18 @@ func newCompatEmitter(logFD int) (*compatEmitter, error) {
}
// Emit implements eventchannel.Emitter.
-func (c *compatEmitter) Emit(msg proto.Message) (hangup bool, err error) {
- // Only interested in UnimplementedSyscall, skip the rest.
- us, ok := msg.(*spb.UnimplementedSyscall)
- if !ok {
- return false, nil
+func (c *compatEmitter) Emit(msg proto.Message) (bool, error) {
+ switch m := msg.(type) {
+ case *spb.UnimplementedSyscall:
+ c.emitUnimplementedSyscall(m)
+ case *ucspb.UncaughtSignal:
+ c.emitUncaughtSignal(m)
}
+
+ return false, nil
+}
+
+func (c *compatEmitter) emitUnimplementedSyscall(us *spb.UnimplementedSyscall) {
regs := us.Registers.GetArch().(*rpb.Registers_Amd64).Amd64
c.mu.Lock()
@@ -113,7 +120,13 @@ func (c *compatEmitter) Emit(msg proto.Message) (hangup bool, err error) {
c.sink.Infof("Unsupported syscall: %s, regs: %+v", c.nameMap.Name(uintptr(sysnr)), regs)
tr.onReported(regs)
}
- return false, nil
+}
+
+func (c *compatEmitter) emitUncaughtSignal(msg *ucspb.UncaughtSignal) {
+ sig := syscall.Signal(msg.SignalNumber)
+ c.sink.Infof(
+ "Uncaught signal: %q (%d), PID: %d, TID: %d, fault addr: %#x",
+ sig, msg.SignalNumber, msg.Pid, msg.Tid, msg.FaultAddr)
}
// Close implements eventchannel.Emitter.