From 8a1845f8b85021bdfec0b901ca9f3ede6ecf47f5 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Mon, 27 Feb 2023 11:10:50 -0800 Subject: [PATCH] Don't send a signal to a controlling thread group if one has not been set. Reported-by: syzbot+6ffd4294901528c6fd54@syzkaller.appspotmail.com PiperOrigin-RevId: 512678427 --- pkg/sentry/kernel/tty.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/sentry/kernel/tty.go b/pkg/sentry/kernel/tty.go index 509ac2e81..48402abee 100644 --- a/pkg/sentry/kernel/tty.go +++ b/pkg/sentry/kernel/tty.go @@ -49,7 +49,15 @@ func (tg *ThreadGroup) TTY() *TTY { func (tty *TTY) SignalForegroundProcessGroup(info *linux.SignalInfo) { tty.mu.Lock() defer tty.mu.Unlock() + tg := tty.tg + if tg == nil { + // This TTY is not a controlling thread group. This can happen + // if it was opened with O_NOCTTY, or if it failed the checks + // on session and leaders in SetControllingTTY(). There is + // nothing to signal. + return + } tg.pidns.owner.mu.Lock() tg.signalHandlers.mu.Lock()