aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs/file.c
diff options
context:
space:
mode:
authorNicolai Stange <nicstange@gmail.com>2017-10-30 19:15:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-07 14:25:02 -0500
commitc9afbec27089cd6b4e621b639f41c7fc726c3bf1 (patch)
treebb66d582f6668101cdbca5e6a3592f2398271443 /fs/debugfs/file.c
parent7cda7b8f97da9382bb945d541a85cde58d5dac27 (diff)
debugfs: purge obsolete SRCU based removal protection
Purge the SRCU based file removal race protection in favour of the new, refcount based debugfs_file_get()/debugfs_file_put() API. Fixes: 49d200deaa68 ("debugfs: prevent access to removed files' private data") Signed-off-by: Nicolai Stange <nicstange@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/debugfs/file.c')
-rw-r--r--fs/debugfs/file.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index d3a972b45ff0..53f5c9a2af88 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -22,7 +22,6 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/atomic.h> 23#include <linux/atomic.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/srcu.h>
26#include <asm/poll.h> 25#include <asm/poll.h>
27 26
28#include "internal.h" 27#include "internal.h"
@@ -48,53 +47,6 @@ const struct file_operations debugfs_noop_file_operations = {
48 .llseek = noop_llseek, 47 .llseek = noop_llseek,
49}; 48};
50 49
51/**
52 * debugfs_use_file_start - mark the beginning of file data access
53 * @dentry: the dentry object whose data is being accessed.
54 * @srcu_idx: a pointer to some memory to store a SRCU index in.
55 *
56 * Up to a matching call to debugfs_use_file_finish(), any
57 * successive call into the file removing functions debugfs_remove()
58 * and debugfs_remove_recursive() will block. Since associated private
59 * file data may only get freed after a successful return of any of
60 * the removal functions, you may safely access it after a successful
61 * call to debugfs_use_file_start() without worrying about
62 * lifetime issues.
63 *
64 * If -%EIO is returned, the file has already been removed and thus,
65 * it is not safe to access any of its data. If, on the other hand,
66 * it is allowed to access the file data, zero is returned.
67 *
68 * Regardless of the return code, any call to
69 * debugfs_use_file_start() must be followed by a matching call
70 * to debugfs_use_file_finish().
71 */
72int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx)
73 __acquires(&debugfs_srcu)
74{
75 *srcu_idx = srcu_read_lock(&debugfs_srcu);
76 barrier();
77 if (d_unlinked(dentry))
78 return -EIO;
79 return 0;
80}
81EXPORT_SYMBOL_GPL(debugfs_use_file_start);
82
83/**
84 * debugfs_use_file_finish - mark the end of file data access
85 * @srcu_idx: the SRCU index "created" by a former call to
86 * debugfs_use_file_start().
87 *
88 * Allow any ongoing concurrent call into debugfs_remove() or
89 * debugfs_remove_recursive() blocked by a former call to
90 * debugfs_use_file_start() to proceed and return to its caller.
91 */
92void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu)
93{
94 srcu_read_unlock(&debugfs_srcu, srcu_idx);
95}
96EXPORT_SYMBOL_GPL(debugfs_use_file_finish);
97
98#define F_DENTRY(filp) ((filp)->f_path.dentry) 50#define F_DENTRY(filp) ((filp)->f_path.dentry)
99 51
100const struct file_operations *debugfs_real_fops(const struct file *filp) 52const struct file_operations *debugfs_real_fops(const struct file *filp)