mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix nil-pointer bug in tty.checkChange.
The logic is the same as Linux's __tty_check_change, but we forgot to check the case that the tty does not have an associated process group. PiperOrigin-RevId: 693119939
This commit is contained in:
committed by
gVisor bot
parent
c5775dbd0f
commit
892ba3d7f6
@@ -334,11 +334,12 @@ func (t *TTYFileDescription) checkChange(ctx context.Context, sig linux.Signal)
|
||||
|
||||
tg := task.ThreadGroup()
|
||||
pg := tg.ProcessGroup()
|
||||
ttyTg := t.tty.ThreadGroup()
|
||||
|
||||
// If the session for the task is different than the session for the
|
||||
// controlling TTY, then the change is allowed. Seems like a bad idea,
|
||||
// but that's exactly what linux does.
|
||||
if tg.Session() != t.tty.ThreadGroup().Session() {
|
||||
if ttyTg == nil || tg.Session() != ttyTg.Session() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1667,8 +1667,15 @@ func (l *Loader) signalForegrondProcessGroup(cid string, tgid kernel.ThreadID, s
|
||||
if tty == nil {
|
||||
return fmt.Errorf("no TTY attached")
|
||||
}
|
||||
pg, _ := tty.ThreadGroup().ForegroundProcessGroup(tty.TTY())
|
||||
si := &linux.SignalInfo{Signo: signo}
|
||||
ttyTg := tty.ThreadGroup()
|
||||
if ttyTg == nil {
|
||||
// No thread group has been set. Signal the original thread
|
||||
// group.
|
||||
log.Warningf("No thread group for container %q and PID %d. Sending signal directly to PID %d.", cid, tgid, tgid)
|
||||
return l.k.SendExternalSignalThreadGroup(tg, si)
|
||||
}
|
||||
pg, _ := ttyTg.ForegroundProcessGroup(tty.TTY())
|
||||
if pg == nil {
|
||||
// No foreground process group has been set. Signal the
|
||||
// original thread group.
|
||||
|
||||
Reference in New Issue
Block a user