Re: [PATCH] kernel: sysctl: make drop_caches write-only

From: Andrew Morton
Date: Thu Oct 31 2019 - 19:28:28 EST


On Thu, 31 Oct 2019 18:16:02 -0400 Johannes Weiner <hannes@xxxxxxxxxxx> wrote:

> Currently, the drop_caches proc file and sysctl read back the last
> value written, suggesting this is somehow a stateful setting instead
> of a one-time command. Make it write-only, like e.g. compact_memory.
>
> ...
>
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1474,7 +1474,7 @@ static struct ctl_table vm_table[] = {
> .procname = "drop_caches",
> .data = &sysctl_drop_caches,
> .maxlen = sizeof(int),
> - .mode = 0644,
> + .mode = 0200,
> .proc_handler = drop_caches_sysctl_handler,
> .extra1 = SYSCTL_ONE,
> .extra2 = &four,

hm.

Risk: some (odd) userspace code will break. Fixable by manually chmodding
it back again.

Reward: very little.

Is the reward worth the risk?