public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Shengzhuo Wei" <me@cherr.cc>
To: "Alexey Dobriyan" <adobriyan@gmail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	 "Shengzhuo Wei" <me@cherr.cc>,
	"John Stultz" <johnstul@us.ibm.com>,  "Yao Zi" <me@ziyao.cc>,
	<linux-kernel@vger.kernel.org>,  <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] proc: fix comm_write return value when truncated or error
Date: Sat, 25 Apr 2026 02:03:41 +0800	[thread overview]
Message-ID: <aeuwfe6xy74R2qm4@pve.cherr> (raw)
In-Reply-To: <3f91ed95-b38e-4049-b69c-13335b13ae44@p183>

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.
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

> Yes, this issue must all over virtual filesystems.
> 
> Patch may break stuff in the other direction too:
> 
> if process is doing "full write" loop, and write hook gets string
> which is too long, then the last piece will be written, not truncated
> first part.

For the truncation case, I agree returning a short count breaks the
full-write idiom. But sliently truncating isnt't great either. Maybe we
should reject overlong writes and return -EINVAL instead? That's also an
ABI change and breaks the userspace, so it needs discussion, but at
least it fails loudly.

> 
> 	/proc/alexey

Very happy to hear from your opinions and sorry for my poor English.
Best regards.

  reply	other threads:[~2026-04-24 18:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 20:06 [PATCH] proc: fix comm_write return value when truncated or error Shengzhuo Wei
2026-04-24 10:50 ` Andrew Morton
2026-04-24 13:28   ` Alexey Dobriyan
2026-04-24 18:03     ` Shengzhuo Wei [this message]
2026-04-24 18:52       ` Alexey Dobriyan
2026-04-24 13:35 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aeuwfe6xy74R2qm4@pve.cherr \
    --to=me@cherr.cc \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@ziyao.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox