summaryrefslogtreecommitdiff
path: root/scripts/basic/split-include.c
diff options
context:
space:
mode:
authorJoel Granados <joel.granados@kernel.org>2026-08-13 08:29:18 +0200
committerJoel Granados <joel.granados@kernel.org>2026-09-10 14:55:32 +0200
commitf52fc239319414aa4c20c1a50787622b1e9064ee (patch)
treec591ed9a26dff9e37730fdf85bdc09f388b17706 /scripts/basic/split-include.c
parent6cf1dc2d616c06bccd49e13e48de0e68498e50ad (diff)
downloadlinux-next-f52fc239319414aa4c20c1a50787622b1e9064ee.tar.gz
linux-next-f52fc239319414aa4c20c1a50787622b1e9064ee.zip
sysctl: Disallow partial updates for erroneous sysctl vectors
When updating the kernel sysctl vectors there is a chance that not all vector elements are updated due to erroneous input. Use a staging variable that holds a copy of the vector and commits to the actual table->data only when all input is successfully updated. This does **not** make the write atomic as a reader can still see a partially updated vector. The staging is only for vectors; cases where table->data points to a variable should not be staged as they will not be updated on input error. PROC_VEC_UINT is not included because UINT arrays are not allowed. Replace first with nr_conv, incremented where first was cleared. first is exactly nr_conv == 0, and the counter doubles as the number of elements to publish. Example of behavior that is being prevented: # echo "4 4 1 7" > /proc/sys/kernel/printk # echo "1 x" > /proc/sys/kernel/printk -bash: echo: write error: Invalid argument # cat /proc/sys/kernel/printk 1 4 1 7 <- incorrect It should be unchanged ("4 4 1 7") on error. Link: https://lore.kernel.org/all/tencent_A860C873956A52E26AD8D309A308A241BA08@qq.com/ Reviewed-by: Bradley Morgan <include@grrlz.net> Signed-off-by: Joel Granados <joel.granados@kernel.org>
Diffstat (limited to 'scripts/basic/split-include.c')
0 files changed, 0 insertions, 0 deletions