vfs: Don't allow to splice in all file descriptors

We want to avoid unneeded side effects, so let's specify what file descriptors
allow to splice data in. Linux does the same thing.

For example, Splicing a big amout of data to eventfd can be slow, because
eventfd can consume only 8 bytes at once.

Reported-by: syzbot+b9610cff22c10d9bead4@syzkaller.appspotmail.com
This commit is contained in:
Andrei Vagin
2021-12-08 12:17:16 -08:00
committed by Andrei Vagin
parent ba86510559
commit eeeaa63923
35 changed files with 73 additions and 0 deletions
+1
View File
@@ -47,6 +47,7 @@ type fullFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
}
// Release implements vfs.FileDescriptionImpl.Release.
+1
View File
@@ -48,6 +48,7 @@ type nullFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
}
// Release implements vfs.FileDescriptionImpl.Release.
+1
View File
@@ -53,6 +53,7 @@ type randomFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
// off is the "file offset". off is accessed using atomic memory
// operations.
+1
View File
@@ -50,6 +50,7 @@ type zeroFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
}
// Release implements vfs.FileDescriptionImpl.Release.
+1
View File
@@ -60,6 +60,7 @@ type tunFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
device tun.Device
}
+1
View File
@@ -90,6 +90,7 @@ type masterFileDescription struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.NoSpliceInFD
inode *masterInode
t *Terminal
+1
View File
@@ -102,6 +102,7 @@ type replicaFileDescription struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.NoSpliceInFD
inode *replicaInode
}
+1
View File
@@ -42,6 +42,7 @@ type EventFileDescription struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.NoSpliceInFD
// queue is used to notify interested parties when the event object
// becomes readable or writable.
+1
View File
@@ -57,6 +57,7 @@ type DeviceFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.SpliceInFD
// nextOpID is used to create new requests.
nextOpID linux.FUSEOpID
+1
View File
@@ -28,6 +28,7 @@ import (
type directoryFD struct {
fileDescription
vfs.NoSpliceInFD
}
// Allocate implements directoryFD.Allocate.
+1
View File
@@ -29,6 +29,7 @@ import (
type regularFileFD struct {
fileDescription
vfs.SpliceInFD
// off is the file offset.
off int64
+1
View File
@@ -2443,6 +2443,7 @@ type fileDescription struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.SpliceInFD
lockLogging sync.Once `state:"nosave"`
}
+1
View File
@@ -45,6 +45,7 @@ func (d *dentry) isRegularFile() bool {
// +stateify savable
type regularFileFD struct {
fileDescription
vfs.SpliceInFD
// off is the file offset. off is protected by mu.
mu sync.Mutex `state:"nosave"`
+1
View File
@@ -649,6 +649,7 @@ type fileDescription struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.SpliceInFD
// inode is vfsfd.Dentry().Impl().(*kernfs.Dentry).Inode().(*inode), but
// cached to reduce indirections and casting. fileDescription does not hold
@@ -89,6 +89,7 @@ type DynamicBytesFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DynamicBytesFileDescriptionImpl
vfs.LockFD
vfs.NoSpliceInFD
vfsfd vfs.FileDescription
inode Inode
+1
View File
@@ -61,6 +61,7 @@ type queueFD struct {
vfs.FileDescriptionDefaultImpl
vfs.DynamicBytesFileDescriptionImpl
vfs.LockFD
vfs.NoSpliceInFD
vfsfd vfs.FileDescription
inode kernfs.Inode
@@ -50,6 +50,7 @@ func (d *dentry) readlink(ctx context.Context) (string, error) {
// +stateify savable
type regularFileFD struct {
fileDescription
vfs.SpliceInFD
// If copiedUp is false, cachedFD represents
// fileDescription.dentry().lowerVDs[0]; otherwise, cachedFD represents
+3
View File
@@ -434,6 +434,7 @@ type memFD struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.SpliceInFD
inode *memInode
@@ -678,6 +679,7 @@ type statusFD struct {
statusFDLowerBase
vfs.DynamicBytesFileDescriptionImpl
vfs.LockFD
vfs.NoSpliceInFD
vfsfd vfs.FileDescription
@@ -1173,6 +1175,7 @@ func (i *namespaceInode) Open(ctx context.Context, rp *vfs.ResolvingPath, d *ker
type namespaceFD struct {
vfs.FileDescriptionDefaultImpl
vfs.LockFD
vfs.NoSpliceInFD
vfsfd vfs.FileDescription
inode *namespaceInode
+1
View File
@@ -34,6 +34,7 @@ type SignalFileDescription struct {
vfs.FileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
vfs.NoLockFD
vfs.NoSpliceInFD
// target is the original signal target task.
//
+1
View File
@@ -67,6 +67,7 @@ func (i *kcovInode) Open(ctx context.Context, rp *vfs.ResolvingPath, d *kernfs.D
type kcovFD struct {
vfs.FileDescriptionDefaultImpl
vfs.NoLockFD
vfs.SpliceInFD
vfsfd vfs.FileDescription
inode *kcovInode

Some files were not shown because too many files have changed in this diff Show More