Centos-kernel-stream-9/fs/vboxsf/vfsmod.h

147 lines
4.5 KiB
C
Raw Permalink Normal View History

/* SPDX-License-Identifier: MIT */
/*
* VirtualBox Guest Shared Folders support: module header.
*
* Copyright (C) 2006-2018 Oracle Corporation
*/
#ifndef VFSMOD_H
#define VFSMOD_H
#include <linux/backing-dev.h>
#include <linux/idr.h>
#include "shfl_hostintf.h"
#define DIR_BUFFER_SIZE SZ_16K
/* The cast is to prevent assignment of void * to pointers of arbitrary type */
#define VBOXSF_SBI(sb) ((struct vboxsf_sbi *)(sb)->s_fs_info)
#define VBOXSF_I(i) container_of(i, struct vboxsf_inode, vfs_inode)
struct vboxsf_handle;
struct vboxsf_options {
unsigned long ttl;
kuid_t uid;
kgid_t gid;
bool dmode_set;
bool fmode_set;
umode_t dmode;
umode_t fmode;
umode_t dmask;
umode_t fmask;
};
struct vboxsf_fs_context {
struct vboxsf_options o;
char *nls_name;
};
/* per-shared folder information */
struct vboxsf_sbi {
struct vboxsf_options o;
struct shfl_fsobjinfo root_info;
struct idr ino_idr;
spinlock_t ino_idr_lock; /* This protects ino_idr */
struct nls_table *nls;
u32 next_generation;
u32 root;
int bdi_id;
};
/* per-inode information */
struct vboxsf_inode {
/* some information was changed, update data on next revalidate */
int force_restat;
/* list of open handles for this inode + lock protecting it */
struct list_head handle_list;
/* This mutex protects handle_list accesses */
struct mutex handle_list_mutex;
/* The VFS inode struct */
struct inode vfs_inode;
};
struct vboxsf_dir_info {
struct list_head info_list;
};
struct vboxsf_dir_buf {
size_t entries;
size_t free;
size_t used;
void *buf;
struct list_head head;
};
/* globals */
extern const struct inode_operations vboxsf_dir_iops;
extern const struct inode_operations vboxsf_lnk_iops;
extern const struct inode_operations vboxsf_reg_iops;
extern const struct file_operations vboxsf_dir_fops;
extern const struct file_operations vboxsf_reg_fops;
extern const struct address_space_operations vboxsf_reg_aops;
extern const struct dentry_operations vboxsf_dentry_ops;
/* from file.c */
struct vboxsf_handle *vboxsf_create_sf_handle(struct inode *inode,
u64 handle, u32 access_flags);
void vboxsf_release_sf_handle(struct inode *inode, struct vboxsf_handle *sf_handle);
/* from utils.c */
struct inode *vboxsf_new_inode(struct super_block *sb);
int vboxsf_init_inode(struct vboxsf_sbi *sbi, struct inode *inode,
const struct shfl_fsobjinfo *info, bool reinit);
int vboxsf_create_at_dentry(struct dentry *dentry,
struct shfl_createparms *params);
int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path,
struct shfl_fsobjinfo *info);
int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info);
int vboxsf_inode_revalidate(struct dentry *dentry);
fs: port ->getattr() to pass mnt_idmap JIRA: https://issues.redhat.com/browse/RHEL-33888 Status: Linus Conflicts: CentOS Stream has commit 3e0b6f1fa9a1c ("afs: use read_seqbegin() in afs_check_validity() and afs_getattr()"), manually apply hunk #2 to fs/afs/inode.c. CentOS Stream commit 3b06927229296 {"afs: split afs_pagecache_valid() out of afs_validate()") is present which causes a reject in fs/afs/internal.h, manually apply hunk to fs/afs/internal.h. For consistency drop btrfs hunks because it isn't supported in CentOS Stream and other backports also drop such hunks. CentOS Stream commit 48fa94aacd100 ("ceph: fscrypt_auth handling for ceph") alters the definition of _ceph_setattr() causing fuzz. The cifs source has been moved in CentOS Stream so manually apply rejected hunks to fs/smb/client/cifsfs.h and fs/smb/client/inode.c. Upstream commit 2e1d66379ece5 ("staging: erofs: drop the extern prefix for function definitions") caused strange behaviour when applying this patch, there was a conflict in fs/erofs/internal.h but after a refresh the hunk and context looked ok. The hunk had to be manually applied. Upstream commit 2db0487faa211 ("f2fs: move f2fs_force_buffered_io() into file.c") is not present in CentOS Stream which causes fuzz when applying the first hunk to fs/f2fs/file.c. Upstream commit 30abce053f811 ("fat: report creation time in statx") is not present in CentOS Stream which caused a reject so apply change manually. Dropped hunks for ksmbd because the source is not present in the CentOS Stream source tree. Dropped hunks for ntfs3 because the source is not present in the CentOS Stream source tree. There was fuzz with hunk #2 against fs/nfs/inode.c but I was unable to see any difference. CentOS Stream commit 98ba731fc7eae ("ovl: Move xattr support to new xattrs.c file") is present which caused fuzz in fs/overlayfs/overlayfs.h. Upstream commit d919a1e79bac8 ("proc: fix a dentry lock race between release_task and lookup") is not present in CentOS Stream causing fuzz applying hunk #1 against fs/proc/base.c. CentOS Stream commit 20c470188c2eb ("vfs: plumb i_version handling into struct kstat") is present causing fuzz in hunk #2 against fs/stat.c. Upstream commit e0c49bd2b4d3c ("fs: sysv: Fix sysv_nblocks() returns wrong value") is not present in CentOS Stream causing fuzz applying hunk#1 against fs/sysv/itree.c. CentOS Stream commit 892da692fa5bc ("shmem: support idmapped mounts for tmpfs") is present so it's ok to pass idmap to generic_fillattr(). CentOS Stream commit f0f830cd7e01b {"ceph: create symlinks with encrypted and base64-encoded targets") uses the old struct user_namespace and so leaves those changes out, make those getattr() changes here. Allow for CentOS Stream commit 6c3396a0d8f2c ("kernfs: Introduce separate rwsem to protect inode attributes") which is already present. CentOS Stream commit f5219db0c03b6 ("KVM: fix Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory") updated the upstream commit a7800aa80ea4d ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory") to account for missing idmapping commits. Now we have updated the second and final place these changes were made make the final needed adjustment to match the original upstream patch. commit b74d24f7a74ffd2d42ca883d84b7422b8d545901 Author: Christian Brauner <brauner@kernel.org> Date: Fri Jan 13 12:49:12 2023 +0100 fs: port ->getattr() to pass mnt_idmap Convert to struct mnt_idmap. Last cycle we merged the necessary infrastructure in 256c8aed2b42 ("fs: introduce dedicated idmap type for mounts"). This is just the conversion to struct mnt_idmap. Currently we still pass around the plain namespace that was attached to a mount. This is in general pretty convenient but it makes it easy to conflate namespaces that are relevant on the filesystem with namespaces that are relevent on the mount level. Especially for non-vfs developers without detailed knowledge in this area this can be a potential source for bugs. Once the conversion to struct mnt_idmap is done all helpers down to the really low-level helpers will take a struct mnt_idmap argument instead of two namespace arguments. This way it becomes impossible to conflate the two eliminating the possibility of any bugs. All of the vfs and all filesystems only operate on struct mnt_idmap. Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Ian Kent <ikent@redhat.com>
2024-05-21 04:47:00 +00:00
int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *kstat, u32 request_mask,
unsigned int query_flags);
fs: port ->setattr() to pass mnt_idmap JIRA: https://issues.redhat.com/browse/RHEL-33888 Status: Linus Conflicts: CentOS Stream commit 3c29fadfb1ba7 ("afs: split afs_pagecache_valid() out of afs_validate()") is present, manually adjust hunk #1 of fs/afs/internal.h. For consistency drop btrfs hunks because it isn't supported in CentOS Stream and other backports also drop such hunks. CentOS Stream commit 48fa94aacd100 ("ceph: fscrypt_auth handling for ceph") alters the definition of _ceph_setattr(), adjust manually. CentOS Stream commit 34b2a2b5a3b7e {"ceph: add some fscrypt guardrails") introduces a call to fscrypt_prepare_setattr() which causes fuzz when applying. The cifs source has been moved in CentOS Stream so manually apply rejected hunks to fs/smb/client/cifsfs.h and fs/smb/client/inode.c. Upstream commit 5a646fb3a3e2d ("coda: avoid doing bad things on inode type changes during revalidation") is not present which causes fuzz in fs/coda/coda_linux.h. Dropped hunks for ntfs3 because the source is not present in the CentOS Stream source tree. CentOS Stream commit 98ba731fc7eae ("ovl: Move xattr support to new xattrs.c file") is presnt so manually apply hunk. CentOS Stream commit 892da692fa5bc ("shmem: support idmapped mounts for tmpfs") is present so it's ok to pass idmap to setattr_prepare() and setattr_copy(). Update to add incremental changes needed due to CentOS Stream commit 469e1d13f6e5f ("shmem: quota support"). Allow for CentOS Stream commit 6c3396a0d8f2c ("kernfs: Introduce separate rwsem to protect inode attributes") which is already present. CentOS Stream commit f5219db0c03b6 ("KVM: fix Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory") updated the upstream commit a7800aa80ea4d ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory") to account for missing idmapping commits. Now we have updated one of the two places these changes were made make one of the needed adjustments to match the original upstream patch. commit c1632a0f11209338fc300c66252bcc4686e609e8 Author: Christian Brauner <brauner@kernel.org> Date: Fri Jan 13 12:49:11 2023 +0100 fs: port ->setattr() to pass mnt_idmap Convert to struct mnt_idmap. Last cycle we merged the necessary infrastructure in 256c8aed2b42 ("fs: introduce dedicated idmap type for mounts"). This is just the conversion to struct mnt_idmap. Currently we still pass around the plain namespace that was attached to a mount. This is in general pretty convenient but it makes it easy to conflate namespaces that are relevant on the filesystem with namespaces that are relevent on the mount level. Especially for non-vfs developers without detailed knowledge in this area this can be a potential source for bugs. Once the conversion to struct mnt_idmap is done all helpers down to the really low-level helpers will take a struct mnt_idmap argument instead of two namespace arguments. This way it becomes impossible to conflate the two eliminating the possibility of any bugs. All of the vfs and all filesystems only operate on struct mnt_idmap. Acked-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Ian Kent <ikent@redhat.com>
2024-05-21 03:43:39 +00:00
int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr);
struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi,
struct dentry *dentry);
int vboxsf_nlscpy(struct vboxsf_sbi *sbi, char *name, size_t name_bound_len,
const unsigned char *utf8_name, size_t utf8_len);
struct vboxsf_dir_info *vboxsf_dir_info_alloc(void);
void vboxsf_dir_info_free(struct vboxsf_dir_info *p);
int vboxsf_dir_read_all(struct vboxsf_sbi *sbi, struct vboxsf_dir_info *sf_d,
u64 handle);
/* from vboxsf_wrappers.c */
int vboxsf_connect(void);
void vboxsf_disconnect(void);
int vboxsf_create(u32 root, struct shfl_string *parsed_path,
struct shfl_createparms *create_parms);
int vboxsf_close(u32 root, u64 handle);
int vboxsf_remove(u32 root, struct shfl_string *parsed_path, u32 flags);
int vboxsf_rename(u32 root, struct shfl_string *src_path,
struct shfl_string *dest_path, u32 flags);
int vboxsf_read(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf);
int vboxsf_write(u32 root, u64 handle, u64 offset, u32 *buf_len, u8 *buf);
int vboxsf_dirinfo(u32 root, u64 handle,
struct shfl_string *parsed_path, u32 flags, u32 index,
u32 *buf_len, struct shfl_dirinfo *buf, u32 *file_count);
int vboxsf_fsinfo(u32 root, u64 handle, u32 flags,
u32 *buf_len, void *buf);
int vboxsf_map_folder(struct shfl_string *folder_name, u32 *root);
int vboxsf_unmap_folder(u32 root);
int vboxsf_readlink(u32 root, struct shfl_string *parsed_path,
u32 buf_len, u8 *buf);
int vboxsf_symlink(u32 root, struct shfl_string *new_path,
struct shfl_string *old_path, struct shfl_fsobjinfo *buf);
int vboxsf_set_utf8(void);
int vboxsf_set_symlinks(void);
#endif