Skip to contentSkip to conversation

rcu: module param kthread_prio should set to read-only under sysfs

PATCH Paul E. McKenney 1 participant 1 message Feb 21, 2019 1 message not in the archive RCU

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 20 lines · Liu Song

kthread_prio used to set prio for boost thread which spawn at the very beginning. We can see kthread_prio under sysfs, and it could be set to a new value. But boost thread's prio can not updated by this opreation. However, user can change boost thread prio by chrt.

We better make kthread_prio read-only under sysfs, which can avoid user invalid operation.

---
 kernel/rcu/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +0 -0
index 121f833acd04..38faef424a99 100644

kernel/rcu/tree.c static void sync_sched_exp_online_cleanup(int cpu); · line 162

Quoted 7 lines
kernel/rcu/tree.c +1 -1
@@ -157,7 +157,7 @@ static void sync_sched_exp_online_cleanup(int cpu);
 
 /* rcuc/rcub kthread realtime priority */
 static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
-module_param(kthread_prio, int, 0644);
+module_param(kthread_prio, int, 0444);
 
 /* Delay in jiffies for grace-period initialization delays, debug only. */

Good catch! I applied this with the commit log updated as shown below. Please let me know if I messed anything up.

Thanx, Paul

------------------------------------------------------------------------

commit c6e26d5eaa5794ae32b38cb1ced9495b07af4ff5

Author: Liu Song <[email protected]>
Date:   Thu Feb 21 22:13:27 2019 +0800

rcu: Set rcutree.kthread_prio sysfs access to read-only

The rcutree.kthread_prio kernel-boot parameter is used to set the priority for boost (rcub), per-CPU (rcuc), and grace-period (rcu_preempt or rcu_sched) kthreads. It is also used by rcutorture to check whether it is possible to meaningfully test RCU priority boosting. However, all of these cases will either ignore or be confused by any post-boot changes to rcutree.kthread_prio.

Note that the user really can change the priorities of all of these kthreads using chrt, given sufficient privileges. Therefore, the read-write nature of sysfs access to rcutree.kthread_prio is thus at best an attractive nuisance.

This commit therefore changes sysfs access to rcutree.kthread_prio to be read-only.

kernel/rcu/tree.c +1 -1
index 24b07cf84161..7273ef0c278d 100644
@@ -143,7 +143,7 @@ static void sync_sched_exp_online_cleanup(int cpu);
 
 /* rcuc/rcub kthread realtime priority */
 static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0;
-module_param(kthread_prio, int, 0644);
+module_param(kthread_prio, int, 0444);
 
 /* Delay in jiffies for grace-period initialization delays, debug only. */