ANDROID: sched/debug: Make Energy Model read-only
authorChris Redpath <chris.redpath@arm.com>
Wed, 21 Nov 2018 20:38:47 +0000 (20:38 +0000)
committerTodd Kjos <tkjos@google.com>
Wed, 21 Nov 2018 21:27:48 +0000 (21:27 +0000)
The energy model is exposed through the sched_domain entry in
/proc/sys/kernel. This option only appears when SCHED_DEBUG is
enabled, and is only writeable by the owner (root).

Various userspace tools may read the energy model, including
LISA (which uses it to brute-force calculate optimal energy
placement for synthetic tasks), but none change it.

Since there is no known use case for changing the energy model,
change these procfs nodes to be read-only instead. This removes
the need to add validation for values written into these files.

Bug: 118694140
Change-Id: Ie997b5c4c9e751b21cc94d82b2b8b99640c524fa
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
kernel/sched/debug.c

index 4e75fda646c06ba6f2b39189b729888abc6b0072..5b0e1d785be64fe0ab41dda5a61c9b3102df3af6 100644 (file)
@@ -275,14 +275,14 @@ sd_alloc_ctl_energy_table(struct sched_group_energy *sge)
                return NULL;
 
        set_table_entry(&table[0], "nr_idle_states", &sge->nr_idle_states,
-                       sizeof(int), 0644, proc_dointvec_minmax, false);
+                       sizeof(int), 0444, proc_dointvec_minmax, false);
        set_table_entry(&table[1], "idle_states", &sge->idle_states[0].power,
-                       sge->nr_idle_states*sizeof(struct idle_state), 0644,
+                       sge->nr_idle_states*sizeof(struct idle_state), 0444,
                        proc_doulongvec_minmax, false);
        set_table_entry(&table[2], "nr_cap_states", &sge->nr_cap_states,
-                       sizeof(int), 0644, proc_dointvec_minmax, false);
+                       sizeof(int), 0444, proc_dointvec_minmax, false);
        set_table_entry(&table[3], "cap_states", &sge->cap_states[0].cap,
-                       sge->nr_cap_states*sizeof(struct capacity_state), 0644,
+                       sge->nr_cap_states*sizeof(struct capacity_state), 0444,
                        proc_doulongvec_minmax, false);
 
        return table;