[PATCH v3 4/5] btrfs: fallback to buffered io for verity files

Boris Burkov
2021-04-08T18:34:05Z

Reading the contents with direct IO would circumvent verity checks, so
fallback to buffered reads. For what it's worth, this is how ext4
handles it as well.

Signed-off-by: Boris Burkov <boris@bur.io>
---
fs/btrfs/file.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e8dcada0d239..9f8d90bbbe26 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -3613,6 +3613,9 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
struct inode *inode = file_inode(iocb->ki_filp);
ssize_t ret;

+ if (fsverity_active(inode))
+ return 0;
+
if (check_direct_read(btrfs_sb(inode->i_sb), to, iocb->ki_pos))
return 0;

--
2.30.2