Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  fs/anon_inodes.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2007  Davide Libenzi <davidel@xmailserver.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Thanks to Arnd Bergmann for code review and suggestions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  More changes for Thomas Gleixner suggestions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/poll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/magic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/anon_inodes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/pseudo_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static struct vfsmount *anon_inode_mnt __read_mostly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static struct inode *anon_inode_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * anon_inodefs_dname() is called from d_path().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static char *anon_inodefs_dname(struct dentry *dentry, char *buffer, int buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	return dynamic_dname(dentry, buffer, buflen, "anon_inode:%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 				dentry->d_name.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static const struct dentry_operations anon_inodefs_dentry_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	.d_dname	= anon_inodefs_dname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int anon_inodefs_init_fs_context(struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct pseudo_fs_context *ctx = init_pseudo(fc, ANON_INODE_FS_MAGIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (!ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	ctx->dops = &anon_inodefs_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static struct file_system_type anon_inode_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	.name		= "anon_inodefs",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	.init_fs_context = anon_inodefs_init_fs_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	.kill_sb	= kill_anon_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static struct inode *anon_inode_make_secure_inode(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	const struct inode *context_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	const struct qstr qname = QSTR_INIT(name, strlen(name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	inode = alloc_anon_inode(anon_inode_mnt->mnt_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (IS_ERR(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	inode->i_flags &= ~S_PRIVATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	error =	security_inode_init_security_anon(inode, &qname, context_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return ERR_PTR(error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static struct file *__anon_inode_getfile(const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					 const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 					 void *priv, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 					 const struct inode *context_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 					 bool secure)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	if (fops->owner && !try_module_get(fops->owner))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		return ERR_PTR(-ENOENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if (secure) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		inode =	anon_inode_make_secure_inode(name, context_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			file = ERR_CAST(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		inode =	anon_inode_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			file = ERR_PTR(-ENODEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		 * We know the anon_inode inode count is always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		 * greater than zero, so ihold() is safe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		ihold(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	file = alloc_file_pseudo(inode, anon_inode_mnt, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 				 flags & (O_ACCMODE | O_NONBLOCK), fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (IS_ERR(file))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		goto err_iput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	file->f_mapping = inode->i_mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	file->private_data = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) err_iput:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	module_put(fops->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	return file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * anon_inode_getfile - creates a new file instance by hooking it up to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *                      anonymous inode, and a dentry that describe the "class"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *                      of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * @name:    [in]    name of the "class" of the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * @fops:    [in]    file operations for the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * @priv:    [in]    private data for the new file (will be file's private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * @flags:   [in]    flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * Creates a new file by hooking it on a single inode. This is useful for files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * that do not need to have a full-fledged inode in order to operate correctly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * All the files created with anon_inode_getfile() will share a single inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * hence saving memory and avoiding code duplication for the file/inode/dentry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * setup.  Returns the newly created file* or an error pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct file *anon_inode_getfile(const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 				const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 				void *priv, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	return __anon_inode_getfile(name, fops, priv, flags, NULL, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) EXPORT_SYMBOL_GPL(anon_inode_getfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int __anon_inode_getfd(const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			      const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			      void *priv, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			      const struct inode *context_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			      bool secure)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	int error, fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	error = get_unused_fd_flags(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	if (error < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	fd = error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	file = __anon_inode_getfile(name, fops, priv, flags, context_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				    secure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (IS_ERR(file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		error = PTR_ERR(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		goto err_put_unused_fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	fd_install(fd, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) err_put_unused_fd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	put_unused_fd(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * anon_inode_getfd - creates a new file instance by hooking it up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *                    an anonymous inode and a dentry that describe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *                    the "class" of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * @name:    [in]    name of the "class" of the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * @fops:    [in]    file operations for the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * @priv:    [in]    private data for the new file (will be file's private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * @flags:   [in]    flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * Creates a new file by hooking it on a single inode. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * useful for files that do not need to have a full-fledged inode in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * order to operate correctly.  All the files created with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * anon_inode_getfd() will use the same singleton inode, reducing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  * memory use and avoiding code duplication for the file/inode/dentry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * setup.  Returns a newly created file descriptor or an error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) int anon_inode_getfd(const char *name, const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		     void *priv, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	return __anon_inode_getfd(name, fops, priv, flags, NULL, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) EXPORT_SYMBOL_GPL(anon_inode_getfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * anon_inode_getfd_secure - Like anon_inode_getfd(), but creates a new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  * !S_PRIVATE anon inode rather than reuse the singleton anon inode, and calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * the inode_init_security_anon() LSM hook. This allows the inode to have its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * own security context and for a LSM to reject creation of the inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * @name:    [in]    name of the "class" of the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * @fops:    [in]    file operations for the new file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * @priv:    [in]    private data for the new file (will be file's private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * @flags:   [in]    flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  * @context_inode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  *           [in]    the logical relationship with the new inode (optional)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * The LSM may use @context_inode in inode_init_security_anon(), but a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * reference to it is not held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int anon_inode_getfd_secure(const char *name, const struct file_operations *fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			    void *priv, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			    const struct inode *context_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	return __anon_inode_getfd(name, fops, priv, flags, context_inode, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) EXPORT_SYMBOL_GPL(anon_inode_getfd_secure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static int __init anon_inode_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	anon_inode_mnt = kern_mount(&anon_inode_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	if (IS_ERR(anon_inode_mnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		panic("anon_inode_init() kernel mount failed (%ld)\n", PTR_ERR(anon_inode_mnt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	anon_inode_inode = alloc_anon_inode(anon_inode_mnt->mnt_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if (IS_ERR(anon_inode_inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		panic("anon_inode_init() inode allocation failed (%ld)\n", PTR_ERR(anon_inode_inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) fs_initcall(anon_inode_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)