tmpfs: make sure that a dentry will not be destroyed before the open() call

If we don't hold a reference, the dentry can be destroyed by another thread.

Reported-by: syzbot+f2132e50060c41f6d41f@syzkaller.appspotmail.com
PiperOrigin-RevId: 342951940
This commit is contained in:
Andrei Vagin
2020-11-17 14:56:21 -08:00
committed by gVisor bot
parent e2d9a68eef
commit 10ba578c01
+2
View File
@@ -381,6 +381,8 @@ afterTrailingSymlink:
creds := rp.Credentials()
child := fs.newDentry(fs.newRegularFile(creds.EffectiveKUID, creds.EffectiveKGID, opts.Mode))
parentDir.insertChildLocked(child, name)
child.IncRef()
defer child.DecRef(ctx)
unlock()
fd, err := child.open(ctx, rp, &opts, true)
if err != nil {