mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 12:00:22 +09:00
ANDROID: fuse-bpf: Use fuse_bpf_args in uapi
fuse_args is not suitable for use in the uapi - it is not stable, and contains internal pointers. Replace with stable equivalent. The end_offset values are currently unused and unset, but will be used in a follow up patch by the verifier. Test: fuse_test, atest ScopedStorageDeviceTest pass Bug: 202785178 Signed-off-by: Daniel Rosenberg <drosen@google.com> Change-Id: Ic1c12f9706aeae233cc30a0d68ed2533030e485b
This commit is contained in:
File diff suppressed because it is too large
Load Diff
248
fs/fuse/fuse_i.h
248
fs/fuse/fuse_i.h
@@ -308,12 +308,48 @@ struct fuse_file {
|
||||
bool flock:1;
|
||||
};
|
||||
|
||||
/** One input argument of a request */
|
||||
struct fuse_in_arg {
|
||||
unsigned size;
|
||||
const void *value;
|
||||
};
|
||||
|
||||
/** One output argument of a request */
|
||||
struct fuse_arg {
|
||||
unsigned size;
|
||||
void *value;
|
||||
};
|
||||
|
||||
/** FUSE page descriptor */
|
||||
struct fuse_page_desc {
|
||||
unsigned int length;
|
||||
unsigned int offset;
|
||||
};
|
||||
|
||||
struct fuse_args {
|
||||
uint64_t nodeid;
|
||||
uint32_t opcode;
|
||||
uint32_t error_in;
|
||||
unsigned short in_numargs;
|
||||
unsigned short out_numargs;
|
||||
int force:1;
|
||||
int noreply:1;
|
||||
int nocreds:1;
|
||||
int in_pages:1;
|
||||
int out_pages:1;
|
||||
int user_pages:1;
|
||||
int out_argvar:1;
|
||||
int page_zeroing:1;
|
||||
int page_replace:1;
|
||||
int may_block:1;
|
||||
struct fuse_in_arg in_args[FUSE_MAX_IN_ARGS];
|
||||
struct fuse_arg out_args[FUSE_MAX_OUT_ARGS];
|
||||
void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error);
|
||||
|
||||
/* Path used for completing d_canonical_path */
|
||||
struct path *canonical_path;
|
||||
};
|
||||
|
||||
struct fuse_args_pages {
|
||||
struct fuse_args args;
|
||||
struct page **pages;
|
||||
@@ -1316,11 +1352,11 @@ struct fuse_open_io {
|
||||
struct fuse_open_out foo;
|
||||
};
|
||||
|
||||
int fuse_open_initialize(struct fuse_args *fa, struct fuse_open_io *foi,
|
||||
int fuse_open_initialize(struct fuse_bpf_args *fa, struct fuse_open_io *foi,
|
||||
struct inode *inode, struct file *file, bool isdir);
|
||||
int fuse_open_backing(struct fuse_args *fa,
|
||||
int fuse_open_backing(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct file *file, bool isdir);
|
||||
void *fuse_open_finalize(struct fuse_args *fa,
|
||||
void *fuse_open_finalize(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct file *file, bool isdir);
|
||||
|
||||
struct fuse_create_open_io {
|
||||
@@ -1330,103 +1366,103 @@ struct fuse_create_open_io {
|
||||
};
|
||||
|
||||
int fuse_create_open_initialize(
|
||||
struct fuse_args *fa, struct fuse_create_open_io *fcoi,
|
||||
struct fuse_bpf_args *fa, struct fuse_create_open_io *fcoi,
|
||||
struct inode *dir, struct dentry *entry,
|
||||
struct file *file, unsigned int flags, umode_t mode);
|
||||
int fuse_create_open_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry,
|
||||
struct file *file, unsigned int flags, umode_t mode);
|
||||
void *fuse_create_open_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry,
|
||||
struct file *file, unsigned int flags, umode_t mode);
|
||||
|
||||
int fuse_mknod_initialize(
|
||||
struct fuse_args *fa, struct fuse_mknod_in *fmi,
|
||||
struct fuse_bpf_args *fa, struct fuse_mknod_in *fmi,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode, dev_t rdev);
|
||||
int fuse_mknod_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode, dev_t rdev);
|
||||
void *fuse_mknod_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode, dev_t rdev);
|
||||
|
||||
int fuse_mkdir_initialize(
|
||||
struct fuse_args *fa, struct fuse_mkdir_in *fmi,
|
||||
struct fuse_bpf_args *fa, struct fuse_mkdir_in *fmi,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode);
|
||||
int fuse_mkdir_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode);
|
||||
void *fuse_mkdir_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, umode_t mode);
|
||||
|
||||
int fuse_rmdir_initialize(
|
||||
struct fuse_args *fa, struct fuse_dummy_io *fmi,
|
||||
struct fuse_bpf_args *fa, struct fuse_dummy_io *fmi,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
int fuse_rmdir_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
void *fuse_rmdir_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
|
||||
int fuse_rename2_initialize(struct fuse_args *fa, struct fuse_rename2_in *fri,
|
||||
int fuse_rename2_initialize(struct fuse_bpf_args *fa, struct fuse_rename2_in *fri,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent,
|
||||
unsigned int flags);
|
||||
int fuse_rename2_backing(struct fuse_args *fa,
|
||||
int fuse_rename2_backing(struct fuse_bpf_args *fa,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent,
|
||||
unsigned int flags);
|
||||
void *fuse_rename2_finalize(struct fuse_args *fa,
|
||||
void *fuse_rename2_finalize(struct fuse_bpf_args *fa,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent,
|
||||
unsigned int flags);
|
||||
|
||||
int fuse_rename_initialize(struct fuse_args *fa, struct fuse_rename_in *fri,
|
||||
int fuse_rename_initialize(struct fuse_bpf_args *fa, struct fuse_rename_in *fri,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent);
|
||||
int fuse_rename_backing(struct fuse_args *fa,
|
||||
int fuse_rename_backing(struct fuse_bpf_args *fa,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent);
|
||||
void *fuse_rename_finalize(struct fuse_args *fa,
|
||||
void *fuse_rename_finalize(struct fuse_bpf_args *fa,
|
||||
struct inode *olddir, struct dentry *oldent,
|
||||
struct inode *newdir, struct dentry *newent);
|
||||
|
||||
int fuse_unlink_initialize(
|
||||
struct fuse_args *fa, struct fuse_dummy_io *fmi,
|
||||
struct fuse_bpf_args *fa, struct fuse_dummy_io *fmi,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
int fuse_unlink_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
void *fuse_unlink_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry);
|
||||
|
||||
int fuse_link_initialize(struct fuse_args *fa, struct fuse_link_in *fli,
|
||||
int fuse_link_initialize(struct fuse_bpf_args *fa, struct fuse_link_in *fli,
|
||||
struct dentry *entry, struct inode *dir,
|
||||
struct dentry *newent);
|
||||
int fuse_link_backing(struct fuse_args *fa, struct dentry *entry,
|
||||
int fuse_link_backing(struct fuse_bpf_args *fa, struct dentry *entry,
|
||||
struct inode *dir, struct dentry *newent);
|
||||
void *fuse_link_finalize(struct fuse_args *fa, struct dentry *entry,
|
||||
void *fuse_link_finalize(struct fuse_bpf_args *fa, struct dentry *entry,
|
||||
struct inode *dir, struct dentry *newent);
|
||||
|
||||
int fuse_release_initialize(struct fuse_args *fa, struct fuse_release_in *fri,
|
||||
int fuse_release_initialize(struct fuse_bpf_args *fa, struct fuse_release_in *fri,
|
||||
struct inode *inode, struct file *file);
|
||||
int fuse_releasedir_initialize(struct fuse_args *fa,
|
||||
int fuse_releasedir_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_release_in *fri,
|
||||
struct inode *inode, struct file *file);
|
||||
int fuse_release_backing(struct fuse_args *fa,
|
||||
int fuse_release_backing(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct file *file);
|
||||
void *fuse_release_finalize(struct fuse_args *fa,
|
||||
void *fuse_release_finalize(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct file *file);
|
||||
|
||||
int fuse_flush_initialize(struct fuse_args *fa, struct fuse_flush_in *ffi,
|
||||
int fuse_flush_initialize(struct fuse_bpf_args *fa, struct fuse_flush_in *ffi,
|
||||
struct file *file, fl_owner_t id);
|
||||
int fuse_flush_backing(struct fuse_args *fa, struct file *file, fl_owner_t id);
|
||||
void *fuse_flush_finalize(struct fuse_args *fa,
|
||||
int fuse_flush_backing(struct fuse_bpf_args *fa, struct file *file, fl_owner_t id);
|
||||
void *fuse_flush_finalize(struct fuse_bpf_args *fa,
|
||||
struct file *file, fl_owner_t id);
|
||||
|
||||
struct fuse_lseek_io {
|
||||
@@ -1434,37 +1470,37 @@ struct fuse_lseek_io {
|
||||
struct fuse_lseek_out flo;
|
||||
};
|
||||
|
||||
int fuse_lseek_initialize(struct fuse_args *fa, struct fuse_lseek_io *fli,
|
||||
int fuse_lseek_initialize(struct fuse_bpf_args *fa, struct fuse_lseek_io *fli,
|
||||
struct file *file, loff_t offset, int whence);
|
||||
int fuse_lseek_backing(struct fuse_args *fa, struct file *file, loff_t offset, int whence);
|
||||
void *fuse_lseek_finalize(struct fuse_args *fa, struct file *file, loff_t offset, int whence);
|
||||
int fuse_lseek_backing(struct fuse_bpf_args *fa, struct file *file, loff_t offset, int whence);
|
||||
void *fuse_lseek_finalize(struct fuse_bpf_args *fa, struct file *file, loff_t offset, int whence);
|
||||
|
||||
struct fuse_copy_file_range_io {
|
||||
struct fuse_copy_file_range_in fci;
|
||||
struct fuse_write_out fwo;
|
||||
};
|
||||
|
||||
int fuse_copy_file_range_initialize(struct fuse_args *fa,
|
||||
int fuse_copy_file_range_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_copy_file_range_io *fcf,
|
||||
struct file *file_in, loff_t pos_in,
|
||||
struct file *file_out, loff_t pos_out,
|
||||
size_t len, unsigned int flags);
|
||||
int fuse_copy_file_range_backing(struct fuse_args *fa,
|
||||
int fuse_copy_file_range_backing(struct fuse_bpf_args *fa,
|
||||
struct file *file_in, loff_t pos_in,
|
||||
struct file *file_out, loff_t pos_out,
|
||||
size_t len, unsigned int flags);
|
||||
void *fuse_copy_file_range_finalize(struct fuse_args *fa,
|
||||
void *fuse_copy_file_range_finalize(struct fuse_bpf_args *fa,
|
||||
struct file *file_in, loff_t pos_in,
|
||||
struct file *file_out, loff_t pos_out,
|
||||
size_t len, unsigned int flags);
|
||||
|
||||
int fuse_fsync_initialize(struct fuse_args *fa, struct fuse_fsync_in *ffi,
|
||||
int fuse_fsync_initialize(struct fuse_bpf_args *fa, struct fuse_fsync_in *ffi,
|
||||
struct file *file, loff_t start, loff_t end, int datasync);
|
||||
int fuse_fsync_backing(struct fuse_args *fa,
|
||||
int fuse_fsync_backing(struct fuse_bpf_args *fa,
|
||||
struct file *file, loff_t start, loff_t end, int datasync);
|
||||
void *fuse_fsync_finalize(struct fuse_args *fa,
|
||||
void *fuse_fsync_finalize(struct fuse_bpf_args *fa,
|
||||
struct file *file, loff_t start, loff_t end, int datasync);
|
||||
int fuse_dir_fsync_initialize(struct fuse_args *fa, struct fuse_fsync_in *ffi,
|
||||
int fuse_dir_fsync_initialize(struct fuse_bpf_args *fa, struct fuse_fsync_in *ffi,
|
||||
struct file *file, loff_t start, loff_t end, int datasync);
|
||||
|
||||
struct fuse_getxattr_io {
|
||||
@@ -1473,43 +1509,43 @@ struct fuse_getxattr_io {
|
||||
};
|
||||
|
||||
int fuse_getxattr_initialize(
|
||||
struct fuse_args *fa, struct fuse_getxattr_io *fgio,
|
||||
struct fuse_bpf_args *fa, struct fuse_getxattr_io *fgio,
|
||||
struct dentry *dentry, const char *name, void *value,
|
||||
size_t size);
|
||||
int fuse_getxattr_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, const char *name, void *value,
|
||||
size_t size);
|
||||
void *fuse_getxattr_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, const char *name, void *value,
|
||||
size_t size);
|
||||
|
||||
int fuse_listxattr_initialize(struct fuse_args *fa,
|
||||
int fuse_listxattr_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_getxattr_io *fgio,
|
||||
struct dentry *dentry, char *list, size_t size);
|
||||
int fuse_listxattr_backing(struct fuse_args *fa, struct dentry *dentry,
|
||||
int fuse_listxattr_backing(struct fuse_bpf_args *fa, struct dentry *dentry,
|
||||
char *list, size_t size);
|
||||
void *fuse_listxattr_finalize(struct fuse_args *fa, struct dentry *dentry,
|
||||
void *fuse_listxattr_finalize(struct fuse_bpf_args *fa, struct dentry *dentry,
|
||||
char *list, size_t size);
|
||||
|
||||
int fuse_setxattr_initialize(struct fuse_args *fa,
|
||||
int fuse_setxattr_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_setxattr_in *fsxi,
|
||||
struct dentry *dentry, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
int fuse_setxattr_backing(struct fuse_args *fa, struct dentry *dentry,
|
||||
int fuse_setxattr_backing(struct fuse_bpf_args *fa, struct dentry *dentry,
|
||||
const char *name, const void *value, size_t size,
|
||||
int flags);
|
||||
void *fuse_setxattr_finalize(struct fuse_args *fa, struct dentry *dentry,
|
||||
void *fuse_setxattr_finalize(struct fuse_bpf_args *fa, struct dentry *dentry,
|
||||
const char *name, const void *value, size_t size,
|
||||
int flags);
|
||||
|
||||
int fuse_removexattr_initialize(struct fuse_args *fa,
|
||||
int fuse_removexattr_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_dummy_io *unused,
|
||||
struct dentry *dentry, const char *name);
|
||||
int fuse_removexattr_backing(struct fuse_args *fa,
|
||||
int fuse_removexattr_backing(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, const char *name);
|
||||
void *fuse_removexattr_finalize(struct fuse_args *fa,
|
||||
void *fuse_removexattr_finalize(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, const char *name);
|
||||
|
||||
struct fuse_read_iter_out {
|
||||
@@ -1521,11 +1557,11 @@ struct fuse_file_read_iter_io {
|
||||
};
|
||||
|
||||
int fuse_file_read_iter_initialize(
|
||||
struct fuse_args *fa, struct fuse_file_read_iter_io *fri,
|
||||
struct fuse_bpf_args *fa, struct fuse_file_read_iter_io *fri,
|
||||
struct kiocb *iocb, struct iov_iter *to);
|
||||
int fuse_file_read_iter_backing(struct fuse_args *fa,
|
||||
int fuse_file_read_iter_backing(struct fuse_bpf_args *fa,
|
||||
struct kiocb *iocb, struct iov_iter *to);
|
||||
void *fuse_file_read_iter_finalize(struct fuse_args *fa,
|
||||
void *fuse_file_read_iter_finalize(struct fuse_bpf_args *fa,
|
||||
struct kiocb *iocb, struct iov_iter *to);
|
||||
|
||||
struct fuse_write_iter_out {
|
||||
@@ -1538,21 +1574,21 @@ struct fuse_file_write_iter_io {
|
||||
};
|
||||
|
||||
int fuse_file_write_iter_initialize(
|
||||
struct fuse_args *fa, struct fuse_file_write_iter_io *fwio,
|
||||
struct fuse_bpf_args *fa, struct fuse_file_write_iter_io *fwio,
|
||||
struct kiocb *iocb, struct iov_iter *from);
|
||||
int fuse_file_write_iter_backing(struct fuse_args *fa,
|
||||
int fuse_file_write_iter_backing(struct fuse_bpf_args *fa,
|
||||
struct kiocb *iocb, struct iov_iter *from);
|
||||
void *fuse_file_write_iter_finalize(struct fuse_args *fa,
|
||||
void *fuse_file_write_iter_finalize(struct fuse_bpf_args *fa,
|
||||
struct kiocb *iocb, struct iov_iter *from);
|
||||
|
||||
ssize_t fuse_backing_mmap(struct file *file, struct vm_area_struct *vma);
|
||||
|
||||
int fuse_file_fallocate_initialize(struct fuse_args *fa,
|
||||
int fuse_file_fallocate_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_fallocate_in *ffi,
|
||||
struct file *file, int mode, loff_t offset, loff_t length);
|
||||
int fuse_file_fallocate_backing(struct fuse_args *fa,
|
||||
int fuse_file_fallocate_backing(struct fuse_bpf_args *fa,
|
||||
struct file *file, int mode, loff_t offset, loff_t length);
|
||||
void *fuse_file_fallocate_finalize(struct fuse_args *fa,
|
||||
void *fuse_file_fallocate_finalize(struct fuse_bpf_args *fa,
|
||||
struct file *file, int mode, loff_t offset, loff_t length);
|
||||
|
||||
struct fuse_lookup_io {
|
||||
@@ -1560,24 +1596,24 @@ struct fuse_lookup_io {
|
||||
struct fuse_entry_bpf feb;
|
||||
};
|
||||
|
||||
int fuse_lookup_initialize(struct fuse_args *fa, struct fuse_lookup_io *feo,
|
||||
int fuse_lookup_initialize(struct fuse_bpf_args *fa, struct fuse_lookup_io *feo,
|
||||
struct inode *dir, struct dentry *entry, unsigned int flags);
|
||||
int fuse_lookup_backing(struct fuse_args *fa, struct inode *dir,
|
||||
int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir,
|
||||
struct dentry *entry, unsigned int flags);
|
||||
struct dentry *fuse_lookup_finalize(struct fuse_args *fa, struct inode *dir,
|
||||
struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir,
|
||||
struct dentry *entry, unsigned int flags);
|
||||
int fuse_revalidate_backing(struct fuse_args *fa, struct inode *dir,
|
||||
int fuse_revalidate_backing(struct fuse_bpf_args *fa, struct inode *dir,
|
||||
struct dentry *entry, unsigned int flags);
|
||||
void *fuse_revalidate_finalize(struct fuse_args *fa, struct inode *dir,
|
||||
void *fuse_revalidate_finalize(struct fuse_bpf_args *fa, struct inode *dir,
|
||||
struct dentry *entry, unsigned int flags);
|
||||
|
||||
int fuse_canonical_path_initialize(struct fuse_args *fa,
|
||||
int fuse_canonical_path_initialize(struct fuse_bpf_args *fa,
|
||||
struct fuse_dummy_io *fdi,
|
||||
const struct path *path,
|
||||
struct path *canonical_path);
|
||||
int fuse_canonical_path_backing(struct fuse_args *fa, const struct path *path,
|
||||
int fuse_canonical_path_backing(struct fuse_bpf_args *fa, const struct path *path,
|
||||
struct path *canonical_path);
|
||||
void *fuse_canonical_path_finalize(struct fuse_args *fa,
|
||||
void *fuse_canonical_path_finalize(struct fuse_bpf_args *fa,
|
||||
const struct path *path,
|
||||
struct path *canonical_path);
|
||||
|
||||
@@ -1585,13 +1621,13 @@ struct fuse_getattr_io {
|
||||
struct fuse_getattr_in fgi;
|
||||
struct fuse_attr_out fao;
|
||||
};
|
||||
int fuse_getattr_initialize(struct fuse_args *fa, struct fuse_getattr_io *fgio,
|
||||
int fuse_getattr_initialize(struct fuse_bpf_args *fa, struct fuse_getattr_io *fgio,
|
||||
const struct dentry *entry, struct kstat *stat,
|
||||
u32 request_mask, unsigned int flags);
|
||||
int fuse_getattr_backing(struct fuse_args *fa,
|
||||
int fuse_getattr_backing(struct fuse_bpf_args *fa,
|
||||
const struct dentry *entry, struct kstat *stat,
|
||||
u32 request_mask, unsigned int flags);
|
||||
void *fuse_getattr_finalize(struct fuse_args *fa,
|
||||
void *fuse_getattr_finalize(struct fuse_bpf_args *fa,
|
||||
const struct dentry *entry, struct kstat *stat,
|
||||
u32 request_mask, unsigned int flags);
|
||||
|
||||
@@ -1600,38 +1636,38 @@ struct fuse_setattr_io {
|
||||
struct fuse_attr_out fao;
|
||||
};
|
||||
|
||||
int fuse_setattr_initialize(struct fuse_args *fa, struct fuse_setattr_io *fsi,
|
||||
int fuse_setattr_initialize(struct fuse_bpf_args *fa, struct fuse_setattr_io *fsi,
|
||||
struct dentry *dentry, struct iattr *attr, struct file *file);
|
||||
int fuse_setattr_backing(struct fuse_args *fa,
|
||||
int fuse_setattr_backing(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, struct iattr *attr, struct file *file);
|
||||
void *fuse_setattr_finalize(struct fuse_args *fa,
|
||||
void *fuse_setattr_finalize(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, struct iattr *attr, struct file *file);
|
||||
|
||||
int fuse_statfs_initialize(struct fuse_args *fa, struct fuse_statfs_out *fso,
|
||||
int fuse_statfs_initialize(struct fuse_bpf_args *fa, struct fuse_statfs_out *fso,
|
||||
struct dentry *dentry, struct kstatfs *buf);
|
||||
int fuse_statfs_backing(struct fuse_args *fa,
|
||||
int fuse_statfs_backing(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, struct kstatfs *buf);
|
||||
void *fuse_statfs_finalize(struct fuse_args *fa,
|
||||
void *fuse_statfs_finalize(struct fuse_bpf_args *fa,
|
||||
struct dentry *dentry, struct kstatfs *buf);
|
||||
|
||||
int fuse_get_link_initialize(struct fuse_args *fa, struct fuse_dummy_io *dummy,
|
||||
int fuse_get_link_initialize(struct fuse_bpf_args *fa, struct fuse_dummy_io *dummy,
|
||||
struct inode *inode, struct dentry *dentry,
|
||||
struct delayed_call *callback, const char **out);
|
||||
int fuse_get_link_backing(struct fuse_args *fa,
|
||||
int fuse_get_link_backing(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct dentry *dentry,
|
||||
struct delayed_call *callback, const char **out);
|
||||
void *fuse_get_link_finalize(struct fuse_args *fa,
|
||||
void *fuse_get_link_finalize(struct fuse_bpf_args *fa,
|
||||
struct inode *inode, struct dentry *dentry,
|
||||
struct delayed_call *callback, const char **out);
|
||||
|
||||
int fuse_symlink_initialize(
|
||||
struct fuse_args *fa, struct fuse_dummy_io *unused,
|
||||
struct fuse_bpf_args *fa, struct fuse_dummy_io *unused,
|
||||
struct inode *dir, struct dentry *entry, const char *link, int len);
|
||||
int fuse_symlink_backing(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, const char *link, int len);
|
||||
void *fuse_symlink_finalize(
|
||||
struct fuse_args *fa,
|
||||
struct fuse_bpf_args *fa,
|
||||
struct inode *dir, struct dentry *entry, const char *link, int len);
|
||||
|
||||
struct fuse_read_io {
|
||||
@@ -1639,20 +1675,20 @@ struct fuse_read_io {
|
||||
struct fuse_read_out fro;
|
||||
};
|
||||
|
||||
int fuse_readdir_initialize(struct fuse_args *fa, struct fuse_read_io *frio,
|
||||
int fuse_readdir_initialize(struct fuse_bpf_args *fa, struct fuse_read_io *frio,
|
||||
struct file *file, struct dir_context *ctx,
|
||||
bool *force_again, bool *allow_force, bool is_continued);
|
||||
int fuse_readdir_backing(struct fuse_args *fa,
|
||||
int fuse_readdir_backing(struct fuse_bpf_args *fa,
|
||||
struct file *file, struct dir_context *ctx,
|
||||
bool *force_again, bool *allow_force, bool is_continued);
|
||||
void *fuse_readdir_finalize(struct fuse_args *fa,
|
||||
void *fuse_readdir_finalize(struct fuse_bpf_args *fa,
|
||||
struct file *file, struct dir_context *ctx,
|
||||
bool *force_again, bool *allow_force, bool is_continued);
|
||||
|
||||
int fuse_access_initialize(struct fuse_args *fa, struct fuse_access_in *fai,
|
||||
int fuse_access_initialize(struct fuse_bpf_args *fa, struct fuse_access_in *fai,
|
||||
struct inode *inode, int mask);
|
||||
int fuse_access_backing(struct fuse_args *fa, struct inode *inode, int mask);
|
||||
void *fuse_access_finalize(struct fuse_args *fa, struct inode *inode, int mask);
|
||||
int fuse_access_backing(struct fuse_bpf_args *fa, struct inode *inode, int mask);
|
||||
void *fuse_access_finalize(struct fuse_bpf_args *fa, struct inode *inode, int mask);
|
||||
|
||||
/*
|
||||
* FUSE caches dentries and attributes with separate timeout. The
|
||||
@@ -1791,16 +1827,18 @@ struct fuse_err_ret {
|
||||
int __init fuse_bpf_init(void);
|
||||
void __exit fuse_bpf_cleanup(void);
|
||||
|
||||
ssize_t fuse_bpf_simple_request(struct fuse_mount *fm, struct fuse_bpf_args *args);
|
||||
|
||||
/*
|
||||
* expression statement to wrap the backing filter logic
|
||||
* struct inode *inode: inode with bpf and backing inode
|
||||
* typedef io: (typically complex) type whose components fuse_args can point to.
|
||||
* An instance of this type is created locally and passed to initialize
|
||||
* void initialize(struct fuse_args *fa, io *in_out, args...): function that sets
|
||||
* void initialize(struct fuse_bpf_args *fa, io *in_out, args...): function that sets
|
||||
* up fa and io based on args
|
||||
* int backing(struct fuse_args *fa, args...): function that actually performs
|
||||
* int backing(struct fuse_bpf_args *fa, args...): function that actually performs
|
||||
* the backing io operation
|
||||
* void *finalize(struct fuse_args *, args...): function that performs any final
|
||||
* void *finalize(struct fuse_bpf_args *, args...): function that performs any final
|
||||
* work needed to commit the backing io
|
||||
*/
|
||||
#define fuse_bpf_backing(inode, io, initialize, backing, finalize, \
|
||||
@@ -1811,7 +1849,7 @@ void __exit fuse_bpf_cleanup(void);
|
||||
struct fuse_inode *fuse_inode = get_fuse_inode(inode); \
|
||||
struct fuse_mount *fm = get_fuse_mount(inode); \
|
||||
io feo = {0}; \
|
||||
struct fuse_args fa = {0}, fa_backup = {0}; \
|
||||
struct fuse_bpf_args fa = {0}, fa_backup = {0}; \
|
||||
bool locked; \
|
||||
ssize_t res; \
|
||||
void *err; \
|
||||
@@ -1835,7 +1873,7 @@ void __exit fuse_bpf_cleanup(void);
|
||||
fa_backup = fa; \
|
||||
fa.opcode |= FUSE_PREFILTER; \
|
||||
for (i = 0; i < fa.in_numargs; ++i) \
|
||||
fa.out_args[i] = (struct fuse_arg) { \
|
||||
fa.out_args[i] = (struct fuse_bpf_arg) { \
|
||||
.size = fa.in_args[i].size, \
|
||||
.value = (void *)fa.in_args[i].value, \
|
||||
}; \
|
||||
@@ -1854,7 +1892,7 @@ void __exit fuse_bpf_cleanup(void);
|
||||
\
|
||||
if (ext_flags & FUSE_BPF_USER_FILTER) { \
|
||||
locked = fuse_lock_inode(inode); \
|
||||
res = fuse_simple_request(fm, &fa); \
|
||||
res = fuse_bpf_simple_request(fm, &fa); \
|
||||
fuse_unlock_inode(inode, locked); \
|
||||
if (res < 0) { \
|
||||
fer = (struct fuse_err_ret) { \
|
||||
@@ -1870,12 +1908,12 @@ void __exit fuse_bpf_cleanup(void);
|
||||
\
|
||||
fa.opcode &= ~FUSE_PREFILTER; \
|
||||
for (i = 0; i < fa.in_numargs; ++i) \
|
||||
fa.in_args[i] = (struct fuse_in_arg) { \
|
||||
fa.in_args[i] = (struct fuse_bpf_in_arg) { \
|
||||
.size = fa.out_args[i].size, \
|
||||
.value = fa.out_args[i].value, \
|
||||
}; \
|
||||
for (i = 0; i < fa.out_numargs; ++i) \
|
||||
fa.out_args[i] = (struct fuse_arg) { \
|
||||
for (i = 0; i < fa_backup.out_numargs; ++i) \
|
||||
fa.out_args[i] = (struct fuse_bpf_arg) { \
|
||||
.size = fa_backup.out_args[i].size, \
|
||||
.value = fa_backup.out_args[i].value, \
|
||||
}; \
|
||||
@@ -1893,7 +1931,7 @@ void __exit fuse_bpf_cleanup(void);
|
||||
fa.opcode |= FUSE_POSTFILTER; \
|
||||
for (i = 0; i < fa.out_numargs; ++i) \
|
||||
fa.in_args[fa.in_numargs++] = \
|
||||
(struct fuse_in_arg) { \
|
||||
(struct fuse_bpf_in_arg) { \
|
||||
.size = fa.out_args[i].size, \
|
||||
.value = fa.out_args[i].value, \
|
||||
}; \
|
||||
@@ -1912,7 +1950,7 @@ void __exit fuse_bpf_cleanup(void);
|
||||
fa.out_args[1].size = fa_backup.out_args[1].size; \
|
||||
fa.out_numargs = fa_backup.out_numargs; \
|
||||
locked = fuse_lock_inode(inode); \
|
||||
res = fuse_simple_request(fm, &fa); \
|
||||
res = fuse_bpf_simple_request(fm, &fa); \
|
||||
fuse_unlock_inode(inode, locked); \
|
||||
if (res < 0) { \
|
||||
fer.result = ERR_PTR(res); \
|
||||
|
||||
@@ -78,7 +78,7 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LSM, lsm,
|
||||
#endif /* CONFIG_BPF_LSM */
|
||||
#endif
|
||||
#ifdef CONFIG_FUSE_BPF
|
||||
BPF_PROG_TYPE(BPF_PROG_TYPE_FUSE, fuse, struct fuse_args, struct fuse_args)
|
||||
BPF_PROG_TYPE(BPF_PROG_TYPE_FUSE, fuse, struct fuse_bpf_args, struct fuse_bpf_args)
|
||||
#endif
|
||||
|
||||
BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY, array_map_ops)
|
||||
|
||||
@@ -965,42 +965,44 @@ struct fuse_removemapping_one {
|
||||
#define FUSE_REMOVEMAPPING_MAX_ENTRY \
|
||||
(PAGE_SIZE / sizeof(struct fuse_removemapping_one))
|
||||
|
||||
struct fuse_mount;
|
||||
/*
|
||||
* Fuse BPF Args
|
||||
*
|
||||
* Used to communicate with bpf programs to allow checking or altering certain values.
|
||||
* The end_offset allows the bpf verifier to check boundaries statically. This reflects
|
||||
* the ends of the buffer. size shows the length that was actually used.
|
||||
*
|
||||
*/
|
||||
|
||||
/** One input argument of a request */
|
||||
struct fuse_in_arg {
|
||||
unsigned size;
|
||||
struct fuse_bpf_in_arg {
|
||||
uint32_t size;
|
||||
const void *value;
|
||||
const void *end_offset;
|
||||
};
|
||||
|
||||
/** One output argument of a request */
|
||||
struct fuse_arg {
|
||||
unsigned size;
|
||||
struct fuse_bpf_arg {
|
||||
uint32_t size;
|
||||
void *value;
|
||||
void *end_offset;
|
||||
};
|
||||
|
||||
struct fuse_args {
|
||||
#define FUSE_MAX_IN_ARGS 5
|
||||
#define FUSE_MAX_OUT_ARGS 3
|
||||
|
||||
#define FUSE_BPF_FORCE (1 << 0)
|
||||
#define FUSE_BPF_OUT_ARGVAR (1 << 6)
|
||||
|
||||
struct fuse_bpf_args {
|
||||
uint64_t nodeid;
|
||||
uint32_t opcode;
|
||||
uint32_t error_in;
|
||||
unsigned short in_numargs;
|
||||
unsigned short out_numargs;
|
||||
int force:1;
|
||||
int noreply:1;
|
||||
int nocreds:1;
|
||||
int in_pages:1;
|
||||
int out_pages:1;
|
||||
int user_pages:1;
|
||||
int out_argvar:1;
|
||||
int page_zeroing:1;
|
||||
int page_replace:1;
|
||||
int may_block:1;
|
||||
struct fuse_in_arg in_args[5];
|
||||
struct fuse_arg out_args[3];
|
||||
void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error);
|
||||
|
||||
/* Path used for completing d_canonical_path */
|
||||
struct path *canonical_path;
|
||||
uint32_t in_numargs;
|
||||
uint32_t out_numargs;
|
||||
uint32_t flags;
|
||||
struct fuse_bpf_in_arg in_args[FUSE_MAX_IN_ARGS];
|
||||
struct fuse_bpf_arg out_args[FUSE_MAX_OUT_ARGS];
|
||||
};
|
||||
|
||||
#define FUSE_BPF_USER_FILTER 1
|
||||
|
||||
@@ -36,12 +36,12 @@ static bool fuse_prog_is_valid_access(int off, int size,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (off < 0 || off > offsetofend(struct fuse_args, out_args))
|
||||
if (off < 0 || off > offsetofend(struct fuse_bpf_args, out_args))
|
||||
return false;
|
||||
|
||||
/* TODO This is garbage. Do it properly */
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (off == offsetof(struct fuse_args, in_args[i].value)) {
|
||||
if (off == offsetof(struct fuse_bpf_args, in_args[i].value)) {
|
||||
info->reg_type = PTR_TO_RDONLY_BUF;
|
||||
info->ctx_field_size = 256;
|
||||
if (type != BPF_READ)
|
||||
@@ -50,7 +50,7 @@ static bool fuse_prog_is_valid_access(int off, int size,
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (off == offsetof(struct fuse_args, out_args[i].value)) {
|
||||
if (off == offsetof(struct fuse_bpf_args, out_args[i].value)) {
|
||||
info->reg_type = PTR_TO_RDWR_BUF;
|
||||
info->ctx_field_size = 256;
|
||||
return true;
|
||||
|
||||
@@ -74,7 +74,7 @@ SEC("maps") struct fuse_bpf_map test_map2 = {
|
||||
|
||||
SEC("test_daemon")
|
||||
|
||||
int trace_daemon(struct fuse_args *fa)
|
||||
int trace_daemon(struct fuse_bpf_args *fa)
|
||||
{
|
||||
uint64_t uid_gid = bpf_get_current_uid_gid();
|
||||
uint32_t uid = uid_gid & 0xffffffff;
|
||||
|
||||
@@ -35,7 +35,7 @@ inline int strcmp(const char *a, const char *b)
|
||||
}
|
||||
SEC("test_readdir_redact")
|
||||
/* return FUSE_BPF_BACKING to use backing fs, 0 to pass to usermode */
|
||||
int readdir_test(struct fuse_args *fa)
|
||||
int readdir_test(struct fuse_bpf_args *fa)
|
||||
{
|
||||
switch (fa->opcode) {
|
||||
case FUSE_READDIR | FUSE_PREFILTER: {
|
||||
@@ -60,7 +60,7 @@ int readdir_test(struct fuse_args *fa)
|
||||
SEC("test_trace")
|
||||
|
||||
/* return FUSE_BPF_BACKING to use backing fs, 0 to pass to usermode */
|
||||
int trace_test(struct fuse_args *fa)
|
||||
int trace_test(struct fuse_bpf_args *fa)
|
||||
{
|
||||
switch (fa->opcode) {
|
||||
case FUSE_LOOKUP | FUSE_PREFILTER: {
|
||||
@@ -361,7 +361,7 @@ int trace_test(struct fuse_args *fa)
|
||||
|
||||
SEC("test_hidden")
|
||||
|
||||
int trace_hidden(struct fuse_args *fa)
|
||||
int trace_hidden(struct fuse_bpf_args *fa)
|
||||
{
|
||||
switch (fa->opcode) {
|
||||
case FUSE_LOOKUP | FUSE_PREFILTER: {
|
||||
@@ -418,7 +418,7 @@ int trace_hidden(struct fuse_args *fa)
|
||||
}
|
||||
|
||||
SEC("test_simple")
|
||||
int trace_simple(struct fuse_args *fa)
|
||||
int trace_simple(struct fuse_bpf_args *fa)
|
||||
{
|
||||
if (fa->opcode & FUSE_PREFILTER)
|
||||
bpf_printk("prefilter opcode: %d",
|
||||
@@ -432,7 +432,7 @@ int trace_simple(struct fuse_args *fa)
|
||||
}
|
||||
|
||||
SEC("test_passthrough")
|
||||
int trace_daemon(struct fuse_args *fa)
|
||||
int trace_daemon(struct fuse_bpf_args *fa)
|
||||
{
|
||||
switch (fa->opcode) {
|
||||
case FUSE_LOOKUP | FUSE_PREFILTER: {
|
||||
@@ -468,7 +468,7 @@ int trace_daemon(struct fuse_args *fa)
|
||||
SEC("test_error")
|
||||
|
||||
/* return FUSE_BPF_BACKING to use backing fs, 0 to pass to usermode */
|
||||
int error_test(struct fuse_args *fa)
|
||||
int error_test(struct fuse_bpf_args *fa)
|
||||
{
|
||||
switch (fa->opcode) {
|
||||
case FUSE_MKDIR | FUSE_PREFILTER: {
|
||||
|
||||
Reference in New Issue
Block a user