Re: [PATCH] rcu: module param kthread_prio should set to read-only under sysfs
From: Paul E. McKenney
Date: Thu Feb 21 2019 - 10:46:11 EST
On Thu, Feb 21, 2019 at 10:13:27PM +0800, Liu Song wrote:
> 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.
>
> Signed-off-by: Liu Song <liu.song11@xxxxxxxxxx>
> ---
> kernel/rcu/tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 121f833acd04..38faef424a99 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -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 <fishland@xxxxxxxxxx>
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.
Signed-off-by: Liu Song <liu.song11@xxxxxxxxxx>
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxx>
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 24b07cf84161..7273ef0c278d 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -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. */