Re: [PATCH] proc: fix comm_write return value when truncated or error
From: Andrew Morton
Date: Fri Apr 24 2026 - 09:40:07 EST
On Fri, 24 Apr 2026 04:06:21 +0800 "Shengzhuo Wei" <me@xxxxxxxx> wrote:
> When count exceeds TASK_COMM_LEN-1, comm_write() copies at most
> TASK_COMM_LEN-1 bytes but returns the original count. This violates
> write(2) semantics, which require returning the number of bytes
> actually written.
>
> The count parameter is size_t and should not be repurposed to carry a
> negative error code on the same_thread_group() failure path.
>
> Introduce a local len for the truncated length and a separate ssize_t
> ret for the return value.
AI review asks a good question:
https://sashiko.dev/#/patchset/20260424-fix_proc_write_return-v1-1-7a793c2aad32@xxxxxxxx