]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
sysctl: Indicate the direction of operation with macro names
authorJoel Granados <joel.granados@kernel.org>
Fri, 3 Oct 2025 12:07:18 +0000 (14:07 +0200)
committerJoel Granados <joel.granados@kernel.org>
Thu, 27 Nov 2025 14:43:20 +0000 (15:43 +0100)
commit5412f5b13d290d22cf910a0e8227737aaa2cc44e
tree35ba42d14e21883be1e33ad47086e510f1e8a3c1
parent610c9b6efb701e559f5b5d449e69e76e91ea4401
sysctl: Indicate the direction of operation with macro names

Replace the "write" integer parameter with SYSCTL_USER_TO_KERN() and
SYSCTL_KERN_TO_USER() that clearly indicate data flow direction in
sysctl operations.

"write" originates in proc_sysctl.c (proc_sys_{read,write}) and can take
one of two values: "0" or "1" when called from proc_sys_read and
proc_sys_write respectively. When write has a value of zero, data is
"written" to a user space buffer from a kernel variable (usually
ctl_table->data). Whereas when write has a value greater than zero, data
is "written" to an internal kernel variable from a user space buffer.
Remove this ambiguity by introducing macros that clearly indicate the
direction of the "write".

The write mode names in sysctl_writes_mode are left unchanged as these
directly relate to the sysctl_write_strict file in /proc/sys where the
word "write" unambiguously refers to writing to a file.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
kernel/sysctl.c