From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B5E237C93C; Sun, 24 May 2026 22:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779662413; cv=none; b=AZEjtZw6k4ezvfP8GdRphCMmooFFV4U8CyL/vWL4WYkuCmRPiE3ZmsQ5vOyyd5yFHoobrCHLXCZUf2xQczIQZ9QbzqktjnzWdvIkRVEeuKal6MXWZ5YEL4rgdENUJouIEg5y+GT2M7oHtXUOBSozcBKI71TF8ZSgrJGwz4+M4IA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779662413; c=relaxed/simple; bh=HOpRwiLSWog/jJRLeZlc2u1UKRPV1E7lSpFIgWK67n0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SxySeg9Qh/cs8Ve0VWWu73Wm5wLISnWJWtMAUFvH3L9k3pGwsy8iILexkf1mUZZ8FIuhWAqafpI0y6KAM+lFV77FMeV+KOY4VMk+1pmBCQYX2HDk2uW5FRJuqMa+ndaSJWrdAfkfNYTYqWzdfVwJnWUdZ7QWKXdoPKhSKj/rmGw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=iA049rNy; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="iA049rNy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lgKKOAKtBLHbCbNFX0Fho8kvN0dZzv79V8RbAyegXZw=; b=iA049rNyxgdGc4JzorywwzByyw G4rzoaKzT2/eclyzFrIS4en2gTJIhnjH0G5BqbQFptI4ia182/75r05W9fzy65tp2UKArtfpruehz sgoPq4/RuDM6xAXUXlFvQIOsNSME07q1/LmDEveQXupqOpG8MaZ3xoEUSeqS/m+y4a2zSSchG8ttY OMFZuzR2cSH3SvUSWmk9YLgLUwU+RejDyYBIkC3D1tgkUcfCfRDAykpg2Xn/JI9LVDeWDaKP0+Ky7 iYQN8mKM5+6aD5xRtLRKLUjX4Ty87CLXkZcK1+ZizSPV2oaRpBa/VKUha5K/BYRiHKoS3vBTicX6x aQXE184Q==; Received: from [179.118.191.12] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wRHUN-007fJn-9p; Mon, 25 May 2026 00:40:07 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Sun, 24 May 2026 19:38:55 -0300 Subject: [PATCH v2 5/6] prctl: Add support for long user thread names Precedence: bulk X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260524-tonyk-long_name-v2-5-332f6bd041c4@igalia.com> References: <20260524-tonyk-long_name-v2-0-332f6bd041c4@igalia.com> In-Reply-To: <20260524-tonyk-long_name-v2-0-332f6bd041c4@igalia.com> To: Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Christian Brauner , Kees Cook , Shuah Khan , willy@infradead.org, mathieu.desnoyers@efficios.com, David Laight , Linus Torvalds , akpm@linux-foundation.org, Yafang Shao , andrii.nakryiko@gmail.com, arnaldo.melo@gmail.com, Petr Mladek Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, linux-mm@kvack.org, linux-api@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.15.2 Add support for getting and setting long user thread names with PR_{SET,GET}_EXT_NAME. Signed-off-by: André Almeida --- include/linux/sched.h | 2 +- include/uapi/linux/prctl.h | 3 +++ kernel/sys.c | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f7fd2b7d131d..fd4256c8627b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1997,7 +1997,7 @@ extern void kick_process(struct task_struct *tsk); extern void __set_task_comm(struct task_struct *tsk, const char *from, bool exec); #define set_task_comm(tsk, from) ({ \ - BUILD_BUG_ON(sizeof(from) != TASK_COMM_LEN); \ + BUILD_BUG_ON(sizeof(from) < TASK_COMM_LEN); \ __set_task_comm(tsk, from, false); \ }) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index b6ec6f693719..a07f8edadd65 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -56,6 +56,9 @@ #define PR_SET_NAME 15 /* Set process name */ #define PR_GET_NAME 16 /* Get process name */ +#define PR_SET_EXT_NAME 17 /* Set extended process name */ +#define PR_GET_EXT_NAME 18 /* Get extended process name */ + /* Get/set process endian */ #define PR_GET_ENDIAN 19 #define PR_SET_ENDIAN 20 diff --git a/kernel/sys.c b/kernel/sys.c index 76d77218ab19..1b70d53da998 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2535,7 +2535,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, unsigned long, arg4, unsigned long, arg5) { struct task_struct *me = current; - unsigned char comm[TASK_COMM_LEN]; + unsigned char comm[TASK_COMM_EXT_LEN]; long error; error = security_task_prctl(option, arg2, arg3, arg4, arg5); @@ -2613,6 +2613,19 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, if (copy_to_user((char __user *)arg2, comm, TASK_COMM_LEN)) return -EFAULT; break; + case PR_SET_EXT_NAME: + comm[TASK_COMM_EXT_LEN - 1] = 0; + if (strncpy_from_user(comm, (char __user *)arg2, + TASK_COMM_EXT_LEN - 1) < 0) + return -EFAULT; + set_task_comm(me, comm); + proc_comm_connector(me); + break; + case PR_GET_EXT_NAME: + strscpy_pad(comm, me->comm, TASK_COMM_EXT_LEN); + if (copy_to_user((char __user *)arg2, comm, TASK_COMM_EXT_LEN)) + return -EFAULT; + break; case PR_GET_ENDIAN: error = GET_ENDIAN(me, arg2); break; -- 2.54.0