From 7bc3e32f7fd75d197e533170e5dcfc70133a84e3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 2 Jul 2020 12:51:03 +0200 Subject: [PATCH] ANDROID: GKI: set vfs-only exports into their own namespace We have namespaces, so use them for all vfs-exported namespaces so that filesystems can use them, but not anything else. Bug: 157965270 Signed-off-by: Greg Kroah-Hartman Change-Id: Ic214d31360af5f1e025a176a61e346a8ec62a735 --- fs/Makefile | 2 ++ fs/incfs/main.c | 1 + fs/namei.c | 14 +++++++------- fs/open.c | 4 ++-- fs/read_write.c | 4 ++-- fs/stat.c | 2 +- fs/xattr.c | 6 +++--- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/fs/Makefile b/fs/Makefile index 3d717a67d435..ac8262fdc12c 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -6,6 +6,8 @@ # Rewritten to use lists instead of if-statements. # +ccflags-y += -DANDROID_GKI_VFS_EXPORT_ONLY=VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver + obj-y := open.o read_write.o file_table.o super.o \ char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ ioctl.o readdir.o select.o dcache.o inode.o \ diff --git a/fs/incfs/main.c b/fs/incfs/main.c index e65d0d895128..a3f0a738ad55 100644 --- a/fs/incfs/main.c +++ b/fs/incfs/main.c @@ -101,3 +101,4 @@ module_exit(cleanup_incfs_module); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Eugene Zemtsov "); MODULE_DESCRIPTION("Incremental File System"); +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver); diff --git a/fs/namei.c b/fs/namei.c index 8a57cfd687e2..c1919544f6d6 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2509,7 +2509,7 @@ int kern_path(const char *name, unsigned int flags, struct path *path) return filename_lookup(AT_FDCWD, getname_kernel(name), flags, path, NULL); } -EXPORT_SYMBOL(kern_path); +EXPORT_SYMBOL_NS(kern_path, ANDROID_GKI_VFS_EXPORT_ONLY); /** * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair @@ -2989,7 +2989,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, fsnotify_create(dir, dentry); return error; } -EXPORT_SYMBOL(vfs_create); +EXPORT_SYMBOL_NS(vfs_create, ANDROID_GKI_VFS_EXPORT_ONLY); int vfs_mkobj(struct dentry *dentry, umode_t mode, int (*f)(struct dentry *, umode_t, void *), @@ -3896,7 +3896,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) fsnotify_mkdir(dir, dentry); return error; } -EXPORT_SYMBOL(vfs_mkdir); +EXPORT_SYMBOL_NS(vfs_mkdir, ANDROID_GKI_VFS_EXPORT_ONLY); long do_mkdirat(int dfd, const char __user *pathname, umode_t mode) { @@ -3971,7 +3971,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) d_delete(dentry); return error; } -EXPORT_SYMBOL(vfs_rmdir); +EXPORT_SYMBOL_NS(vfs_rmdir, ANDROID_GKI_VFS_EXPORT_ONLY); long do_rmdir(int dfd, const char __user *pathname) { @@ -4094,7 +4094,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegate return error; } -EXPORT_SYMBOL(vfs_unlink); +EXPORT_SYMBOL_NS(vfs_unlink, ANDROID_GKI_VFS_EXPORT_ONLY); /* * Make sure that the actual truncation of the file will occur outside its @@ -4330,7 +4330,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de fsnotify_link(dir, inode, new_dentry); return error; } -EXPORT_SYMBOL(vfs_link); +EXPORT_SYMBOL_NS(vfs_link, ANDROID_GKI_VFS_EXPORT_ONLY); /* * Hardlinks are often used in delicate situations. We avoid @@ -4590,7 +4590,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, return error; } -EXPORT_SYMBOL(vfs_rename); +EXPORT_SYMBOL_NS(vfs_rename, ANDROID_GKI_VFS_EXPORT_ONLY); static int do_renameat2(int olddfd, const char __user *oldname, int newdfd, const char __user *newname, unsigned int flags) diff --git a/fs/open.c b/fs/open.c index dcbd01611237..88e42c2e8742 100644 --- a/fs/open.c +++ b/fs/open.c @@ -321,7 +321,7 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) file_end_write(file); return ret; } -EXPORT_SYMBOL_GPL(vfs_fallocate); +EXPORT_SYMBOL_NS_GPL(vfs_fallocate, ANDROID_GKI_VFS_EXPORT_ONLY); int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len) { @@ -932,7 +932,7 @@ struct file *dentry_open(const struct path *path, int flags, } return f; } -EXPORT_SYMBOL(dentry_open); +EXPORT_SYMBOL_NS(dentry_open, ANDROID_GKI_VFS_EXPORT_ONLY); struct file *open_with_fake_path(const struct path *path, int flags, struct inode *inode, const struct cred *cred) diff --git a/fs/read_write.c b/fs/read_write.c index 7458fccc59e1..93d06b4c5f78 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -441,7 +441,7 @@ ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) set_fs(old_fs); return result; } -EXPORT_SYMBOL(kernel_read); +EXPORT_SYMBOL_NS(kernel_read, ANDROID_GKI_VFS_EXPORT_ONLY); ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { @@ -537,7 +537,7 @@ ssize_t kernel_write(struct file *file, const void *buf, size_t count, return res; } -EXPORT_SYMBOL(kernel_write); +EXPORT_SYMBOL_NS(kernel_write, ANDROID_GKI_VFS_EXPORT_ONLY); ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { diff --git a/fs/stat.c b/fs/stat.c index c38e4c2e1221..ec9220cc1c2d 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -117,7 +117,7 @@ int vfs_getattr(const struct path *path, struct kstat *stat, return retval; return vfs_getattr_nosec(path, stat, request_mask, query_flags); } -EXPORT_SYMBOL(vfs_getattr); +EXPORT_SYMBOL_NS(vfs_getattr, ANDROID_GKI_VFS_EXPORT_ONLY); /** * vfs_statx_fd - Get the enhanced basic attributes by file descriptor diff --git a/fs/xattr.c b/fs/xattr.c index 71f887518d6f..f8ef34db162f 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -227,7 +227,7 @@ vfs_setxattr(struct dentry *dentry, const char *name, const void *value, inode_unlock(inode); return error; } -EXPORT_SYMBOL_GPL(vfs_setxattr); +EXPORT_SYMBOL_NS_GPL(vfs_setxattr, ANDROID_GKI_VFS_EXPORT_ONLY); static ssize_t xattr_getsecurity(struct inode *inode, const char *name, void *value, @@ -341,7 +341,7 @@ vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) { return __vfs_getxattr(dentry, dentry->d_inode, name, value, size, 0); } -EXPORT_SYMBOL_GPL(vfs_getxattr); +EXPORT_SYMBOL_NS_GPL(vfs_getxattr, ANDROID_GKI_VFS_EXPORT_ONLY); ssize_t vfs_listxattr(struct dentry *dentry, char *list, size_t size) @@ -361,7 +361,7 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size) } return error; } -EXPORT_SYMBOL_GPL(vfs_listxattr); +EXPORT_SYMBOL_NS_GPL(vfs_listxattr, ANDROID_GKI_VFS_EXPORT_ONLY); int __vfs_removexattr(struct dentry *dentry, const char *name)