splice: compare inode numbers only if both ends are pipes

It isn't allowed to splice data from and into the same pipe.

But right now this check is broken, because we don't check that both ends are
pipes.

PiperOrigin-RevId: 272107022
This commit is contained in:
Andrei Vagin
2019-09-30 17:57:14 -07:00
committed by gVisor bot
parent 20841b98e1
commit 29a1ba54ea
+5 -5
View File
@@ -245,12 +245,12 @@ func Splice(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal
if inOffset != 0 || outOffset != 0 {
return 0, nil, syserror.ESPIPE
}
default:
return 0, nil, syserror.EINVAL
}
// We may not refer to the same pipe; otherwise it's a continuous loop.
if inFile.Dirent.Inode.StableAttr.InodeID == outFile.Dirent.Inode.StableAttr.InodeID {
// We may not refer to the same pipe; otherwise it's a continuous loop.
if inFile.Dirent.Inode.StableAttr.InodeID == outFile.Dirent.Inode.StableAttr.InodeID {
return 0, nil, syserror.EINVAL
}
default:
return 0, nil, syserror.EINVAL
}