1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
25dc8bf81SDavide Libenzi /*
35dc8bf81SDavide Libenzi * fs/anon_inodes.c
45dc8bf81SDavide Libenzi *
55dc8bf81SDavide Libenzi * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
65dc8bf81SDavide Libenzi *
75dc8bf81SDavide Libenzi * Thanks to Arnd Bergmann for code review and suggestions.
85dc8bf81SDavide Libenzi * More changes for Thomas Gleixner suggestions.
95dc8bf81SDavide Libenzi *
105dc8bf81SDavide Libenzi */
115dc8bf81SDavide Libenzi
12a99bbaf5SAlexey Dobriyan #include <linux/cred.h>
135dc8bf81SDavide Libenzi #include <linux/file.h>
145dc8bf81SDavide Libenzi #include <linux/poll.h>
15a99bbaf5SAlexey Dobriyan #include <linux/sched.h>
165dc8bf81SDavide Libenzi #include <linux/init.h>
175dc8bf81SDavide Libenzi #include <linux/fs.h>
185dc8bf81SDavide Libenzi #include <linux/mount.h>
195dc8bf81SDavide Libenzi #include <linux/module.h>
205dc8bf81SDavide Libenzi #include <linux/kernel.h>
215dc8bf81SDavide Libenzi #include <linux/magic.h>
225dc8bf81SDavide Libenzi #include <linux/anon_inodes.h>
2333cada40SDavid Howells #include <linux/pseudo_fs.h>
245dc8bf81SDavide Libenzi
257c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
265dc8bf81SDavide Libenzi
27cfd86ef7SChristian Brauner #include "internal.h"
28cfd86ef7SChristian Brauner
2968279f9cSAlexey Dobriyan static struct vfsmount *anon_inode_mnt __ro_after_init;
3068279f9cSAlexey Dobriyan static struct inode *anon_inode_inode __ro_after_init;
315dc8bf81SDavide Libenzi
32b9aff027SNick Piggin /*
33cfd86ef7SChristian Brauner * User space expects anonymous inodes to have no file type in st_mode.
34cfd86ef7SChristian Brauner *
35cfd86ef7SChristian Brauner * In particular, 'lsof' has this legacy logic:
36cfd86ef7SChristian Brauner *
37cfd86ef7SChristian Brauner * type = s->st_mode & S_IFMT;
38cfd86ef7SChristian Brauner * switch (type) {
39cfd86ef7SChristian Brauner * ...
40cfd86ef7SChristian Brauner * case 0:
41cfd86ef7SChristian Brauner * if (!strcmp(p, "anon_inode"))
42cfd86ef7SChristian Brauner * Lf->ntype = Ntype = N_ANON_INODE;
43cfd86ef7SChristian Brauner *
44cfd86ef7SChristian Brauner * to detect our old anon_inode logic.
45cfd86ef7SChristian Brauner *
46cfd86ef7SChristian Brauner * Rather than mess with our internal sane inode data, just fix it
47cfd86ef7SChristian Brauner * up here in getattr() by masking off the format bits.
48cfd86ef7SChristian Brauner */
anon_inode_getattr(struct mnt_idmap * idmap,const struct path * path,struct kstat * stat,u32 request_mask,unsigned int query_flags)49cfd86ef7SChristian Brauner int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
50cfd86ef7SChristian Brauner struct kstat *stat, u32 request_mask,
51cfd86ef7SChristian Brauner unsigned int query_flags)
52cfd86ef7SChristian Brauner {
53cfd86ef7SChristian Brauner struct inode *inode = d_inode(path->dentry);
54cfd86ef7SChristian Brauner
55cfd86ef7SChristian Brauner generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
56cfd86ef7SChristian Brauner stat->mode &= ~S_IFMT;
57cfd86ef7SChristian Brauner return 0;
58cfd86ef7SChristian Brauner }
59cfd86ef7SChristian Brauner
anon_inode_setattr(struct mnt_idmap * idmap,struct dentry * dentry,struct iattr * attr)6022bdf3d6SChristian Brauner int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
6122bdf3d6SChristian Brauner struct iattr *attr)
6222bdf3d6SChristian Brauner {
6322bdf3d6SChristian Brauner return -EOPNOTSUPP;
6422bdf3d6SChristian Brauner }
6522bdf3d6SChristian Brauner
66cfd86ef7SChristian Brauner static const struct inode_operations anon_inode_operations = {
67cfd86ef7SChristian Brauner .getattr = anon_inode_getattr,
6822bdf3d6SChristian Brauner .setattr = anon_inode_setattr,
69cfd86ef7SChristian Brauner };
70cfd86ef7SChristian Brauner
71cfd86ef7SChristian Brauner /*
72b9aff027SNick Piggin * anon_inodefs_dname() is called from d_path().
73b9aff027SNick Piggin */
anon_inodefs_dname(struct dentry * dentry,char * buffer,int buflen)74b9aff027SNick Piggin static char *anon_inodefs_dname(struct dentry *dentry, char *buffer, int buflen)
75b9aff027SNick Piggin {
760f60d288SAl Viro return dynamic_dname(buffer, buflen, "anon_inode:%s",
77b9aff027SNick Piggin dentry->d_name.name);
78b9aff027SNick Piggin }
79b9aff027SNick Piggin
80c74a1cbbSAl Viro static const struct dentry_operations anon_inodefs_dentry_operations = {
81c74a1cbbSAl Viro .d_dname = anon_inodefs_dname,
82c74a1cbbSAl Viro };
83c74a1cbbSAl Viro
anon_inodefs_init_fs_context(struct fs_context * fc)8433cada40SDavid Howells static int anon_inodefs_init_fs_context(struct fs_context *fc)
85ca7068c4SAl Viro {
8633cada40SDavid Howells struct pseudo_fs_context *ctx = init_pseudo(fc, ANON_INODE_FS_MAGIC);
8733cada40SDavid Howells if (!ctx)
8833cada40SDavid Howells return -ENOMEM;
891ed95281SChristian Brauner fc->s_iflags |= SB_I_NOEXEC;
901ed95281SChristian Brauner fc->s_iflags |= SB_I_NODEV;
9133cada40SDavid Howells ctx->dops = &anon_inodefs_dentry_operations;
9233cada40SDavid Howells return 0;
93ca7068c4SAl Viro }
94ca7068c4SAl Viro
95ca7068c4SAl Viro static struct file_system_type anon_inode_fs_type = {
96ca7068c4SAl Viro .name = "anon_inodefs",
9733cada40SDavid Howells .init_fs_context = anon_inodefs_init_fs_context,
98ca7068c4SAl Viro .kill_sb = kill_anon_super,
99ca7068c4SAl Viro };
100ca7068c4SAl Viro
101cbe4134eSShivank Garg /**
102cbe4134eSShivank Garg * anon_inode_make_secure_inode - allocate an anonymous inode with security context
103cbe4134eSShivank Garg * @sb: [in] Superblock to allocate from
104cbe4134eSShivank Garg * @name: [in] Name of the class of the newfile (e.g., "secretmem")
105cbe4134eSShivank Garg * @context_inode:
106cbe4134eSShivank Garg * [in] Optional parent inode for security inheritance
107cbe4134eSShivank Garg *
108cbe4134eSShivank Garg * The function ensures proper security initialization through the LSM hook
109cbe4134eSShivank Garg * security_inode_init_security_anon().
110cbe4134eSShivank Garg *
111cbe4134eSShivank Garg * Return: Pointer to new inode on success, ERR_PTR on failure.
112cbe4134eSShivank Garg */
anon_inode_make_secure_inode(struct super_block * sb,const char * name,const struct inode * context_inode)113cbe4134eSShivank Garg struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *name,
114e7e832ceSDaniel Colascione const struct inode *context_inode)
115e7e832ceSDaniel Colascione {
116e7e832ceSDaniel Colascione struct inode *inode;
117e7e832ceSDaniel Colascione int error;
118e7e832ceSDaniel Colascione
119cbe4134eSShivank Garg inode = alloc_anon_inode(sb);
120e7e832ceSDaniel Colascione if (IS_ERR(inode))
121e7e832ceSDaniel Colascione return inode;
122e7e832ceSDaniel Colascione inode->i_flags &= ~S_PRIVATE;
123cfd86ef7SChristian Brauner inode->i_op = &anon_inode_operations;
124c1feab95SAl Viro error = security_inode_init_security_anon(inode, &QSTR(name),
125c1feab95SAl Viro context_inode);
126e7e832ceSDaniel Colascione if (error) {
127e7e832ceSDaniel Colascione iput(inode);
128e7e832ceSDaniel Colascione return ERR_PTR(error);
129e7e832ceSDaniel Colascione }
130e7e832ceSDaniel Colascione return inode;
131e7e832ceSDaniel Colascione }
1326d3c3ca4SVlastimil Babka EXPORT_SYMBOL_FOR_MODULES(anon_inode_make_secure_inode, "kvm");
133e7e832ceSDaniel Colascione
__anon_inode_getfile(const char * name,const struct file_operations * fops,void * priv,int flags,const struct inode * context_inode,bool make_inode)134e7e832ceSDaniel Colascione static struct file *__anon_inode_getfile(const char *name,
135e7e832ceSDaniel Colascione const struct file_operations *fops,
136e7e832ceSDaniel Colascione void *priv, int flags,
137e7e832ceSDaniel Colascione const struct inode *context_inode,
1384f0b9194SPaolo Bonzini bool make_inode)
139e7e832ceSDaniel Colascione {
140e7e832ceSDaniel Colascione struct inode *inode;
141e7e832ceSDaniel Colascione struct file *file;
142e7e832ceSDaniel Colascione
143e7e832ceSDaniel Colascione if (fops->owner && !try_module_get(fops->owner))
144e7e832ceSDaniel Colascione return ERR_PTR(-ENOENT);
145e7e832ceSDaniel Colascione
1464f0b9194SPaolo Bonzini if (make_inode) {
147cbe4134eSShivank Garg inode = anon_inode_make_secure_inode(anon_inode_mnt->mnt_sb,
148cbe4134eSShivank Garg name, context_inode);
149e7e832ceSDaniel Colascione if (IS_ERR(inode)) {
150e7e832ceSDaniel Colascione file = ERR_CAST(inode);
151e7e832ceSDaniel Colascione goto err;
152e7e832ceSDaniel Colascione }
153e7e832ceSDaniel Colascione } else {
154e7e832ceSDaniel Colascione inode = anon_inode_inode;
155e7e832ceSDaniel Colascione if (IS_ERR(inode)) {
156e7e832ceSDaniel Colascione file = ERR_PTR(-ENODEV);
157e7e832ceSDaniel Colascione goto err;
158e7e832ceSDaniel Colascione }
159e7e832ceSDaniel Colascione /*
160e7e832ceSDaniel Colascione * We know the anon_inode inode count is always
161e7e832ceSDaniel Colascione * greater than zero, so ihold() is safe.
162e7e832ceSDaniel Colascione */
163e7e832ceSDaniel Colascione ihold(inode);
164e7e832ceSDaniel Colascione }
165e7e832ceSDaniel Colascione
166e7e832ceSDaniel Colascione file = alloc_file_pseudo(inode, anon_inode_mnt, name,
167e7e832ceSDaniel Colascione flags & (O_ACCMODE | O_NONBLOCK), fops);
168e7e832ceSDaniel Colascione if (IS_ERR(file))
169e7e832ceSDaniel Colascione goto err_iput;
170e7e832ceSDaniel Colascione
171e7e832ceSDaniel Colascione file->f_mapping = inode->i_mapping;
172e7e832ceSDaniel Colascione
173e7e832ceSDaniel Colascione file->private_data = priv;
174e7e832ceSDaniel Colascione
175e7e832ceSDaniel Colascione return file;
176e7e832ceSDaniel Colascione
177e7e832ceSDaniel Colascione err_iput:
178e7e832ceSDaniel Colascione iput(inode);
179e7e832ceSDaniel Colascione err:
180e7e832ceSDaniel Colascione module_put(fops->owner);
181e7e832ceSDaniel Colascione return file;
182e7e832ceSDaniel Colascione }
183e7e832ceSDaniel Colascione
1845dc8bf81SDavide Libenzi /**
185c0d8768aSNamhyung Kim * anon_inode_getfile - creates a new file instance by hooking it up to an
1865dc8bf81SDavide Libenzi * anonymous inode, and a dentry that describe the "class"
1875dc8bf81SDavide Libenzi * of the file
1885dc8bf81SDavide Libenzi *
1895dc8bf81SDavide Libenzi * @name: [in] name of the "class" of the new file
1907d9dbca3SUlrich Drepper * @fops: [in] file operations for the new file
1917d9dbca3SUlrich Drepper * @priv: [in] private data for the new file (will be file's private_data)
1927d9dbca3SUlrich Drepper * @flags: [in] flags
1935dc8bf81SDavide Libenzi *
1945dc8bf81SDavide Libenzi * Creates a new file by hooking it on a single inode. This is useful for files
1955dc8bf81SDavide Libenzi * that do not need to have a full-fledged inode in order to operate correctly.
196562787a5SDavide Libenzi * All the files created with anon_inode_getfile() will share a single inode,
1975dc8bf81SDavide Libenzi * hence saving memory and avoiding code duplication for the file/inode/dentry
198562787a5SDavide Libenzi * setup. Returns the newly created file* or an error pointer.
1995dc8bf81SDavide Libenzi */
anon_inode_getfile(const char * name,const struct file_operations * fops,void * priv,int flags)200562787a5SDavide Libenzi struct file *anon_inode_getfile(const char *name,
201562787a5SDavide Libenzi const struct file_operations *fops,
2027d9dbca3SUlrich Drepper void *priv, int flags)
2035dc8bf81SDavide Libenzi {
204e7e832ceSDaniel Colascione return __anon_inode_getfile(name, fops, priv, flags, NULL, false);
205562787a5SDavide Libenzi }
206562787a5SDavide Libenzi EXPORT_SYMBOL_GPL(anon_inode_getfile);
207562787a5SDavide Libenzi
2083a862cacSPaul Moore /**
20955394d29SDawid Osuchowski * anon_inode_getfile_fmode - creates a new file instance by hooking it up to an
21055394d29SDawid Osuchowski * anonymous inode, and a dentry that describe the "class"
21155394d29SDawid Osuchowski * of the file
21255394d29SDawid Osuchowski *
21355394d29SDawid Osuchowski * @name: [in] name of the "class" of the new file
21455394d29SDawid Osuchowski * @fops: [in] file operations for the new file
21555394d29SDawid Osuchowski * @priv: [in] private data for the new file (will be file's private_data)
21655394d29SDawid Osuchowski * @flags: [in] flags
21755394d29SDawid Osuchowski * @f_mode: [in] fmode
21855394d29SDawid Osuchowski *
21955394d29SDawid Osuchowski * Creates a new file by hooking it on a single inode. This is useful for files
22055394d29SDawid Osuchowski * that do not need to have a full-fledged inode in order to operate correctly.
22155394d29SDawid Osuchowski * All the files created with anon_inode_getfile() will share a single inode,
22255394d29SDawid Osuchowski * hence saving memory and avoiding code duplication for the file/inode/dentry
22355394d29SDawid Osuchowski * setup. Allows setting the fmode. Returns the newly created file* or an error
22455394d29SDawid Osuchowski * pointer.
22555394d29SDawid Osuchowski */
anon_inode_getfile_fmode(const char * name,const struct file_operations * fops,void * priv,int flags,fmode_t f_mode)22655394d29SDawid Osuchowski struct file *anon_inode_getfile_fmode(const char *name,
22755394d29SDawid Osuchowski const struct file_operations *fops,
22855394d29SDawid Osuchowski void *priv, int flags, fmode_t f_mode)
22955394d29SDawid Osuchowski {
23055394d29SDawid Osuchowski struct file *file;
23155394d29SDawid Osuchowski
23255394d29SDawid Osuchowski file = __anon_inode_getfile(name, fops, priv, flags, NULL, false);
23355394d29SDawid Osuchowski if (!IS_ERR(file))
23455394d29SDawid Osuchowski file->f_mode |= f_mode;
23555394d29SDawid Osuchowski
23655394d29SDawid Osuchowski return file;
23755394d29SDawid Osuchowski }
23855394d29SDawid Osuchowski EXPORT_SYMBOL_GPL(anon_inode_getfile_fmode);
23955394d29SDawid Osuchowski
24055394d29SDawid Osuchowski /**
2414f0b9194SPaolo Bonzini * anon_inode_create_getfile - Like anon_inode_getfile(), but creates a new
2423a862cacSPaul Moore * !S_PRIVATE anon inode rather than reuse the
2433a862cacSPaul Moore * singleton anon inode and calls the
2444f0b9194SPaolo Bonzini * inode_init_security_anon() LSM hook.
2453a862cacSPaul Moore *
2463a862cacSPaul Moore * @name: [in] name of the "class" of the new file
2473a862cacSPaul Moore * @fops: [in] file operations for the new file
2483a862cacSPaul Moore * @priv: [in] private data for the new file (will be file's private_data)
2493a862cacSPaul Moore * @flags: [in] flags
2503a862cacSPaul Moore * @context_inode:
2513a862cacSPaul Moore * [in] the logical relationship with the new inode (optional)
2523a862cacSPaul Moore *
2534f0b9194SPaolo Bonzini * Create a new anonymous inode and file pair. This can be done for two
2544f0b9194SPaolo Bonzini * reasons:
2554f0b9194SPaolo Bonzini *
2564f0b9194SPaolo Bonzini * - for the inode to have its own security context, so that LSMs can enforce
2574f0b9194SPaolo Bonzini * policy on the inode's creation;
2584f0b9194SPaolo Bonzini *
2594f0b9194SPaolo Bonzini * - if the caller needs a unique inode, for example in order to customize
2604f0b9194SPaolo Bonzini * the size returned by fstat()
2614f0b9194SPaolo Bonzini *
2623a862cacSPaul Moore * The LSM may use @context_inode in inode_init_security_anon(), but a
2634f0b9194SPaolo Bonzini * reference to it is not held.
2644f0b9194SPaolo Bonzini *
2654f0b9194SPaolo Bonzini * Returns the newly created file* or an error pointer.
2663a862cacSPaul Moore */
anon_inode_create_getfile(const char * name,const struct file_operations * fops,void * priv,int flags,const struct inode * context_inode)2674f0b9194SPaolo Bonzini struct file *anon_inode_create_getfile(const char *name,
2683a862cacSPaul Moore const struct file_operations *fops,
2693a862cacSPaul Moore void *priv, int flags,
2703a862cacSPaul Moore const struct inode *context_inode)
2713a862cacSPaul Moore {
2723a862cacSPaul Moore return __anon_inode_getfile(name, fops, priv, flags,
2733a862cacSPaul Moore context_inode, true);
2743a862cacSPaul Moore }
275a7800aa8SSean Christopherson EXPORT_SYMBOL_GPL(anon_inode_create_getfile);
2763a862cacSPaul Moore
__anon_inode_getfd(const char * name,const struct file_operations * fops,void * priv,int flags,const struct inode * context_inode,bool make_inode)277e7e832ceSDaniel Colascione static int __anon_inode_getfd(const char *name,
278e7e832ceSDaniel Colascione const struct file_operations *fops,
279e7e832ceSDaniel Colascione void *priv, int flags,
280e7e832ceSDaniel Colascione const struct inode *context_inode,
2814f0b9194SPaolo Bonzini bool make_inode)
282562787a5SDavide Libenzi {
283*8797dd56SChristian Brauner return FD_ADD(flags, __anon_inode_getfile(name, fops, priv, flags,
284*8797dd56SChristian Brauner context_inode, make_inode));
2855dc8bf81SDavide Libenzi }
286e7e832ceSDaniel Colascione
287e7e832ceSDaniel Colascione /**
288e7e832ceSDaniel Colascione * anon_inode_getfd - creates a new file instance by hooking it up to
289e7e832ceSDaniel Colascione * an anonymous inode and a dentry that describe
290e7e832ceSDaniel Colascione * the "class" of the file
291e7e832ceSDaniel Colascione *
292e7e832ceSDaniel Colascione * @name: [in] name of the "class" of the new file
293e7e832ceSDaniel Colascione * @fops: [in] file operations for the new file
294e7e832ceSDaniel Colascione * @priv: [in] private data for the new file (will be file's private_data)
295e7e832ceSDaniel Colascione * @flags: [in] flags
296e7e832ceSDaniel Colascione *
297e7e832ceSDaniel Colascione * Creates a new file by hooking it on a single inode. This is
298e7e832ceSDaniel Colascione * useful for files that do not need to have a full-fledged inode in
299e7e832ceSDaniel Colascione * order to operate correctly. All the files created with
300e7e832ceSDaniel Colascione * anon_inode_getfd() will use the same singleton inode, reducing
301e7e832ceSDaniel Colascione * memory use and avoiding code duplication for the file/inode/dentry
302e7e832ceSDaniel Colascione * setup. Returns a newly created file descriptor or an error code.
303e7e832ceSDaniel Colascione */
anon_inode_getfd(const char * name,const struct file_operations * fops,void * priv,int flags)304e7e832ceSDaniel Colascione int anon_inode_getfd(const char *name, const struct file_operations *fops,
305e7e832ceSDaniel Colascione void *priv, int flags)
306e7e832ceSDaniel Colascione {
307e7e832ceSDaniel Colascione return __anon_inode_getfd(name, fops, priv, flags, NULL, false);
308e7e832ceSDaniel Colascione }
309d6d28168SAvi Kivity EXPORT_SYMBOL_GPL(anon_inode_getfd);
3105dc8bf81SDavide Libenzi
311e7e832ceSDaniel Colascione /**
3124f0b9194SPaolo Bonzini * anon_inode_create_getfd - Like anon_inode_getfd(), but creates a new
313365982abSLukas Bulwahn * !S_PRIVATE anon inode rather than reuse the singleton anon inode, and calls
3144f0b9194SPaolo Bonzini * the inode_init_security_anon() LSM hook.
315365982abSLukas Bulwahn *
316365982abSLukas Bulwahn * @name: [in] name of the "class" of the new file
317365982abSLukas Bulwahn * @fops: [in] file operations for the new file
318365982abSLukas Bulwahn * @priv: [in] private data for the new file (will be file's private_data)
319365982abSLukas Bulwahn * @flags: [in] flags
320365982abSLukas Bulwahn * @context_inode:
321365982abSLukas Bulwahn * [in] the logical relationship with the new inode (optional)
322365982abSLukas Bulwahn *
3234f0b9194SPaolo Bonzini * Create a new anonymous inode and file pair. This can be done for two
3244f0b9194SPaolo Bonzini * reasons:
3254f0b9194SPaolo Bonzini *
3264f0b9194SPaolo Bonzini * - for the inode to have its own security context, so that LSMs can enforce
3274f0b9194SPaolo Bonzini * policy on the inode's creation;
3284f0b9194SPaolo Bonzini *
3294f0b9194SPaolo Bonzini * - if the caller needs a unique inode, for example in order to customize
3304f0b9194SPaolo Bonzini * the size returned by fstat()
3314f0b9194SPaolo Bonzini *
332365982abSLukas Bulwahn * The LSM may use @context_inode in inode_init_security_anon(), but a
333365982abSLukas Bulwahn * reference to it is not held.
3344f0b9194SPaolo Bonzini *
3354f0b9194SPaolo Bonzini * Returns a newly created file descriptor or an error code.
336e7e832ceSDaniel Colascione */
anon_inode_create_getfd(const char * name,const struct file_operations * fops,void * priv,int flags,const struct inode * context_inode)3374f0b9194SPaolo Bonzini int anon_inode_create_getfd(const char *name, const struct file_operations *fops,
338e7e832ceSDaniel Colascione void *priv, int flags,
339e7e832ceSDaniel Colascione const struct inode *context_inode)
340e7e832ceSDaniel Colascione {
341e7e832ceSDaniel Colascione return __anon_inode_getfd(name, fops, priv, flags, context_inode, true);
342e7e832ceSDaniel Colascione }
343e7e832ceSDaniel Colascione
34455394d29SDawid Osuchowski
anon_inode_init(void)3455dc8bf81SDavide Libenzi static int __init anon_inode_init(void)
3465dc8bf81SDavide Libenzi {
3475dc8bf81SDavide Libenzi anon_inode_mnt = kern_mount(&anon_inode_fs_type);
34875c5a52dSJan Kara if (IS_ERR(anon_inode_mnt))
34975c5a52dSJan Kara panic("anon_inode_init() kernel mount failed (%ld)\n", PTR_ERR(anon_inode_mnt));
3505dc8bf81SDavide Libenzi
35175c5a52dSJan Kara anon_inode_inode = alloc_anon_inode(anon_inode_mnt->mnt_sb);
35275c5a52dSJan Kara if (IS_ERR(anon_inode_inode))
35375c5a52dSJan Kara panic("anon_inode_init() inode allocation failed (%ld)\n", PTR_ERR(anon_inode_inode));
354cfd86ef7SChristian Brauner anon_inode_inode->i_op = &anon_inode_operations;
35575c5a52dSJan Kara
35675c5a52dSJan Kara return 0;
3575dc8bf81SDavide Libenzi }
3585dc8bf81SDavide Libenzi
3595dc8bf81SDavide Libenzi fs_initcall(anon_inode_init);
3605dc8bf81SDavide Libenzi
361