diff options
| author | Joel Granados <joel.granados@kernel.org> | 2026-08-13 08:29:18 +0200 |
|---|---|---|
| committer | Joel Granados <joel.granados@kernel.org> | 2026-09-10 14:52:15 +0200 |
| commit | 242bac52294e437218f5815b16d3de984bb55593 (patch) | |
| tree | 777ef8f9c6a8b0642d752e5655ef527877819c58 /tools/perf/scripts/python/netdev-times.py | |
| parent | d08ab285b0968c96ee33bc66c6a3c5a348a45d62 (diff) | |
| download | linux-next-242bac52294e437218f5815b16d3de984bb55593.tar.gz linux-next-242bac52294e437218f5815b16d3de984bb55593.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 'tools/perf/scripts/python/netdev-times.py')
0 files changed, 0 insertions, 0 deletions
