lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202503180846.EAB79290D@keescook>
Date: Tue, 18 Mar 2025 08:51:14 -0700
From: Kees Cook <kees@...nel.org>
To: Bhupesh Sharma <bhsharma@...lia.com>
Cc: Andres Rodriguez <andresx7@...il.com>, Bhupesh <bhupesh@...lia.com>,
	akpm@...ux-foundation.org, kernel-dev@...lia.com,
	linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
	linux-perf-users@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	linux-mm@...ck.org, oliver.sang@...el.com, lkp@...el.com,
	laoar.shao@...il.com, pmladek@...e.com, rostedt@...dmis.org,
	mathieu.desnoyers@...icios.com, arnaldo.melo@...il.com,
	alexei.starovoitov@...il.com, andrii.nakryiko@...il.com,
	mirq-linux@...e.qmqm.pl, peterz@...radead.org, willy@...radead.org,
	david@...hat.com, viro@...iv.linux.org.uk, ebiederm@...ssion.com,
	brauner@...nel.org, jack@...e.cz, mingo@...hat.com,
	juri.lelli@...hat.com, bsegall@...gle.com, mgorman@...e.de,
	vschneid@...hat.com
Subject: Re: [PATCH RFC 0/2] Dynamically allocate memory to store task's full
 name

On Tue, Mar 18, 2025 at 04:49:28PM +0530, Bhupesh Sharma wrote:
> On 3/15/25 1:13 PM, Andres Rodriguez wrote:
> > On 3/14/25 14:25, Kees Cook wrote:
> > > On Fri, Mar 14, 2025 at 10:57:13AM +0530, Bhupesh wrote:
> > > > While working with user-space debugging tools which work especially
> > > > on linux gaming platforms, I found that the task name is truncated due
> > > > to the limitation of TASK_COMM_LEN.
> > > > 
> > > > For example, currently running 'ps', the task->comm value of a long
> > > > task name is truncated due to the limitation of TASK_COMM_LEN.
> > > >      create_very_lon
> > > > 
> > > > This leads to the names passed from userland via pthread_setname_np()
> > > > being truncated.
> > > 
> > > So there have been long discussions about "comm", and it mainly boils
> > > down to "leave it alone". For the /proc-scraping tools like "ps" and
> > > "top", they check both "comm" and "cmdline", depending on mode. The more
> > > useful (and already untruncated) stuff is in "cmdline", so I suspect it
> > > may make more sense to have pthread_setname_np() interact with that
> > > instead. Also TASK_COMM_LEN is basically considered userspace ABI at
> > > this point and we can't sanely change its length without breaking the
> > > world.
> > > 
> > 
> > Completely agree that comm is best left untouched. TASK_COMM_LEN is
> > embedded into the kernel and the pthread ABI changes here should be
> > avoided.
> > 
> 
> So, basically my approach _does not_ touch TASK_COMM_LEN at all. The normal
> 'TASK_COMM_LEN' 16byte design remains untouched.
> Which means that all the legacy / existing ABi which uses 'task->comm' and
> hence are designed / written to handle 'TASK_COMM_LEN' 16-byte name,
> continue to work as before using '/proc/$pid/task/$tid/comm'.
> 
> This change-set only adds a _parallel_ dynamically allocated
> 'task->full_name' which can be used by interested users via
> '/proc/$pid/task/$tid/full_name'.

I don't want to add this to all processes at exec time as the existing
solution works for those processes: read /proc/$pid/cmdline.

That said, adding another pointer to task_struct isn't to bad I guess,
and it could be updated by later calls. Maybe by default it just points
to "comm".

> I am fine with adding either '/proc/$pid/task/$tid/full_name' or
> '/proc/$pid/task/$tid/debug_name' (actually both of these achieve the same).
> The new / modified users (especially the debug applications you listed
> above) can switch easily to using '/proc/$pid/task/$tid/full_name' instead
> of ''/proc/$pid/task/$tid/comm'
> 
> AFAIK we already achieved for the kthreads using d6986ce24fc00 ("kthread:
> dynamically allocate memory to store kthread's full name"), which adds
> 'full_name' in parallel to 'comm' for kthread names.

If we do this for task_struct, we should remove "full_name" from kthread
and generalize it for all processes.

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ