From nobody Sat Oct 4 01:47:31 2025 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 E82822DA75C; Thu, 21 Aug 2025 10:22: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=1755771735; cv=none; b=ofCHjo37iNZtJfzx33xs+lWyemgqzL0J0Co3Kse0LGmL0D280aopMz5PmSTaB2Yx4M6Sec2W6eZLGCaQHK8Jt0P+jrz5ISXmLee4Q9vaeNlPO5LddKRrWF8I11muhqOeW3rg1UmuYZ+8kwEy3BMr5+Er7VuMGlDmguRHlWZDDfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771735; c=relaxed/simple; bh=P5LNrpuDso84evhrHDb5O/cBPmQFjz++sIDdWzNU4tY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HBHrI6XwA3700RnW+8T9IBA06AY/9M61WEluz76GcHO2pIVkdHj+FFo7AMo3BNp0qoKVdDkjYwYthNAWTwQzn5n3xl0Eoz21o0wXTolePwNfxcbYRB/+SkiVzlMqdINM/sSptu5RTe4YJtP1/SIf/714zZ0fB32uM+47UaEC42E= 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=rKsiUYA8; 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="rKsiUYA8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=zRAnHsOfkqVGryjONqmeYxIHoj1DfmYgpmMCpMPPlBQ=; b=rKsiUYA89wVGH3IG3P4L0TkD8B QhQhniq0xN2HodgjgeZ4GWESucqR9nCGc7TtiMk+wB8/Vyn7tZURFFXWZAMaqFixBOHWq5B2rFb6p z7wQxtSUXI1hxOPoy2Q1gFCA5qShbEFPdVmqOvNe3z0FoAuIYmfszhyqKMdJuMM0bzULyNYCK1u/U Arllm3Dd23QW780w1B8/oBSauPtNb1YAJB+ISdlMYEMPOq5bLFnJJ79Gu7pzyTL60Lswpd0XNusJy fpLijRYQp5Kgx2eycxatNBjbwMdOp9VisPFG29G6HY3C/NHebb6synSOrDscGUXrOvyPfIe07jPiv OC8vLlAg==; Received: from [223.233.68.152] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1up2Qq-00HBmV-4T; Thu, 21 Aug 2025 12:22:08 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-trace-kernel@vger.kernel.org, kees@kernel.org, torvalds@linux-foundation.org Subject: [PATCH v8 1/5] exec: Remove obsolete comments Date: Thu, 21 Aug 2025 15:51:48 +0530 Message-Id: <20250821102152.323367-2-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250821102152.323367-1-bhupesh@igalia.com> References: <20250821102152.323367-1-bhupesh@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Patch 3a3f61ce5e0b ("exec: Make sure task->comm is always NUL-terminated"), replaced 'strscpy_pad()' with 'memcpy()' implementations inside '__set_task_comm()'. However a few left-over comments are still there, which mention the usage of 'strscpy_pad()' inside '__set_task_comm()'. Remove those obsolete comments. While at it, also remove an obsolete comment regarding 'task_lock()' usage while handing 'task->comm'. Signed-off-by: Bhupesh Reviewed-by: Kees Cook --- include/linux/sched.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f8188b833350..24216259cda4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1159,10 +1159,8 @@ struct task_struct { * * - normally initialized begin_new_exec() * - set it with set_task_comm() - * - strscpy_pad() to ensure it is always NUL-terminated and + * - logic inside set_task_comm() will ensure it is always NUL-terminat= ed and * zero-padded - * - task_lock() to ensure the operation is atomic and the name is - * fully updated. */ char comm[TASK_COMM_LEN]; =20 @@ -1972,7 +1970,7 @@ extern void __set_task_comm(struct task_struct *tsk, = const char *from, bool exec * User space can randomly change their names anyway, so locking for rea= ders * doesn't make sense. For writers, locking is probably necessary, as a = race * condition could lead to long-term mixed results. - * The strscpy_pad() in __set_task_comm() can ensure that the task comm = is + * The logic inside __set_task_comm() should ensure that the task comm is * always NUL-terminated and zero-padded. Therefore the race condition b= etween * reader and writer is not an issue. * --=20 2.38.1 From nobody Sat Oct 4 01:47:31 2025 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 8C16F2F549B; Thu, 21 Aug 2025 10:22:17 +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=1755771740; cv=none; b=DqqXuSF0ymecuMYT0yBCRDtrMidzI0F5uG39ITV5/EU+jcOaHiy0/4lxNOukOAHjID7uvY7OC2tojo61jmuPwHKtnz8JABR2mBSvd8g/2LGBhRLbULjw/T0K98W33oLyKUVTkLJH7KXEXFZ19rK/ozetAH1U2DrOe75onym9EfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771740; c=relaxed/simple; bh=ITel6dwryUU1HeYPk6QFIUv0pmLNzObqsWadXZfwTu4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OaDmpsfmFGh0WQu+Q1vf+rd/B7D4h9A78sNA5dEb8UZGceyPARioJ39lv4DZeNKTPLrn6qj1xKrXuBKJUB2mu3M0jt6upNLnG0buQYQP0k0aagK+gD8u64TOCdGh5ouSzbVTkyCQGSptBS3yRGAox+hJs4EPOYLF7FfkQYN5XGA= 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=BMWp8pD7; 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="BMWp8pD7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=SqG59QcNd5zcgM/48bgbCRG/bObN6shwfOiwsu1X8jM=; b=BMWp8pD7b9GiEYM/tFJo1TnmAV Vc9hHbhfmKolOyJCKbBRqSIC4CjK59oqtpEVzZ4TBBJ+lNf628BnUHtepubkcq1W7FdVmQaqxOrOo PDKmL9ueul+Azb2iulfgVVYyI0CboZGmrTszyAHcAKXbqXbFT50OhNwmgj4GcgQHDN6uweDRRdyLw z22GvTK7IQ09Rxx/TLpaVz4ESQDBCwAD5X+iWk2IG2oachNyc4j5/Pci41Yuv9C+QqHjhJJskWOdT iqGC5p78QFQI7QoaWRX8QAUCbNSpR4TOKMkOFqmNW/+oTxc/f8Y6YiCGeDzSW5LZChJhAvWpkLhjB wmokEYVQ==; Received: from [223.233.68.152] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1up2Qv-00HBmV-UT; Thu, 21 Aug 2025 12:22:14 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-trace-kernel@vger.kernel.org, kees@kernel.org, torvalds@linux-foundation.org Subject: [PATCH v8 2/5] include: Set tsk->comm length to 64 bytes Date: Thu, 21 Aug 2025 15:51:49 +0530 Message-Id: <20250821102152.323367-3-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250821102152.323367-1-bhupesh@igalia.com> References: <20250821102152.323367-1-bhupesh@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Historically due to the 16-byte length of TASK_COMM_LEN, the users of 'tsk->comm' are restricted to use a fixed-size target buffer also of TASK_COMM_LEN for 'memcpy()' like use-cases. To fix the same, we now use a 64-byte TASK_COMM_EXT_LEN and set the comm element inside 'task_struct' to the same length: struct task_struct { ..... char comm[TASK_COMM_EXT_LEN]; ..... }; where TASK_COMM_EXT_LEN is 64-bytes. Note, that the existing users have not been modified to migrate to 'TASK_COMM_EXT_LEN', in case they have hard-coded expectations of dealing with only a 'TASK_COMM_LEN' long 'tsk->comm'. Signed-off-by: Bhupesh --- include/linux/sched.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 24216259cda4..bcebc5622e07 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -318,6 +318,7 @@ struct user_event_mm; */ enum { TASK_COMM_LEN =3D 16, + TASK_COMM_EXT_LEN =3D 64, }; =20 extern void sched_tick(void); @@ -1162,7 +1163,7 @@ struct task_struct { * - logic inside set_task_comm() will ensure it is always NUL-terminat= ed and * zero-padded */ - char comm[TASK_COMM_LEN]; + char comm[TASK_COMM_EXT_LEN]; =20 struct nameidata *nameidata; =20 @@ -1961,7 +1962,7 @@ extern void kick_process(struct task_struct *tsk); =20 extern void __set_task_comm(struct task_struct *tsk, const char *from, boo= l exec); #define set_task_comm(tsk, from) ({ \ - BUILD_BUG_ON(sizeof(from) !=3D TASK_COMM_LEN); \ + BUILD_BUG_ON(sizeof(from) < TASK_COMM_LEN); \ __set_task_comm(tsk, from, false); \ }) =20 --=20 2.38.1 From nobody Sat Oct 4 01:47:31 2025 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 49B272F8BFC; Thu, 21 Aug 2025 10:22:23 +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=1755771746; cv=none; b=a1FOxp3Kw9AbkrdSRWl3K9ziKAg6oME/cyRt+VzA3hBgN1cKIqBPNIIof4cbC0utLKi7Duo3zC82l9HraBsnUTVPp7OPalPNH1qysOr3RWbAgTxm0xDPt/l+K2o0QyZ+7VM1E0WV5549+gqosVDqJzr8bH3YxSiLE/L5gVY+M18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771746; c=relaxed/simple; bh=5mrNcTA4OKCt0WHHQhS4PeUZX3yg2Inj47YRTqLc37s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qE/x+na/gI9NUBzKxYiTnx4LcFLSEHU8B20xrJ64GrwWBkFvKsSST3ebwJR/x62Q/81n42WY9l5NdKODLwAZu48OATuTXivId5o4ZoAAx/CsQy7ci93DA2bxHKvmYUmF8rX3iRsjdnHDUiJ+Br/SZkpFRl6RbcYYd+VrELnZNxo= 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=n9HPLkDi; 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="n9HPLkDi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=GAEyZkelqAOAawrlKIjrCAL0su4aVASycJItIz/u0K0=; b=n9HPLkDikLdWRySIMzui9PAS8w 6Hc5uVOa2c444JCSw2dTBwMYLPjQWrABmjprdnX5hV47eKvX7RTNW5hR0Vy5ZWoFiZmDXJvZzpi9v L0alS82MArv0Q6g/tsT7RJ1XBVx+cEwGKgBB6pP0D7w5n7LO3dbVyaWR7KeK2YsmcROlKIaOGov/v 51jkoeo80lL7N582wvTsaXAGsTzJQF/3uZbRGJErJpq8kt42JraYdBs13+JIeD4eC9sGptYmzGDMz pi19gOGNIb25VB9Xi/Y5mY3vvm8cHwS34rJhCEuF2Kfo9B7lMH3dsWZ8niEjd9rLpE7VpesujJCJN 8gdEtxeA==; Received: from [223.233.68.152] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1up2R1-00HBmV-Pc; Thu, 21 Aug 2025 12:22:20 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-trace-kernel@vger.kernel.org, kees@kernel.org, torvalds@linux-foundation.org Subject: [PATCH v8 3/5] treewide: Replace 'get_task_comm()' with 'strscpy_pad()' Date: Thu, 21 Aug 2025 15:51:50 +0530 Message-Id: <20250821102152.323367-4-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250821102152.323367-1-bhupesh@igalia.com> References: <20250821102152.323367-1-bhupesh@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As Linus mentioned in [1], we should get rid of 'get_task_comm()' entirely and replace it with 'strscpy_pad()' implementation. 'strscpy_pad()' will already make sure comm is NUL-terminated, so we won't need the explicit final byte termination done in 'get_task_comm()'. The relevant 'get_task_comm()' users were identified using the following search pattern: $ git grep 'get_task_comm*' Link: https://lore.kernel.org/all/CAHk-=3Dwi5c=3D_-FBGo_88CowJd_F-Gi6Ud9d= =3DTALm65ReN7YjrMw@mail.gmail.com/ #1 Signed-off-by: Bhupesh --- drivers/connector/cn_proc.c | 2 +- drivers/dma-buf/sw_sync.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c | 2 +- .../drm/amd/amdgpu/amdgpu_eviction_fence.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- drivers/gpu/drm/lima/lima_ctx.c | 2 +- drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +- drivers/gpu/drm/panthor/panthor_gem.c | 2 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 2 +- drivers/hwtracing/stm/core.c | 2 +- drivers/tty/tty_audit.c | 2 +- fs/bcachefs/thread_with_file.c | 2 +- fs/binfmt_elf.c | 2 +- fs/binfmt_elf_fdpic.c | 2 +- fs/ocfs2/cluster/netdebug.c | 1 - fs/proc/array.c | 2 +- include/linux/sched.h | 19 ------------------- kernel/audit.c | 6 ++++-- kernel/auditsc.c | 6 ++++-- kernel/sys.c | 2 +- mm/kmemleak.c | 6 ------ net/bluetooth/hci_sock.c | 2 +- net/netfilter/nf_tables_api.c | 2 +- security/integrity/integrity_audit.c | 3 ++- security/ipe/audit.c | 2 +- security/landlock/domain.c | 2 +- security/lsm_audit.c | 7 ++++--- 30 files changed, 38 insertions(+), 58 deletions(-) diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 44b19e696176..3c1b07198e10 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -278,7 +278,7 @@ void proc_comm_connector(struct task_struct *task) ev->what =3D PROC_EVENT_COMM; ev->event_data.comm.process_pid =3D task->pid; ev->event_data.comm.process_tgid =3D task->tgid; - get_task_comm(ev->event_data.comm.comm, task); + strscpy_pad(ev->event_data.comm.comm, task->comm); =20 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); msg->ack =3D 0; /* not used */ diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c index 3c20f1d31cf5..1f2ddf00799b 100644 --- a/drivers/dma-buf/sw_sync.c +++ b/drivers/dma-buf/sw_sync.c @@ -311,7 +311,7 @@ static int sw_sync_debugfs_open(struct inode *inode, st= ruct file *file) struct sync_timeline *obj; char task_comm[TASK_COMM_LEN]; =20 - get_task_comm(task_comm, current); + strscpy_pad(task_comm, current->comm); =20 obj =3D sync_timeline_create(task_comm); if (!obj) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c b/drivers/gpu= /drm/amd/amdgpu/amdgpu_amdkfd_fence.c index 1ef758ac5076..ea2b99fde425 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c @@ -73,7 +73,7 @@ struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u6= 4 context, /* This reference gets released in amdkfd_fence_release */ mmgrab(mm); fence->mm =3D mm; - get_task_comm(fence->timeline_name, current); + strscpy_pad(fence->timeline_name, current->comm); spin_lock_init(&fence->lock); fence->svm_bo =3D svm_bo; dma_fence_init(&fence->base, &amdkfd_fence_ops, &fence->lock, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/g= pu/drm/amd/amdgpu/amdgpu_eviction_fence.c index 23d7d0b0d625..3e2ad72cafc4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c @@ -166,7 +166,7 @@ amdgpu_eviction_fence_create(struct amdgpu_eviction_fen= ce_mgr *evf_mgr) return NULL; =20 ev_fence->evf_mgr =3D evf_mgr; - get_task_comm(ev_fence->timeline_name, current); + strscpy_pad(ev_fence->timeline_name, current->comm); spin_lock_init(&ev_fence->lock); dma_fence_init64(&ev_fence->base, &amdgpu_eviction_fence_ops, &ev_fence->lock, evf_mgr->ev_fence_ctx, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_ras.c index 25bade9a5e95..8a4a4c03bbcd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -4169,7 +4169,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev) } =20 con->init_task_pid =3D task_pid_nr(current); - get_task_comm(con->init_task_comm, current); + strscpy_pad(con->init_task_comm, current->comm); =20 mutex_init(&con->critical_region_lock); INIT_LIST_HEAD(&con->critical_region_head); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/= drm/amd/amdgpu/amdgpu_userq_fence.c index c2a983ff23c9..73aa37f65e0b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c @@ -92,7 +92,7 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device = *adev, =20 fence_drv->adev =3D adev; fence_drv->context =3D dma_fence_context_alloc(1); - get_task_comm(fence_drv->timeline_name, current); + strscpy_pad(fence_drv->timeline_name, current->comm); =20 xa_lock_irqsave(&adev->userq_xa, flags); r =3D xa_err(__xa_store(&adev->userq_xa, userq->doorbell_index, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/a= mdgpu/amdgpu_vm.c index c3d4bf0767e0..20b83441951b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2523,13 +2523,13 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) return; =20 vm->task_info->task.pid =3D current->pid; - get_task_comm(vm->task_info->task.comm, current); + strscpy_pad(vm->task_info->task.comm, current->comm); =20 if (current->group_leader->mm !=3D current->mm) return; =20 vm->task_info->tgid =3D current->group_leader->pid; - get_task_comm(vm->task_info->process_name, current->group_leader); + strscpy_pad(vm->task_info->process_name, current->group_leader->comm); } =20 /** diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm= /amd/amdgpu/amdgpu_vram_mgr.c index e69db0a93378..7d7c9ff940d7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -598,7 +598,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_mana= ger *man, } =20 vres->task.pid =3D task_pid_nr(current); - get_task_comm(vres->task.comm, current); + strscpy_pad(vres->task.comm, current->comm); list_add_tail(&vres->vres_node, &mgr->allocated_vres_list); =20 if (bo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS && adjust_dcc_size) { diff --git a/drivers/gpu/drm/lima/lima_ctx.c b/drivers/gpu/drm/lima/lima_ct= x.c index 0e668fc1e0f9..7536288ec93b 100644 --- a/drivers/gpu/drm/lima/lima_ctx.c +++ b/drivers/gpu/drm/lima/lima_ctx.c @@ -29,7 +29,7 @@ int lima_ctx_create(struct lima_device *dev, struct lima_= ctx_mgr *mgr, u32 *id) goto err_out0; =20 ctx->pid =3D task_pid_nr(current); - get_task_comm(ctx->pname, current); + strscpy_pad(ctx->pname, current->comm); =20 return 0; =20 diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panf= rost/panfrost_gem.c index 85d6289a6eda..75d927020560 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -17,7 +17,7 @@ static void panfrost_gem_debugfs_bo_add(struct panfrost_d= evice *pfdev, struct panfrost_gem_object *bo) { bo->debugfs.creator.tgid =3D current->group_leader->pid; - get_task_comm(bo->debugfs.creator.process_name, current->group_leader); + strscpy_pad(bo->debugfs.creator.process_name, current->group_leader->comm= ); =20 mutex_lock(&pfdev->debugfs.gems_lock); list_add_tail(&bo->debugfs.node, &pfdev->debugfs.gems_list); diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/pantho= r/panthor_gem.c index a123bc740ba1..ba2b80c760c9 100644 --- a/drivers/gpu/drm/panthor/panthor_gem.c +++ b/drivers/gpu/drm/panthor/panthor_gem.c @@ -27,7 +27,7 @@ static void panthor_gem_debugfs_bo_add(struct panthor_gem= _object *bo) struct panthor_device, base); =20 bo->debugfs.creator.tgid =3D current->group_leader->pid; - get_task_comm(bo->debugfs.creator.process_name, current->group_leader); + strscpy_pad(bo->debugfs.creator.process_name, current->group_leader->comm= ); =20 mutex_lock(&ptdev->gems.lock); list_add_tail(&bo->debugfs.node, &ptdev->gems.node); diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virti= o/virtgpu_ioctl.c index c33c057365f8..d2bf221e8f01 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -50,7 +50,7 @@ static void virtio_gpu_create_context_locked(struct virti= o_gpu_device *vgdev, } else { char dbgname[TASK_COMM_LEN]; =20 - get_task_comm(dbgname, current); + strscpy_pad(dbgname, current->comm); virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, vfpriv->context_init, strlen(dbgname), dbgname); diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c index cdba4e875b28..f07784c8751c 100644 --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -634,7 +634,7 @@ static ssize_t stm_char_write(struct file *file, const = char __user *buf, char comm[sizeof(current->comm)]; char *ids[] =3D { comm, "default", NULL }; =20 - get_task_comm(comm, current); + strscpy_pad(comm, current->comm); =20 err =3D stm_assign_first_policy(stmf->stm, &stmf->output, ids, 1); /* diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 75542333c54a..2724341edda0 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -77,7 +77,7 @@ static void tty_audit_log(const char *description, dev_t = dev, audit_log_format(ab, "%s pid=3D%u uid=3D%u auid=3D%u ses=3D%u major=3D%d = minor=3D%d comm=3D", description, pid, uid, loginuid, sessionid, MAJOR(dev), MINOR(dev)); - get_task_comm(name, current); + strscpy_pad(name, current->comm); audit_log_untrustedstring(ab, name); audit_log_format(ab, " data=3D"); audit_log_n_hex(ab, data, size); diff --git a/fs/bcachefs/thread_with_file.c b/fs/bcachefs/thread_with_file.c index c2eae0ab7765..eda1b6b5e3b7 100644 --- a/fs/bcachefs/thread_with_file.c +++ b/fs/bcachefs/thread_with_file.c @@ -35,7 +35,7 @@ int bch2_run_thread_with_file(struct thread_with_file *th= r, fd_flags |=3D O_WRONLY; =20 char name[TASK_COMM_LEN]; - get_task_comm(name, current); + strscpy_pad(name, current->comm); =20 thr->ret =3D 0; thr->task =3D kthread_create(fn, thr, "%s", name); diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 264fba0d44bd..6ea946656403 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1540,7 +1540,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, s= truct task_struct *p, SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid)); SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid)); rcu_read_unlock(); - get_task_comm(psinfo->pr_fname, p); + strscpy_pad(psinfo->pr_fname, p->comm); =20 return 0; } diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 48fd2de3bca0..605d09d3c36f 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1365,7 +1365,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, s= truct task_struct *p, SET_UID(psinfo->pr_uid, from_kuid_munged(cred->user_ns, cred->uid)); SET_GID(psinfo->pr_gid, from_kgid_munged(cred->user_ns, cred->gid)); rcu_read_unlock(); - get_task_comm(psinfo->pr_fname, p); + strscpy_pad(psinfo->pr_fname, p->comm); =20 return 0; } diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index bc27301eab6d..ab94ab55111e 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -122,7 +122,6 @@ static int nst_seq_show(struct seq_file *seq, void *v) send =3D ktime_to_us(ktime_sub(now, nst->st_send_time)); status =3D ktime_to_us(ktime_sub(now, nst->st_status_time)); =20 - /* get_task_comm isn't exported. oh well. */ seq_printf(seq, "%p:\n" " pid: %lu\n" " tgid: %lu\n" diff --git a/fs/proc/array.c b/fs/proc/array.c index a0a97606c8f6..eefc6b365b3d 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -109,7 +109,7 @@ void proc_task_name(struct seq_file *m, struct task_str= uct *p, bool escape) else if (p->flags & PF_KTHREAD) get_kthread_comm(tcomm, sizeof(tcomm), p); else - get_task_comm(tcomm, p); + strscpy_pad(tcomm, p->comm); =20 if (escape) seq_escape_str(m, tcomm, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\"); diff --git a/include/linux/sched.h b/include/linux/sched.h index bcebc5622e07..5a58c1270474 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1966,25 +1966,6 @@ extern void __set_task_comm(struct task_struct *tsk,= const char *from, bool exec __set_task_comm(tsk, from, false); \ }) =20 -/* - * - Why not use task_lock()? - * User space can randomly change their names anyway, so locking for rea= ders - * doesn't make sense. For writers, locking is probably necessary, as a = race - * condition could lead to long-term mixed results. - * The logic inside __set_task_comm() should ensure that the task comm is - * always NUL-terminated and zero-padded. Therefore the race condition b= etween - * reader and writer is not an issue. - * - * - BUILD_BUG_ON() can help prevent the buf from being truncated. - * Since the callers don't perform any return value checks, this safegua= rd is - * necessary. - */ -#define get_task_comm(buf, tsk) ({ \ - BUILD_BUG_ON(sizeof(buf) < TASK_COMM_LEN); \ - strscpy_pad(buf, (tsk)->comm); \ - buf; \ -}) - static __always_inline void scheduler_ipi(void) { /* diff --git a/kernel/audit.c b/kernel/audit.c index 61b5744d0bb6..64623f186fc6 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -1621,7 +1621,8 @@ static void audit_log_multicast(int group, const char= *op, int err) audit_put_tty(tty); audit_log_task_context(ab); /* subj=3D */ audit_log_format(ab, " comm=3D"); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + strscpy_pad(comm, current->comm); + audit_log_untrustedstring(ab, comm); audit_log_d_path_exe(ab, current->mm); /* exe=3D */ audit_log_format(ab, " nl-mcgrp=3D%d op=3D%s res=3D%d", group, op, !err); audit_log_end(ab); @@ -2270,7 +2271,8 @@ void audit_log_task_info(struct audit_buffer *ab) audit_get_sessionid(current)); audit_put_tty(tty); audit_log_format(ab, " comm=3D"); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + strscpy_pad(comm, current->comm); + audit_log_untrustedstring(ab, comm); audit_log_d_path_exe(ab, current->mm); audit_log_task_context(ab); } diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 497bda0043fb..801f261d9891 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2931,7 +2931,8 @@ void __audit_log_nfcfg(const char *name, u8 af, unsig= ned int nentries, audit_log_format(ab, " pid=3D%u", task_tgid_nr(current)); audit_log_task_context(ab); /* subj=3D */ audit_log_format(ab, " comm=3D"); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + strscpy_pad(comm, current->comm); + audit_log_untrustedstring(ab, comm); audit_log_end(ab); } EXPORT_SYMBOL_GPL(__audit_log_nfcfg); @@ -2954,7 +2955,8 @@ static void audit_log_task(struct audit_buffer *ab) sessionid); audit_log_task_context(ab); audit_log_format(ab, " pid=3D%d comm=3D", task_tgid_nr(current)); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + strscpy_pad(comm, current->comm); + audit_log_untrustedstring(ab, comm); audit_log_d_path_exe(ab, current->mm); } =20 diff --git a/kernel/sys.c b/kernel/sys.c index 605f7fe9a143..b139f3fe7539 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2520,7 +2520,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, ar= g2, unsigned long, arg3, proc_comm_connector(me); break; case PR_GET_NAME: - get_task_comm(comm, me); + strscpy_pad(comm, me->comm); if (copy_to_user((char __user *)arg2, comm, sizeof(comm))) return -EFAULT; break; diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 84265983f239..42e67c03cb7d 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -682,12 +682,6 @@ static struct kmemleak_object *__alloc_object(gfp_t gf= p) strscpy(object->comm, "softirq"); } else { object->pid =3D current->pid; - /* - * There is a small chance of a race with set_task_comm(), - * however using get_task_comm() here may cause locking - * dependency issues with current->alloc_lock. In the worst - * case, the command line is not correct. - */ strscpy(object->comm, current->comm); } =20 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index fc866759910d..759a508024be 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -106,7 +106,7 @@ static bool hci_sock_gen_cookie(struct sock *sk) id =3D 0xffffffff; =20 hci_pi(sk)->cookie =3D id; - get_task_comm(hci_pi(sk)->comm, current); + strscpy_pad(hci_pi(sk)->comm, current->comm); return true; } =20 diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 58c5425d61c2..cdd5195547b5 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9688,7 +9688,7 @@ static int nf_tables_fill_gen_info(struct sk_buff *sk= b, struct net *net, =20 if (nla_put_be32(skb, NFTA_GEN_ID, htonl(nft_net->base_seq)) || nla_put_be32(skb, NFTA_GEN_PROC_PID, htonl(task_pid_nr(current))) || - nla_put_string(skb, NFTA_GEN_PROC_NAME, get_task_comm(buf, current))) + nla_put_string(skb, NFTA_GEN_PROC_NAME, strscpy_pad(buf, current->com= m))) goto nla_put_failure; =20 nlmsg_end(skb, nlh); diff --git a/security/integrity/integrity_audit.c b/security/integrity/inte= grity_audit.c index 0ec5e4c22cb2..28c203f0cdb7 100644 --- a/security/integrity/integrity_audit.c +++ b/security/integrity/integrity_audit.c @@ -54,7 +54,8 @@ void integrity_audit_message(int audit_msgno, struct inod= e *inode, audit_get_sessionid(current)); audit_log_task_context(ab); audit_log_format(ab, " op=3D%s cause=3D%s comm=3D", op, cause); - audit_log_untrustedstring(ab, get_task_comm(name, current)); + strscpy_pad(name, current->comm); + audit_log_untrustedstring(ab, name); if (fname) { audit_log_format(ab, " name=3D"); audit_log_untrustedstring(ab, fname); diff --git a/security/ipe/audit.c b/security/ipe/audit.c index de5fed62592e..b4318988c65d 100644 --- a/security/ipe/audit.c +++ b/security/ipe/audit.c @@ -144,7 +144,7 @@ void ipe_audit_match(const struct ipe_eval_ctx *const c= tx, audit_log_format(ab, "ipe_op=3D%s ipe_hook=3D%s enforcing=3D%d pid=3D%d c= omm=3D", op, audit_hook_names[ctx->hook], READ_ONCE(enforce), task_tgid_nr(current)); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + audit_log_untrustedstring(ab, strscpy_pad(comm, current->comm)); =20 if (ctx->file) { audit_log_d_path(ab, " path=3D", &ctx->file->f_path); diff --git a/security/landlock/domain.c b/security/landlock/domain.c index a647b68e8d06..77b678f0f469 100644 --- a/security/landlock/domain.c +++ b/security/landlock/domain.c @@ -102,7 +102,7 @@ static struct landlock_details *get_current_details(voi= d) memcpy(details->exe_path, path_str, path_size); details->pid =3D get_pid(task_tgid(current)); details->uid =3D from_kuid(&init_user_ns, current_uid()); - get_task_comm(details->comm, current); + strscpy_pad(details->comm, current->comm); return details; } =20 diff --git a/security/lsm_audit.c b/security/lsm_audit.c index 7d623b00495c..b4d3b8a69cfe 100644 --- a/security/lsm_audit.c +++ b/security/lsm_audit.c @@ -276,8 +276,8 @@ void audit_log_lsm_data(struct audit_buffer *ab, if (pid) { char tskcomm[sizeof(tsk->comm)]; audit_log_format(ab, " opid=3D%d ocomm=3D", pid); - audit_log_untrustedstring(ab, - get_task_comm(tskcomm, tsk)); + strscpy_pad(tskcomm, tsk->comm); + audit_log_untrustedstring(ab, tskcomm); } } break; @@ -417,7 +417,8 @@ static void dump_common_audit_data(struct audit_buffer = *ab, char comm[sizeof(current->comm)]; =20 audit_log_format(ab, " pid=3D%d comm=3D", task_tgid_nr(current)); - audit_log_untrustedstring(ab, get_task_comm(comm, current)); + strscpy_pad(comm, current->comm); + audit_log_untrustedstring(ab, comm); audit_log_lsm_data(ab, a); } =20 --=20 2.38.1 From nobody Sat Oct 4 01:47:31 2025 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 583CE2F3C17; Thu, 21 Aug 2025 10:22:29 +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=1755771752; cv=none; b=IgmDnNwEt016CrhLZw482f9hJ5quMe7o2z07waUTW9wfE27KrTmSruorRg3zMk5O5AUbJzl3iBSdjioVGbekIekMpbM7GlhPY00T8FM+u3TY7i7Q5ETbwzb8QJy/ZrlHXv9Y8GCJxN51J5F1lMheSvOEIIj09OeXvoTRAzasq8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771752; c=relaxed/simple; bh=6vzw+P6ux+kbSuCNoGx4O3cEAX1Ajq3AvdBEK7oOUmk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jVDkZ36wNzyooOofGeICEbw1rOmKnCx/2F0icBBw3FSmseEeByVZrUfripIsjDZX/TrvlkyQrC4yOrS4mB+MZ0xbmh13EFMFjwm8xUihcZnzXXQqaIjLatLJq/F7Zro9Ym7hLYYXrPaxU5kT1WEf1kAqIOEDN1hfK57C+v+QZek= 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=W6WtSgol; 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="W6WtSgol" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=YqsTTNFtY7sLvLfKdk5uavi6kBouFmYvW/0kXiCyJt4=; b=W6WtSgol1JRfHGdppK4TBaac2y zESPO8TRh6da6tbLe5VfFj/fBPNoIIpPUXmPWY9lvhvveGLlhPO8MGnehRVf4CS9qAftCF6bkMWdX nnDlAGFKvj6iyJOACpXGkSQJ6CBj0HF0d9bOvdFdOYc7rZOjUM3TqdNcLRTYVwf39yJJW8t1395DD 1+1/RUVpCBtUFllgAkDx+RaUMUEDPl2hzWZueJense77c5lj+C2oDZXjngbW0H260c94Mds4Wa/kB wbW0Gvvzm92oa1U8tcYff7QHHrrbjlY3ZZI2nILwQOSNxWAyA9f2x+/HLAQcl6gx0GUcUgQRDJwiq l2dzavfA==; Received: from [223.233.68.152] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1up2R7-00HBmV-Np; Thu, 21 Aug 2025 12:22:26 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-trace-kernel@vger.kernel.org, kees@kernel.org, torvalds@linux-foundation.org Subject: [PATCH v8 4/5] treewide: Switch memcpy() users of 'task->comm' to a more safer implementation Date: Thu, 21 Aug 2025 15:51:51 +0530 Message-Id: <20250821102152.323367-5-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250821102152.323367-1-bhupesh@igalia.com> References: <20250821102152.323367-1-bhupesh@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As Linus mentioned in [1], currently we have several memcpy() use-cases which use 'current->comm' to copy the task name over to local copies. For an example: ... char comm[TASK_COMM_LEN]; memcpy(comm, current->comm, TASK_COMM_LEN); ... These should be rather calling a wrappper like "get_task_array()", which is implemented as: static __always_inline void __cstr_array_copy(char *dst, const char *src, __kernel_size_t size) { memcpy(dst, src, size); dst[size] =3D 0; } #define get_task_array(dst,src) \ __cstr_array_copy(dst, src, __must_be_array(dst)) The relevant 'memcpy()' users were identified using the following search pattern: $ git grep 'memcpy.*->comm\>' Link: https://lore.kernel.org/all/CAHk-=3Dwi5c=3D_-FBGo_88CowJd_F-Gi6Ud9d= =3DTALm65ReN7YjrMw@mail.gmail.com/ #1 Signed-off-by: Bhupesh --- include/linux/coredump.h | 2 +- include/linux/sched.h | 32 +++++++++++++++++++ include/linux/tracepoint.h | 4 +-- include/trace/events/block.h | 10 +++--- include/trace/events/oom.h | 2 +- include/trace/events/osnoise.h | 2 +- include/trace/events/sched.h | 13 ++++---- include/trace/events/signal.h | 2 +- include/trace/events/task.h | 4 +-- tools/bpf/bpftool/pids.c | 6 ++-- .../bpf/test_kmods/bpf_testmod-events.h | 2 +- 11 files changed, 54 insertions(+), 25 deletions(-) diff --git a/include/linux/coredump.h b/include/linux/coredump.h index 68861da4cf7c..bcee0afc5eaf 100644 --- a/include/linux/coredump.h +++ b/include/linux/coredump.h @@ -54,7 +54,7 @@ extern void vfs_coredump(const kernel_siginfo_t *siginfo); do { \ char comm[TASK_COMM_LEN]; \ /* This will always be NUL terminated. */ \ - memcpy(comm, current->comm, sizeof(comm)); \ + get_task_array(comm, current->comm); \ printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \ task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \ } while (0) \ diff --git a/include/linux/sched.h b/include/linux/sched.h index 5a58c1270474..d26d1dfb9904 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1960,12 +1960,44 @@ extern void wake_up_new_task(struct task_struct *ts= k); =20 extern void kick_process(struct task_struct *tsk); =20 +/* + * - Why not use task_lock()? + * User space can randomly change their names anyway, so locking for rea= ders + * doesn't make sense. For writers, locking is probably necessary, as a = race + * condition could lead to long-term mixed results. + * The logic inside __set_task_comm() should ensure that the task comm is + * always NUL-terminated and zero-padded. Therefore the race condition b= etween + * reader and writer is not an issue. + */ + extern void __set_task_comm(struct task_struct *tsk, const char *from, boo= l exec); #define set_task_comm(tsk, from) ({ \ BUILD_BUG_ON(sizeof(from) < TASK_COMM_LEN); \ __set_task_comm(tsk, from, false); \ }) =20 +/* + * 'get_task_array' can be 'data-racy' in the destination and + * should not be used for cases where a 'stable NUL at the end' + * is needed. Its better to use strscpy and friends for such + * use-cases. + * + * It is suited mainly for a 'just copy comm to a constant-sized + * array' case - especially in performance sensitive use-cases, + * like tracing. + */ + +static __always_inline void + __cstr_array_copy(char *dst, const char *src, + __kernel_size_t size) +{ + memcpy(dst, src, size); + dst[size] =3D 0; +} + +#define get_task_array(dst, src) \ + __cstr_array_copy(dst, src, __must_be_array(dst)) + static __always_inline void scheduler_ipi(void) { /* diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 826ce3f8e1f8..40e04cb660ce 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -570,10 +570,10 @@ static inline struct tracepoint *tracepoint_ptr_deref= (tracepoint_ptr_t *p) * * * * TP_fast_assign( - * memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); + * get_task_array(__entry->next_comm, next->comm); * __entry->prev_pid =3D prev->pid; * __entry->prev_prio =3D prev->prio; - * memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); + * get_task_array(__entry->prev_comm, prev->comm); * __entry->next_pid =3D next->pid; * __entry->next_prio =3D next->prio; * ), diff --git a/include/trace/events/block.h b/include/trace/events/block.h index 6aa79e2d799c..de1fe35333fc 100644 --- a/include/trace/events/block.h +++ b/include/trace/events/block.h @@ -213,7 +213,7 @@ DECLARE_EVENT_CLASS(block_rq, =20 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); __get_str(cmd)[0] =3D '\0'; - memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, current->comm); ), =20 TP_printk("%d,%d %s %u (%s) %llu + %u %s,%u,%u [%s]", @@ -351,7 +351,7 @@ DECLARE_EVENT_CLASS(block_bio, __entry->sector =3D bio->bi_iter.bi_sector; __entry->nr_sector =3D bio_sectors(bio); blk_fill_rwbs(__entry->rwbs, bio->bi_opf); - memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, current->comm); ), =20 TP_printk("%d,%d %s %llu + %u [%s]", @@ -434,7 +434,7 @@ TRACE_EVENT(block_plug, ), =20 TP_fast_assign( - memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, current->comm); ), =20 TP_printk("[%s]", __entry->comm) @@ -453,7 +453,7 @@ DECLARE_EVENT_CLASS(block_unplug, =20 TP_fast_assign( __entry->nr_rq =3D depth; - memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, current->comm); ), =20 TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) @@ -504,7 +504,7 @@ TRACE_EVENT(block_split, __entry->sector =3D bio->bi_iter.bi_sector; __entry->new_sector =3D new_sector; blk_fill_rwbs(__entry->rwbs, bio->bi_opf); - memcpy(__entry->comm, current->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, current->comm); ), =20 TP_printk("%d,%d %s %llu / %llu [%s]", diff --git a/include/trace/events/oom.h b/include/trace/events/oom.h index 9f0a5d1482c4..31e5b7295188 100644 --- a/include/trace/events/oom.h +++ b/include/trace/events/oom.h @@ -23,7 +23,7 @@ TRACE_EVENT(oom_score_adj_update, =20 TP_fast_assign( __entry->pid =3D task->pid; - memcpy(__entry->comm, task->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, task->comm); __entry->oom_score_adj =3D task->signal->oom_score_adj; ), =20 diff --git a/include/trace/events/osnoise.h b/include/trace/events/osnoise.h index 3f4273623801..f67f8b5eca75 100644 --- a/include/trace/events/osnoise.h +++ b/include/trace/events/osnoise.h @@ -116,7 +116,7 @@ TRACE_EVENT(thread_noise, ), =20 TP_fast_assign( - memcpy(__entry->comm, t->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, t->comm); __entry->pid =3D t->pid; __entry->start =3D start; __entry->duration =3D duration; diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index 7b2645b50e78..66fe808f2654 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -152,7 +152,7 @@ DECLARE_EVENT_CLASS(sched_wakeup_template, ), =20 TP_fast_assign( - memcpy(__entry->comm, p->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, p->comm); __entry->pid =3D p->pid; __entry->prio =3D p->prio; /* XXX SCHED_DEADLINE */ __entry->target_cpu =3D task_cpu(p); @@ -237,11 +237,11 @@ TRACE_EVENT(sched_switch, ), =20 TP_fast_assign( - memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); + get_task_array(__entry->prev_comm, prev->comm); __entry->prev_pid =3D prev->pid; __entry->prev_prio =3D prev->prio; __entry->prev_state =3D __trace_sched_switch_state(preempt, prev_state, = prev); - memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); + get_task_array(__entry->next_comm, next->comm); __entry->next_pid =3D next->pid; __entry->next_prio =3D next->prio; /* XXX SCHED_DEADLINE */ @@ -346,7 +346,7 @@ TRACE_EVENT(sched_process_exit, ), =20 TP_fast_assign( - memcpy(__entry->comm, p->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, p->comm); __entry->pid =3D p->pid; __entry->prio =3D p->prio; /* XXX SCHED_DEADLINE */ __entry->group_dead =3D group_dead; @@ -787,14 +787,13 @@ TRACE_EVENT(sched_skip_cpuset_numa, ), =20 TP_fast_assign( - memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, tsk->comm); __entry->pid =3D task_pid_nr(tsk); __entry->tgid =3D task_tgid_nr(tsk); __entry->ngid =3D task_numa_group_id(tsk); BUILD_BUG_ON(sizeof(nodemask_t) !=3D \ BITS_TO_LONGS(MAX_NUMNODES) * sizeof(long)); - memcpy(__entry->mem_allowed, mem_allowed_ptr->bits, - sizeof(__entry->mem_allowed)); + get_task_array(__entry->mem_allowed, mem_allowed_ptr->bits); ), =20 TP_printk("comm=3D%s pid=3D%d tgid=3D%d ngid=3D%d mem_nodes_allowed=3D%*p= bl", diff --git a/include/trace/events/signal.h b/include/trace/events/signal.h index 1db7e4b07c01..0681dc5ab1de 100644 --- a/include/trace/events/signal.h +++ b/include/trace/events/signal.h @@ -67,7 +67,7 @@ TRACE_EVENT(signal_generate, TP_fast_assign( __entry->sig =3D sig; TP_STORE_SIGINFO(__entry, info); - memcpy(__entry->comm, task->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, task->comm); __entry->pid =3D task->pid; __entry->group =3D group; __entry->result =3D result; diff --git a/include/trace/events/task.h b/include/trace/events/task.h index af535b053033..9553946943a6 100644 --- a/include/trace/events/task.h +++ b/include/trace/events/task.h @@ -21,7 +21,7 @@ TRACE_EVENT(task_newtask, =20 TP_fast_assign( __entry->pid =3D task->pid; - memcpy(__entry->comm, task->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, task->comm); __entry->clone_flags =3D clone_flags; __entry->oom_score_adj =3D task->signal->oom_score_adj; ), @@ -44,7 +44,7 @@ TRACE_EVENT(task_rename, ), =20 TP_fast_assign( - memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN); + get_task_array(entry->oldcomm, task->comm); strscpy(entry->newcomm, comm, TASK_COMM_LEN); __entry->oom_score_adj =3D task->signal->oom_score_adj; ), diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c index 23f488cf1740..a5d339cb8ca3 100644 --- a/tools/bpf/bpftool/pids.c +++ b/tools/bpf/bpftool/pids.c @@ -53,8 +53,7 @@ static void add_ref(struct hashmap *map, struct pid_iter_= entry *e) refs->refs =3D tmp; ref =3D &refs->refs[refs->ref_cnt]; ref->pid =3D e->pid; - memcpy(ref->comm, e->comm, sizeof(ref->comm)); - ref->comm[sizeof(ref->comm) - 1] =3D '\0'; + get_task_array(ref->comm, e->comm); refs->ref_cnt++; =20 return; @@ -77,8 +76,7 @@ static void add_ref(struct hashmap *map, struct pid_iter_= entry *e) } ref =3D &refs->refs[0]; ref->pid =3D e->pid; - memcpy(ref->comm, e->comm, sizeof(ref->comm)); - ref->comm[sizeof(ref->comm) - 1] =3D '\0'; + get_task_array(ref->comm, e->comm); refs->ref_cnt =3D 1; refs->has_bpf_cookie =3D e->has_bpf_cookie; refs->bpf_cookie =3D e->bpf_cookie; diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h b/= tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h index aeef86b3da74..81880748550f 100644 --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h @@ -20,7 +20,7 @@ TRACE_EVENT(bpf_testmod_test_read, ), TP_fast_assign( __entry->pid =3D task->pid; - memcpy(__entry->comm, task->comm, TASK_COMM_LEN); + get_task_array(__entry->comm, task->comm); __entry->off =3D ctx->off; __entry->len =3D ctx->len; ), --=20 2.38.1 From nobody Sat Oct 4 01:47:31 2025 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 EB3A32FDC3C; Thu, 21 Aug 2025 10:22:34 +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=1755771757; cv=none; b=icPcxL/7ygMUt8zQp5VqvoI32Y+EKWQAaKIofGpOZWQxaH2KgynarWnLmp4QpfsGYdxm8DRqMViVgm4D2KVvjpXO81BZzOkIlZiSM8wovZKT8KzwfjeBsLAt6wlaNlnSDHm+7MzUQ1cGdymwYhwdpd8VzHBKz1tlNDL47mBw0Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771757; c=relaxed/simple; bh=wvaUmALRQLnARKD+yeMOhpT7bXS/e9AoONMp4b6P1Vg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O0dhufU5uxImO8DAgvnQ16n/CWFZFEH6BvN3jE7aNgXaPsUKBb1LW5SZaLfb+7JlFuER3MiwR+ScbKq6iuvIFO4NCRySiwB7bgyxq86JJ4teeX5qOndQ5cETzigxSmib7t9LxskT5pJ9HLFzw+b08pvfjEKoAF0mSyZ5shiV8bw= 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=dcitShqS; 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="dcitShqS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=VqJEmr/n09REC8+UBB9VEKt7Poxqe/QefzeRVIsvj6A=; b=dcitShqSPUuBBKA4+9P37TcOhG u7PqftO+reDMPuDKrTaP4COiidnrQNYhqrUuz9RukvpTJp2gJpPv4W/YtsqtSG8g8AquTq3IprFER VxAVoVW8/k2sFNeNg2R2p8YJ8JKugf02aO5keT0AxLXt3mr54ivsCOMEcnqJK3qUhTk/zjAW6CArQ MwBPbyfWOrwyFPUlTSmn6W9xU4xiVNNafCN6t7gVsnlmxzmgx7THcsJOtBGW9CqoZFda7OcOYQ33K g1cHk59nVGk+2UdcdyIUxwskYIMot9FQ3Yy4WLFfhaArAJQK0uzyMDmz/GUy0GnrA1Q/FJW5aEmo4 7JXrWb/A==; Received: from [223.233.68.152] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1up2RD-00HBmV-Hy; Thu, 21 Aug 2025 12:22:31 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-trace-kernel@vger.kernel.org, kees@kernel.org, torvalds@linux-foundation.org Subject: [PATCH v8 5/5] include: Replace BUILD_BUG_ON with static_assert in 'set_task_comm()' Date: Thu, 21 Aug 2025 15:51:52 +0530 Message-Id: <20250821102152.323367-6-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250821102152.323367-1-bhupesh@igalia.com> References: <20250821102152.323367-1-bhupesh@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace BUILD_BUG_ON() with static_assert() inside 'set_task_comm()', to benefit from the error message available with static_assert(). Signed-off-by: Bhupesh --- include/linux/sched.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index d26d1dfb9904..2603a674ee22 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1972,7 +1972,8 @@ extern void kick_process(struct task_struct *tsk); =20 extern void __set_task_comm(struct task_struct *tsk, const char *from, boo= l exec); #define set_task_comm(tsk, from) ({ \ - BUILD_BUG_ON(sizeof(from) < TASK_COMM_LEN); \ + static_assert(sizeof(from) >=3D TASK_COMM_LEN, \ + "tsk->comm size being set should be >=3D TASK_COMM_LEN"); \ __set_task_comm(tsk, from, false); \ }) =20 --=20 2.38.1