From: John L. Hammond Date: Wed, 19 Dec 2012 22:54:31 +0000 (-0600) Subject: LU-2511 procfs: Disallow secretly (un)writable proc entries X-Git-Tag: 2.3.60~59 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a5450f57fe530b706d7a1149a35906601f00cb44 LU-2511 procfs: Disallow secretly (un)writable proc entries Add an assert to lprocfs_seq_create() to ensure that proc entries implementing write have user writable modes. Fix a few callers to pass this assertion. Signed-off-by: John L. Hammond Change-Id: I95d08106f7d9be478c29d7331cdf5ab607435889 Reviewed-on: http://review.whamcloud.com/4871 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 613bcfd..1560ec11 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -169,7 +169,7 @@ static int lproc_mdt_attach_rename_seqstat(struct mdt_device *mdt) for (i = 0; i < RENAME_LAST; i++) spin_lock_init(&mdt->mdt_rename_stats.hist[i].oh_lock); - return lprocfs_obd_seq_create(obd, "rename_stats", 0444, + return lprocfs_obd_seq_create(obd, "rename_stats", 0644, &mdt_rename_stats_fops, mdt); } diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 06b8396..7020470 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -154,8 +154,8 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, &mgs_fs_fops, obd); - rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0600, - &mgsself_srpc_fops, obd); + rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400, + &mgsself_srpc_fops, obd); mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry, NULL, NULL); @@ -282,8 +282,8 @@ int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) if (!mgs->mgs_proc_live) return 0; - rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444, - &mgs_live_fops, fsdb); + rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, + &mgs_live_fops, fsdb); return 0; } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 1fb65be..1d02f7a 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -2343,6 +2343,9 @@ int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, struct proc_dir_entry *entry; ENTRY; + /* Disallow secretly (un)writable entries. */ + LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); + LPROCFS_WRITE_ENTRY(); entry = create_proc_entry(name, mode, parent); if (entry) { diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index 5a71de9..68b09ce 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -622,7 +622,7 @@ LPROC_SEQ_FOPS(ofd_brw_stats); int lproc_ofd_attach_seqstat(struct obd_device *dev) { - return lprocfs_obd_seq_create(dev, "brw_stats", 0444, + return lprocfs_obd_seq_create(dev, "brw_stats", 0644, &ofd_brw_stats_fops, dev); } diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 82a1a0c..cf472d1 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -693,14 +693,15 @@ LPROC_SEQ_FOPS(osc_stats); int lproc_osc_attach_seqstat(struct obd_device *dev) { - int rc; + int rc; - rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0444, - &osc_stats_fops, dev); - if (rc == 0) - rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0444, - &osc_rpc_stats_fops, dev); - return rc; + rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644, + &osc_stats_fops, dev); + if (rc == 0) + rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, + &osc_rpc_stats_fops, dev); + + return rc; } void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index 045060e..e3539a8 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -228,8 +228,8 @@ static int osd_stats_init(struct osd_device *osd) LPROCFS_CNTR_AVGMINMAX, "thandle closing", "usec"); #endif - lprocfs_seq_create(osd->od_proc_entry, "brw_stats", - 0444, &osd_brw_stats_fops, osd); + lprocfs_seq_create(osd->od_proc_entry, "brw_stats", + 0644, &osd_brw_stats_fops, osd); } else result = -ENOMEM;