From 44d450890f43502cea21e0460dab7ae3bed810d9 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 19 Jul 2019 18:39:04 -0400 Subject: [PATCH] LU-8066 obd: harden debugfs handling 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. Change-Id: I28614994e8ec29f360ab534534a5869b0bf60d4b Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/35575 Tested-by: jenkins Reviewed-by: Arshad Hussain Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- lustre/include/lprocfs_status.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index efb56e2..92b4cac 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -690,6 +690,8 @@ static const struct file_operations name##_fops = { \ #define LDEBUGFS_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_##type##_seq_show(m, m->private); \ } \ LDEBUGFS_SEQ_FOPS_RO(name##_##type) @@ -697,6 +699,8 @@ static const struct file_operations name##_fops = { \ #define LDEBUGFS_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_##type##_seq_show(m, m->private); \ } \ static ssize_t name##_##type##_seq_write(struct file *file, \ @@ -704,6 +708,9 @@ static const struct file_operations name##_fops = { \ loff_t *off) \ { \ struct seq_file *seq = file->private_data; \ + \ + if (!seq->private) \ + return -ENODEV; \ return ldebugfs_##type##_seq_write(file, buffer, count, \ seq->private); \ } \ -- 1.8.3.1