kernel: GetMountNamespace has to check that mntns isn't nil

Reported-by: syzbot+e21bed832e505430bb27@syzkaller.appspotmail.com
PiperOrigin-RevId: 553568085
This commit is contained in:
Andrei Vagin
2023-08-03 13:14:04 -07:00
committed by gVisor bot
parent b4aeb6cd0c
commit 6f978d7185
2 changed files with 7 additions and 5 deletions
+5 -2
View File
@@ -795,8 +795,11 @@ func (t *Task) MountNamespace() *vfs.MountNamespace {
func (t *Task) GetMountNamespace() *vfs.MountNamespace {
t.mu.Lock()
defer t.mu.Unlock()
t.mountNamespace.IncRef()
return t.mountNamespace
mntns := t.mountNamespace
if mntns != nil {
mntns.IncRef()
}
return mntns
}
// AbstractSockets returns t's AbstractSocketNamespace.
+2 -3
View File
@@ -288,12 +288,11 @@ func (*runExitMain) execute(t *Task) taskRunState {
mntns := t.mountNamespace
t.mountNamespace = nil
ipcns := t.ipcns
t.ipcns = nil
netns := t.netns
t.netns = nil
t.mu.Unlock()
if mntns != nil {
mntns.DecRef(t)
}
mntns.DecRef(t)
ipcns.DecRef(t)
netns.DecRef(t)