Article View: muc.lists.freebsd.bugs
Article #454[Bug 300754] linux: prctl(PR_SET_NAME) renames the whole process instead of the calling thread
From: bugzilla-noreply
Date: Fri, 13 Nov 2026 22:53
Date: Fri, 13 Nov 2026 22:53
98 lines
5272 bytes
5272 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300754
Bug ID: 300754
Summary: linux: prctl(PR_SET_NAME) renames the whole process
instead of the calling thread
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: rbranco@suse.com
Attachment #277279 text/plain
mime type:
Created attachment 277279
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277279&action=edit
prctl_name.c
On Linux, prctl(PR_SET_NAME) and prctl(PR_GET_NAME) operate on the name
of the calling thread. The main thread's name is also the process name
shown in /proc/<pid>/stat, /proc/<pid>/comm and ps(1).
The Linuxulator implements both operations on p_comm instead
(linux_prctl() in sys/compat/linux/linux_misc.c):
- PR_SET_NAME from any thread renames the whole process, and the
thread's own td_name is never changed.
whichever thread called PR_SET_NAME most recently, not the caller's
own name.
glibc's pthread_setname_np() and pthread_getname_np() use these prctl()
operations when a thread names itself. So any multithreaded Linux
program that names its worker threads ends up showing the name of
whichever thread was named last in ps(1) and top(1), and
pthread_getname_np(pthread_self()) returns the wrong name. Thread names
set this way are also not visible in "ps -H" or "top -H", because
td_name is never updated.
How to reproduce:
Build the attached prctl_name.c on Linux:
cc -static -pthread -o prctl_name prctl_name.c
The main thread names itself "main". It starts a thread, which names
itself "worker", and joins it. Then it checks its own name with
PR_GET_NAME, with pthread_getname_np() and through /proc/self/stat.
Native Linux:
worker: PR_GET_NAME after renaming itself got worker want worker
ok
main: PR_GET_NAME after worker renamed got main want main
ok
main: pthread_getname_np() got main want main
ok
process name in /proc/self/stat got main want main
ok
FreeBSD <version> with linux64.ko and linprocfs:
worker: PR_GET_NAME after renaming itself got worker want worker
ok
main: PR_GET_NAME after worker renamed got worker want main
FAIL
main: pthread_getname_np() got worker want main
FAIL
process name in /proc/self/stat got worker want main
FAIL
Expected: as on Linux, PR_SET_NAME renames only the calling thread, and
the process name changes only when the main thread renames itself.
Proposed fix: set and get td->td_name in PR_SET_NAME/PR_GET_NAME, and
also update p_comm when the caller is the main thread (em_tid == p_pid).
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-300754-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 300754] linux: prctl(PR_SET_NAME) renames the whole process instead of the calling thread Date: Fri, 13 Nov 2026 22:53:10 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-300754-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="52804"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794610390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MM2Hx3ML4GqL0ehzhyX6rPbHlwb3T1jTmVZ53Gc5zkI=; b=IMdFBGQjpiKRK8J5dvKAXvrwF/CTtnLiOpt5ZpCQeO2r0ljEQI8I+YsqJEMtVX00J86Ylo f68E0C2tBHUgRIHQ/7NcKsTBVWiHzTffqZjEgqxCAVjKxLCel/PqqJjP34eiS3/K6GPgod /Htf1ZO0NINc1e2ewAEg9spYjKHZJn2l07kEnx0Dzv2r9eq856bvGLUl3xdR7jKIg3jiLr RyWnvzCxcU1MffwCBN2y8nelBBONRI0O88pExLAWjUwZ0pq8gxVu7XDmyUxVuURtV3sBzS GJYnL9HhmMwJudXzk+q4inAPMYKnOl6gZGiN/cFX4+t6W4EGcVKc7wjpyISy3g== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes