Re: [PATCH v2 0/4] sysctl: Disallow partial updates of miss-formatted sysctl vectors

Andrew Morton <[email protected]>
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Fri, 14 Aug 2026 12:41:11 +0200 Joel Granados <[email protected]> wrote:

> What?
> =====
> 
> Stage table->data when writing INT & ULONG ctl_tables. Commit staged
> data to kernel variable only when all the conversions have succeeded.
> This is applicable only to variables that represent a vector; paths
> pertaining to scalers are left unchanged. Notice that partial updates

"scalars"

> can still happen if less than the size of the vector are passed and
> correctly formatted.
> 
> This is the behavior we are protecting against:
> 
>   # 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    <- the write failed, the first element changed anyway

I like the change.

> Why?
> ====
> Allowing a partial change to a vector after returning from an erroneous
> proc_handler is just plain wrong. This should be handled within sysctl
> to avoid users having to do it for themselves [1]. 
> 
> Behavioral Changes
> ==================
> 1. A failed write will not update the vector
> 2. Vector writes can now fail with -ENOMEM

Yeah, this improves Linux.

> Testing
> =======
> This went through regular sysctl kunit and self test. Also is posted to
> 0-day.
> 
> I always find it difficult to know who wants to receive this. Please let
> me know if you want to be removed from the Cc/To.

Sashiko said one thing:
	https://sashiko.dev/#/patchset/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.