aboutsummaryrefslogtreecommitdiff
path: root/include/linux/fsverity.h
blob: 7a34b4c4b93f36e3cb1175026ec6e7751e3f4353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// SPDX-License-Identifier: GPL-2.0
/*
 * fs-verity: read-only file-based integrity/authenticity
 *
 * Copyright (C) 2018, Google, Inc.
 *
 * Written by Jaegeuk Kim, Michael Halcrow, and Eric Biggers.
 */

#ifndef _LINUX_FSVERITY_H
#define _LINUX_FSVERITY_H

#include <linux/fs.h>

/*
 * fs-verity operations for filesystems
 */
struct fsverity_operations {
	bool (*is_verity)(struct inode *inode);
	int (*set_verity)(struct inode *inode);
	struct page *(*read_metadata_page)(struct inode *inode, pgoff_t index);
};

#if __FS_HAS_VERITY
extern int fsverity_file_open(struct inode *inode, struct file *filp);
extern int fsverity_prepare_setattr(struct dentry *dentry, struct iattr *attr);
extern int fsverity_prepare_getattr(struct inode *inode);
extern void fsverity_cleanup_inode(struct inode *inode);
extern bool fsverity_verify_page(struct page *page);
extern void fsverity_verify_bio(struct bio *bio);
extern void fsverity_enqueue_verify_work(struct work_struct *work);
extern loff_t fsverity_full_isize(struct inode *inode);
extern int fsverity_ioctl_set_measurement(struct file *filp,
					  const void __user *arg);
extern int fsverity_ioctl_enable(struct file *filp, const void __user *arg);
#else
static inline int fsverity_file_open(struct inode *inode, struct file *filp)
{
	return -EOPNOTSUPP;
}

static inline int fsverity_prepare_setattr(struct dentry *dentry,
					   struct iattr *attr)
{
	return -EOPNOTSUPP;
}

static inline int fsverity_prepare_getattr(struct inode *inode)
{
	return -EOPNOTSUPP;
}

static inline void fsverity_cleanup_inode(struct inode *inode)
{
}

static inline bool fsverity_verify_page(struct page *page)
{
	WARN_ON(1);
	return false;
}

static inline void fsverity_verify_bio(struct bio *bio)
{
	WARN_ON(1);
}

static inline void fsverity_enqueue_verify_work(struct work_struct *work)
{
	WARN_ON(1);
}

static inline loff_t fsverity_full_isize(struct inode *inode)
{
	return i_size_read(inode);
}

static inline int fsverity_ioctl_set_measurement(struct file *filp,
						 const void __user *arg)
{
	return -EOPNOTSUPP;
}

static inline int fsverity_ioctl_enable(struct file *filp,
					const void __user *arg)
{
	return -EOPNOTSUPP;
}

#endif	/* !__FS_HAS_VERITY */

#endif	/* _LINUX_FSVERITY_H */