Skip to content

Commit 69d6da9

Browse files
committed
Merge pull request #11945 from Champ-Goblem:patch/runsc-fix-tty-panic
PiperOrigin-RevId: 785581719
2 parents db0c9e8 + 5f3d16e commit 69d6da9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/sentry/fsimpl/host/tty.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ func (t *TTYFileDescription) Ioctl(ctx context.Context, io usermem.IO, sysno uin
164164
return 0, linuxerr.ENOTTY
165165
}
166166

167-
fgpg, err := t.ThreadGroup().ForegroundProcessGroup(t.TTY())
167+
tg := t.ThreadGroup()
168+
if tg == nil {
169+
return 0, linuxerr.ENOTTY
170+
}
171+
fgpg, err := tg.ForegroundProcessGroup(t.TTY())
168172
if err != nil {
169173
return 0, err
170174
}
@@ -184,7 +188,12 @@ func (t *TTYFileDescription) Ioctl(ctx context.Context, io usermem.IO, sysno uin
184188
return 0, err
185189
}
186190
pgID := kernel.ProcessGroupID(pgIDP)
187-
if err := t.ThreadGroup().SetForegroundProcessGroupID(ctx, t.TTY(), pgID); err != nil {
191+
192+
tg := t.ThreadGroup()
193+
if tg == nil {
194+
return 0, linuxerr.ENOTTY
195+
}
196+
if err := tg.SetForegroundProcessGroupID(ctx, t.TTY(), pgID); err != nil {
188197
return 0, err
189198
}
190199

0 commit comments

Comments
 (0)