[lustre-devel] [PATCH 409/622] lustre: obd: harden debugfs handling
James Simmons
jsimmons at infradead.org
Thu Feb 27 13:14:37 PST 2020
While the seq_file private data shouldn't disappear from under
us just in case always test if the private field is set. If
not return -ENODEV for debugfs read and write operations.
WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Lustre-commit: 44d450890f43 ("LU-8066 obd: harden debugfs handling")
Signed-off-by: James Simmons <uja.ornl at yahoo.com>
Reviewed-on: https://review.whamcloud.com/35575
Reviewed-by: Arshad Hussain <arshad.super at gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz at whamcloud.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/include/lprocfs_status.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/lustre/include/lprocfs_status.h b/fs/lustre/include/lprocfs_status.h
index 6269bd3..fdc1b19 100644
--- a/fs/lustre/include/lprocfs_status.h
+++ b/fs/lustre/include/lprocfs_status.h
@@ -519,6 +519,8 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
#define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
static int name##_##type##_seq_show(struct seq_file *m, void *v)\
{ \
+ if (!m->private) \
+ return -ENODEV; \
return lprocfs_rd_##type(m, m->private); \
} \
LPROC_SEQ_FOPS_RO(name##_##type)
@@ -526,6 +528,8 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
#define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
static int name##_##type##_seq_show(struct seq_file *m, void *v)\
{ \
+ if (!m->private) \
+ return -ENODEV; \
return lprocfs_rd_##type(m, m->private); \
} \
static ssize_t name##_##type##_seq_write(struct file *file, \
@@ -533,6 +537,9 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
loff_t *off) \
{ \
struct seq_file *seq = file->private_data; \
+ \
+ if (!seq->private) \
+ return -ENODEV; \
return lprocfs_wr_##type(file, buffer, \
count, seq->private); \
} \
--
1.8.3.1
More information about the lustre-devel
mailing list