This source file includes following definitions.
- fsverity_ioctl_measure
1
2
3
4
5
6
7
8 #include "fsverity_private.h"
9
10 #include <linux/uaccess.h>
11
12
13
14
15
16
17
18
19
20
21 int fsverity_ioctl_measure(struct file *filp, void __user *_uarg)
22 {
23 const struct inode *inode = file_inode(filp);
24 struct fsverity_digest __user *uarg = _uarg;
25 const struct fsverity_info *vi;
26 const struct fsverity_hash_alg *hash_alg;
27 struct fsverity_digest arg;
28
29 vi = fsverity_get_info(inode);
30 if (!vi)
31 return -ENODATA;
32 hash_alg = vi->tree_params.hash_alg;
33
34
35
36
37
38
39
40 if (get_user(arg.digest_size, &uarg->digest_size))
41 return -EFAULT;
42 if (arg.digest_size < hash_alg->digest_size)
43 return -EOVERFLOW;
44
45 memset(&arg, 0, sizeof(arg));
46 arg.digest_algorithm = hash_alg - fsverity_hash_algs;
47 arg.digest_size = hash_alg->digest_size;
48
49 if (copy_to_user(uarg, &arg, sizeof(arg)))
50 return -EFAULT;
51
52 if (copy_to_user(uarg->digest, vi->measurement, hash_alg->digest_size))
53 return -EFAULT;
54
55 return 0;
56 }
57 EXPORT_SYMBOL_GPL(fsverity_ioctl_measure);