// SPDX-License-Identifier: GPL-2.0 /* * Ioctl to enable verity on a file * * Copyright 2019 Google LLC */ #include "fsverity_private.h" #include <crypto/hash.h> #include <linux/mount.h> #include <linux/sched/signal.h> #include <linux/uaccess.h> struct block_buffer { … }; /* Hash a block, writing the result to the next level's pending block buffer. */ static int hash_one_block(struct inode *inode, const struct merkle_tree_params *params, struct block_buffer *cur) { … } static int write_merkle_tree_block(struct inode *inode, const u8 *buf, unsigned long index, const struct merkle_tree_params *params) { … } /* * Build the Merkle tree for the given file using the given parameters, and * return the root hash in @root_hash. * * The tree is written to a filesystem-specific location as determined by the * ->write_merkle_tree_block() method. However, the blocks that comprise the * tree are the same for all filesystems. */ static int build_merkle_tree(struct file *filp, const struct merkle_tree_params *params, u8 *root_hash) { … } static int enable_verity(struct file *filp, const struct fsverity_enable_arg *arg) { … } /** * fsverity_ioctl_enable() - enable verity on a file * @filp: file to enable verity on * @uarg: user pointer to fsverity_enable_arg * * Enable fs-verity on a file. See the "FS_IOC_ENABLE_VERITY" section of * Documentation/filesystems/fsverity.rst for the documentation. * * Return: 0 on success, -errno on failure */ int fsverity_ioctl_enable(struct file *filp, const void __user *uarg) { … } EXPORT_SYMBOL_GPL(…);