Whamcloud - gitweb
LU-2511 procfs: Disallow secretly (un)writable proc entries
authorJohn L. Hammond <jhammond@tacc.utexas.edu>
Wed, 19 Dec 2012 22:54:31 +0000 (16:54 -0600)
committerOleg Drokin <green@whamcloud.com>
Mon, 21 Jan 2013 18:58:12 +0000 (13:58 -0500)
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 <jhammond@tacc.utexas.edu>
Change-Id: I95d08106f7d9be478c29d7331cdf5ab607435889
Reviewed-on: http://review.whamcloud.com/4871
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_lproc.c
lustre/mgs/lproc_mgs.c
lustre/obdclass/lprocfs_status.c
lustre/ofd/lproc_ofd.c
lustre/osc/lproc_osc.c
lustre/osd-ldiskfs/osd_lproc.c

index 613bcfd..1560ec1 100644 (file)
@@ -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);
 }
 
index 06b8396..7020470 100644 (file)
@@ -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;
 }
index 1fb65be..1d02f7a 100644 (file)
@@ -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) {
index 5a71de9..68b09ce 100644 (file)
@@ -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);
 }
 
index 82a1a0c..cf472d1 100644 (file)
@@ -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)
index 045060e..e3539a8 100644 (file)
@@ -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;