Re: [PATCH] proc: fix comm_write return value when truncated or error
From: Alexey Dobriyan
Date: Fri Apr 24 2026 - 14:50:47 EST
On Sat, Apr 25, 2026 at 02:03:41AM +0800, Shengzhuo Wei wrote:
> On 2026-04-24 16:28, Alexey Dobriyan wrote:
> > > > Fixes: 4614a696bd1c ("procfs: allow threads to rename siblings via /proc/pid/tasks/tid/comm")
> > >
> > > December 2009.
> > >
> > > Hopefully no userspace is depending on the broken return value of a
> > > write to /proc/pid/comm.
> > >
> > > Arguably we should leave the code as-is and add an apologetic comment
> > > explaining the situation.
> >
>
> First, there's a plain bug regardless: assigning -EINVAL to a size_t count and
> returning it as ssize_t produces a bogus positive value on the error path.
There is no bug, write() will return -EINVAL as it should.
> Introducing a dedicated ssize_t ret fixes this without changing any
> success-path behavior, the change is on a permission failure path, so it's hard
> to imagine anyone depending on the broken behavior, but worth mentioning