From 4fdd69d681bb3abb68a043377a2fb0ec8a031d54 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Mon, 4 Nov 2019 10:56:13 -0800 Subject: Check that a file is a regular file with open(O_TRUNC). It was possible to panic the sentry by opening a cache revalidating folder with O_TRUNC|O_CREAT. PiperOrigin-RevId: 278417533 --- pkg/sentry/fs/inode_operations.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkg/sentry/fs') diff --git a/pkg/sentry/fs/inode_operations.go b/pkg/sentry/fs/inode_operations.go index 5cde9d215..d6c35c2dc 100644 --- a/pkg/sentry/fs/inode_operations.go +++ b/pkg/sentry/fs/inode_operations.go @@ -221,6 +221,8 @@ type InodeOperations interface { // sys_ftruncate. // // Implementations need not check that length >= 0. + // + // Truncate must only be called on regular files. Truncate(ctx context.Context, inode *Inode, size int64) error // Allocate allows the caller to reserve disk space for the inode. -- cgit v1.2.3