blob: b3140deebbbf691f524d38b62b88ef44a76bf083 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Ingo Molnar3f07c012017-02-08 18:51:30 +01002#include <linux/sched/signal.h>
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +04003#include <linux/errno.h>
4#include <linux/dcache.h>
5#include <linux/path.h>
6#include <linux/fdtable.h>
7#include <linux/namei.h>
8#include <linux/pid.h>
Kalesh Singh7bc3fa02021-06-30 18:54:44 -07009#include <linux/ptrace.h>
Ivan Babrouf1f1f252022-09-22 15:40:26 -070010#include <linux/bitmap.h>
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040011#include <linux/security.h>
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040012#include <linux/file.h>
13#include <linux/seq_file.h>
Andrey Vagin6c8c9032015-04-16 12:49:38 -070014#include <linux/fs.h>
Jeff Layton5970e152022-11-20 09:15:34 -050015#include <linux/filelock.h>
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040016
17#include <linux/proc_fs.h>
18
Andrey Vagin49d063c2014-04-07 15:38:34 -070019#include "../mount.h"
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040020#include "internal.h"
21#include "fd.h"
22
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040023static int seq_show(struct seq_file *m, void *v)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040024{
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040025 struct files_struct *files = NULL;
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040026 int f_flags = 0, ret = -ENOENT;
27 struct file *file = NULL;
28 struct task_struct *task;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040029
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040030 task = get_proc_task(m->private);
31 if (!task)
32 return -ENOENT;
33
Eric W. Biederman775e0652020-11-20 17:14:34 -060034 task_lock(task);
35 files = task->files;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040036 if (files) {
Alexey Dobriyan771187d2016-09-02 00:42:02 +030037 unsigned int fd = proc_fd(m->private);
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040038
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040039 spin_lock(&files->file_lock);
Eric W. Biederman120ce2b2020-11-20 17:14:25 -060040 file = files_lookup_fd_locked(files, fd);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040041 if (file) {
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040042 struct fdtable *fdt = files_fdtable(files);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040043
Al Viroc6f3d812012-08-26 11:01:04 -040044 f_flags = file->f_flags;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040045 if (close_on_exec(fd, fdt))
46 f_flags |= O_CLOEXEC;
47
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040048 get_file(file);
49 ret = 0;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040050 }
51 spin_unlock(&files->file_lock);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040052 }
Eric W. Biederman775e0652020-11-20 17:14:34 -060053 task_unlock(task);
54 put_task_struct(task);
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040055
Andrey Vagin6c8c9032015-04-16 12:49:38 -070056 if (ret)
57 return ret;
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040058
Kalesh Singh3845f252021-06-30 18:54:49 -070059 seq_printf(m, "pos:\t%lli\nflags:\t0%o\nmnt_id:\t%i\nino:\t%lu\n",
Andrey Vagin6c8c9032015-04-16 12:49:38 -070060 (long long)file->f_pos, f_flags,
Kalesh Singh3845f252021-06-30 18:54:49 -070061 real_mount(file->f_path.mnt)->mnt_id,
62 file_inode(file)->i_ino);
Andrey Vagin6c8c9032015-04-16 12:49:38 -070063
Eric W. Biederman775e0652020-11-20 17:14:34 -060064 /* show_fd_locks() never deferences files so a stale value is safe */
Andrey Vagin6c8c9032015-04-16 12:49:38 -070065 show_fd_locks(m, file, files);
66 if (seq_has_overflowed(m))
67 goto out;
68
69 if (file->f_op->show_fdinfo)
70 file->f_op->show_fdinfo(m, file);
71
72out:
73 fput(file);
74 return 0;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +040075}
76
Kalesh Singh1927e492022-05-09 17:34:28 -070077static int proc_fdinfo_access_allowed(struct inode *inode)
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +040078{
Kalesh Singh7bc3fa02021-06-30 18:54:44 -070079 bool allowed = false;
80 struct task_struct *task = get_proc_task(inode);
81
82 if (!task)
83 return -ESRCH;
84
85 allowed = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS);
86 put_task_struct(task);
87
88 if (!allowed)
89 return -EACCES;
90
Kalesh Singh1927e492022-05-09 17:34:28 -070091 return 0;
92}
93
94static int seq_fdinfo_open(struct inode *inode, struct file *file)
95{
96 int ret = proc_fdinfo_access_allowed(inode);
97
98 if (ret)
99 return ret;
100
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400101 return single_open(file, seq_show, inode);
102}
103
104static const struct file_operations proc_fdinfo_file_operations = {
105 .open = seq_fdinfo_open,
106 .read = seq_read,
107 .llseek = seq_lseek,
108 .release = single_release,
109};
110
Al Viro1ae9bd82018-05-02 22:42:22 -0400111static bool tid_fd_mode(struct task_struct *task, unsigned fd, fmode_t *mode)
112{
Al Viro1ae9bd82018-05-02 22:42:22 -0400113 struct file *file;
114
Al Viro1ae9bd82018-05-02 22:42:22 -0400115 rcu_read_lock();
Eric W. Biederman64eb6612020-11-20 17:14:29 -0600116 file = task_lookup_fd_rcu(task, fd);
Al Viro1ae9bd82018-05-02 22:42:22 -0400117 if (file)
118 *mode = file->f_mode;
119 rcu_read_unlock();
Al Viro1ae9bd82018-05-02 22:42:22 -0400120 return !!file;
121}
122
Al Viro98836382018-05-03 09:00:33 -0400123static void tid_fd_update_inode(struct task_struct *task, struct inode *inode,
124 fmode_t f_mode)
125{
126 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid);
127
128 if (S_ISLNK(inode->i_mode)) {
129 unsigned i_mode = S_IFLNK;
130 if (f_mode & FMODE_READ)
131 i_mode |= S_IRUSR | S_IXUSR;
132 if (f_mode & FMODE_WRITE)
133 i_mode |= S_IWUSR | S_IXUSR;
134 inode->i_mode = i_mode;
135 }
136 security_task_to_inode(task, inode);
137}
138
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400139static int tid_fd_revalidate(struct dentry *dentry, unsigned int flags)
140{
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400141 struct task_struct *task;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400142 struct inode *inode;
Alexey Dobriyan771187d2016-09-02 00:42:02 +0300143 unsigned int fd;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400144
145 if (flags & LOOKUP_RCU)
146 return -ECHILD;
147
David Howells2b0143b2015-03-17 22:25:59 +0000148 inode = d_inode(dentry);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400149 task = get_proc_task(inode);
150 fd = proc_fd(inode);
151
152 if (task) {
Al Viro98836382018-05-03 09:00:33 -0400153 fmode_t f_mode;
Al Viro1ae9bd82018-05-02 22:42:22 -0400154 if (tid_fd_mode(task, fd, &f_mode)) {
Al Viro98836382018-05-03 09:00:33 -0400155 tid_fd_update_inode(task, inode, f_mode);
Al Viro1ae9bd82018-05-02 22:42:22 -0400156 put_task_struct(task);
157 return 1;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400158 }
159 put_task_struct(task);
160 }
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400161 return 0;
162}
163
164static const struct dentry_operations tid_fd_dentry_operations = {
165 .d_revalidate = tid_fd_revalidate,
166 .d_delete = pid_delete_dentry,
167};
168
169static int proc_fd_link(struct dentry *dentry, struct path *path)
170{
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400171 struct task_struct *task;
172 int ret = -ENOENT;
173
David Howells2b0143b2015-03-17 22:25:59 +0000174 task = get_proc_task(d_inode(dentry));
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400175 if (task) {
Alexey Dobriyan771187d2016-09-02 00:42:02 +0300176 unsigned int fd = proc_fd(d_inode(dentry));
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400177 struct file *fd_file;
178
Eric W. Biederman439be322020-11-20 17:14:23 -0600179 fd_file = fget_task(task, fd);
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400180 if (fd_file) {
181 *path = fd_file->f_path;
182 path_get(&fd_file->f_path);
183 ret = 0;
Eric W. Biederman439be322020-11-20 17:14:23 -0600184 fput(fd_file);
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400185 }
Eric W. Biederman439be322020-11-20 17:14:23 -0600186 put_task_struct(task);
Cyrill Gorcunovddd3e072012-08-26 18:28:20 +0400187 }
188
189 return ret;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400190}
191
Al Viro98836382018-05-03 09:00:33 -0400192struct fd_data {
193 fmode_t mode;
194 unsigned fd;
195};
196
Al Viro0168b9e2018-05-03 09:21:05 -0400197static struct dentry *proc_fd_instantiate(struct dentry *dentry,
198 struct task_struct *task, const void *ptr)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400199{
Al Viro98836382018-05-03 09:00:33 -0400200 const struct fd_data *data = ptr;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400201 struct proc_inode *ei;
202 struct inode *inode;
203
Al Viro0168b9e2018-05-03 09:21:05 -0400204 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400205 if (!inode)
Al Viro0168b9e2018-05-03 09:21:05 -0400206 return ERR_PTR(-ENOENT);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400207
208 ei = PROC_I(inode);
Al Viro98836382018-05-03 09:00:33 -0400209 ei->fd = data->fd;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400210
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400211 inode->i_op = &proc_pid_link_inode_operations;
212 inode->i_size = 64;
213
214 ei->op.proc_get_link = proc_fd_link;
Al Viro98836382018-05-03 09:00:33 -0400215 tid_fd_update_inode(task, inode, data->mode);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400216
217 d_set_d_op(dentry, &tid_fd_dentry_operations);
Al Viro0168b9e2018-05-03 09:21:05 -0400218 return d_splice_alias(inode, dentry);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400219}
220
221static struct dentry *proc_lookupfd_common(struct inode *dir,
222 struct dentry *dentry,
223 instantiate_t instantiate)
224{
225 struct task_struct *task = get_proc_task(dir);
Al Viro98836382018-05-03 09:00:33 -0400226 struct fd_data data = {.fd = name_to_int(&dentry->d_name)};
Al Viro0168b9e2018-05-03 09:21:05 -0400227 struct dentry *result = ERR_PTR(-ENOENT);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400228
229 if (!task)
230 goto out_no_task;
Al Viro98836382018-05-03 09:00:33 -0400231 if (data.fd == ~0U)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400232 goto out;
Al Viro98836382018-05-03 09:00:33 -0400233 if (!tid_fd_mode(task, data.fd, &data.mode))
Al Viro1ae9bd82018-05-02 22:42:22 -0400234 goto out;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400235
Al Viro0168b9e2018-05-03 09:21:05 -0400236 result = instantiate(dentry, task, &data);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400237out:
238 put_task_struct(task);
239out_no_task:
Al Viro0168b9e2018-05-03 09:21:05 -0400240 return result;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400241}
242
Al Virof0c3b502013-05-16 12:07:31 -0400243static int proc_readfd_common(struct file *file, struct dir_context *ctx,
244 instantiate_t instantiate)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400245{
Al Virof0c3b502013-05-16 12:07:31 -0400246 struct task_struct *p = get_proc_task(file_inode(file));
Al Virof0c3b502013-05-16 12:07:31 -0400247 unsigned int fd;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400248
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400249 if (!p)
Al Virof0c3b502013-05-16 12:07:31 -0400250 return -ENOENT;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400251
Al Virof0c3b502013-05-16 12:07:31 -0400252 if (!dir_emit_dots(file, ctx))
253 goto out;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400254
Al Virof0c3b502013-05-16 12:07:31 -0400255 rcu_read_lock();
Eric W. Biederman5b17b612020-11-20 17:14:32 -0600256 for (fd = ctx->pos - 2;; fd++) {
Al Viro98836382018-05-03 09:00:33 -0400257 struct file *f;
258 struct fd_data data;
Alexey Dobriyane3912ac2018-02-06 15:36:51 -0800259 char name[10 + 1];
Alexey Dobriyana4ef3892018-06-07 17:10:10 -0700260 unsigned int len;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400261
Eric W. Biederman5b17b612020-11-20 17:14:32 -0600262 f = task_lookup_next_fd_rcu(p, &fd);
263 ctx->pos = fd + 2LL;
Al Viro98836382018-05-03 09:00:33 -0400264 if (!f)
Eric W. Biederman5b17b612020-11-20 17:14:32 -0600265 break;
Al Viro98836382018-05-03 09:00:33 -0400266 data.mode = f->f_mode;
Al Virof0c3b502013-05-16 12:07:31 -0400267 rcu_read_unlock();
Al Viro98836382018-05-03 09:00:33 -0400268 data.fd = fd;
Al Virof0c3b502013-05-16 12:07:31 -0400269
Alexey Dobriyan771187d2016-09-02 00:42:02 +0300270 len = snprintf(name, sizeof(name), "%u", fd);
Al Virof0c3b502013-05-16 12:07:31 -0400271 if (!proc_fill_cache(file, ctx,
272 name, len, instantiate, p,
Al Viro98836382018-05-03 09:00:33 -0400273 &data))
Eric W. Biederman5b17b612020-11-20 17:14:32 -0600274 goto out;
Eric Dumazet3cc4a842015-12-03 11:12:07 -0800275 cond_resched();
Al Virof0c3b502013-05-16 12:07:31 -0400276 rcu_read_lock();
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400277 }
Al Virof0c3b502013-05-16 12:07:31 -0400278 rcu_read_unlock();
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400279out:
280 put_task_struct(p);
Al Virof0c3b502013-05-16 12:07:31 -0400281 return 0;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400282}
283
Ivan Babrouf1f1f252022-09-22 15:40:26 -0700284static int proc_readfd_count(struct inode *inode, loff_t *count)
285{
286 struct task_struct *p = get_proc_task(inode);
287 struct fdtable *fdt;
288
289 if (!p)
290 return -ENOENT;
291
292 task_lock(p);
293 if (p->files) {
294 rcu_read_lock();
295
296 fdt = files_fdtable(p->files);
297 *count = bitmap_weight(fdt->open_fds, fdt->max_fds);
298
299 rcu_read_unlock();
300 }
301 task_unlock(p);
302
303 put_task_struct(p);
304
305 return 0;
306}
307
Al Virof0c3b502013-05-16 12:07:31 -0400308static int proc_readfd(struct file *file, struct dir_context *ctx)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400309{
Al Virof0c3b502013-05-16 12:07:31 -0400310 return proc_readfd_common(file, ctx, proc_fd_instantiate);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400311}
312
313const struct file_operations proc_fd_operations = {
314 .read = generic_read_dir,
Al Virof50752e2016-04-20 17:13:54 -0400315 .iterate_shared = proc_readfd,
316 .llseek = generic_file_llseek,
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400317};
318
319static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
320 unsigned int flags)
321{
322 return proc_lookupfd_common(dir, dentry, proc_fd_instantiate);
323}
324
325/*
326 * /proc/pid/fd needs a special permission handler so that a process can still
327 * access /proc/self/fd after it has executed a setuid().
328 */
Christian Brauner4609e1f2023-01-13 12:49:22 +0100329int proc_fd_permission(struct mnt_idmap *idmap,
Christian Brauner549c7292021-01-21 14:19:43 +0100330 struct inode *inode, int mask)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400331{
Oleg Nesterov54708d22015-11-06 16:30:06 -0800332 struct task_struct *p;
333 int rv;
334
Christian Brauner4609e1f2023-01-13 12:49:22 +0100335 rv = generic_permission(&nop_mnt_idmap, inode, mask);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400336 if (rv == 0)
Oleg Nesterov54708d22015-11-06 16:30:06 -0800337 return rv;
338
339 rcu_read_lock();
340 p = pid_task(proc_pid(inode), PIDTYPE_PID);
341 if (p && same_thread_group(p, current))
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400342 rv = 0;
Oleg Nesterov54708d22015-11-06 16:30:06 -0800343 rcu_read_unlock();
344
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400345 return rv;
346}
347
Christian Braunerb74d24f2023-01-13 12:49:12 +0100348static int proc_fd_getattr(struct mnt_idmap *idmap,
Ivan Babrouf1f1f252022-09-22 15:40:26 -0700349 const struct path *path, struct kstat *stat,
350 u32 request_mask, unsigned int query_flags)
351{
352 struct inode *inode = d_inode(path->dentry);
353 int rv = 0;
354
Christian Braunerb74d24f2023-01-13 12:49:12 +0100355 generic_fillattr(&nop_mnt_idmap, inode, stat);
Ivan Babrouf1f1f252022-09-22 15:40:26 -0700356
357 /* If it's a directory, put the number of open fds there */
358 if (S_ISDIR(inode->i_mode)) {
359 rv = proc_readfd_count(inode, &stat->size);
360 if (rv < 0)
361 return rv;
362 }
363
364 return rv;
365}
366
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400367const struct inode_operations proc_fd_inode_operations = {
368 .lookup = proc_lookupfd,
369 .permission = proc_fd_permission,
Ivan Babrouf1f1f252022-09-22 15:40:26 -0700370 .getattr = proc_fd_getattr,
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400371 .setattr = proc_setattr,
372};
373
Al Viro0168b9e2018-05-03 09:21:05 -0400374static struct dentry *proc_fdinfo_instantiate(struct dentry *dentry,
375 struct task_struct *task, const void *ptr)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400376{
Al Viro98836382018-05-03 09:00:33 -0400377 const struct fd_data *data = ptr;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400378 struct proc_inode *ei;
379 struct inode *inode;
380
Kalesh Singh7bc3fa02021-06-30 18:54:44 -0700381 inode = proc_pid_make_inode(dentry->d_sb, task, S_IFREG | S_IRUGO);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400382 if (!inode)
Al Viro0168b9e2018-05-03 09:21:05 -0400383 return ERR_PTR(-ENOENT);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400384
385 ei = PROC_I(inode);
Al Viro98836382018-05-03 09:00:33 -0400386 ei->fd = data->fd;
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400387
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400388 inode->i_fop = &proc_fdinfo_file_operations;
Al Viro98836382018-05-03 09:00:33 -0400389 tid_fd_update_inode(task, inode, 0);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400390
391 d_set_d_op(dentry, &tid_fd_dentry_operations);
Al Viro0168b9e2018-05-03 09:21:05 -0400392 return d_splice_alias(inode, dentry);
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400393}
394
395static struct dentry *
396proc_lookupfdinfo(struct inode *dir, struct dentry *dentry, unsigned int flags)
397{
398 return proc_lookupfd_common(dir, dentry, proc_fdinfo_instantiate);
399}
400
Al Virof0c3b502013-05-16 12:07:31 -0400401static int proc_readfdinfo(struct file *file, struct dir_context *ctx)
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400402{
Al Virof0c3b502013-05-16 12:07:31 -0400403 return proc_readfd_common(file, ctx,
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400404 proc_fdinfo_instantiate);
405}
406
Kalesh Singh1927e492022-05-09 17:34:28 -0700407static int proc_open_fdinfo(struct inode *inode, struct file *file)
408{
409 int ret = proc_fdinfo_access_allowed(inode);
410
411 if (ret)
412 return ret;
413
414 return 0;
415}
416
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400417const struct inode_operations proc_fdinfo_inode_operations = {
418 .lookup = proc_lookupfdinfo,
419 .setattr = proc_setattr,
420};
421
422const struct file_operations proc_fdinfo_operations = {
Kalesh Singh1927e492022-05-09 17:34:28 -0700423 .open = proc_open_fdinfo,
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400424 .read = generic_read_dir,
Al Virof50752e2016-04-20 17:13:54 -0400425 .iterate_shared = proc_readfdinfo,
426 .llseek = generic_file_llseek,
Cyrill Gorcunovfaf60af2012-08-23 14:43:24 +0400427};