From patchwork Fri Dec 13 05:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D7AFE7717F for ; Fri, 13 Dec 2024 14:02:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 108BA10F021; Fri, 13 Dec 2024 14:02:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NKATDm9k"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by gabe.freedesktop.org (Postfix) with ESMTPS id 77DE710E074; Fri, 13 Dec 2024 05:46:52 +0000 (UTC) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2161eb95317so12934855ad.1; Thu, 12 Dec 2024 21:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068812; x=1734673612; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yq/q3oQ+1coBzSyYiu7PIQ9YY0FE8S8wlVnD6GFmf1s=; b=NKATDm9kWEnh8wI6I25i/UyYOqc8SqyoqKlWX3z5D38k3QbBN/L3Q0SosEl5hoCXyp mGXKC1g5TIqAmozRuXW+o1Nz5KkCATM3Qaxg6I57oFw4HJXhCmEpHjok7z+euo6jWb4o eIckCEw3jH1VTChWGNhjrPH9YKus1ab0tUzojQfZiWobejOnhi5e8VEZ3onL8jr4uoil mFpqdga0Ixa/kMMlVR2+fscvcqEvXCu9Ir7Ns1ZrU+3BOvWqcWYagi4UPbbMTlde+ykE HNEBXne75ZNuI+mfvNcSM1Y12z7yXlFlhclFh9F3r7o6gWczSs2uyP2i7ZIzRtXJOzEj TiOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068812; x=1734673612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yq/q3oQ+1coBzSyYiu7PIQ9YY0FE8S8wlVnD6GFmf1s=; b=N1N2sYKl+olTQmXmhEcQMS+otg2RvcuVkW0gQyyHA2A6ScxgkuCkLekhMGtLcCdext M4GM9Z49f8EaZPlNFj6QeWbQu8Cz2EyD6JitfIqdnetaNdqT7IIXP6oXhRy1s8x5uKrU eZKLH9IXa8UKRRubT/4z0Zjr5n/2emw8MbmVHVwX6kj6TZtDKBP5FtRRrU519viZVXyM 4ju07wgl5V6Y3anH6gSqZcpr+5Y9nyS1nLls2MSJZ97clzcXv/Z77vCYi94o82SbM9/M 3PBZQvoFBbsju+v9bTiwSZftNE3UaEPmNhz6x609pZNJ3JBJj13C3hiL+H0OqnTIXB8A RIlA== X-Forwarded-Encrypted: i=1; AJvYcCUVV6c+BTdm+daVY7T4bcu20MT5YbzKYpHqniQKxKQFNh8kjjvCnPU68Hqq4TCTGAAtpa1/41rxTw==@lists.freedesktop.org, AJvYcCVQMvoZsOewL0hs2GJ+a3EPDOykQI7JI4/ugNkkLc7UPpI9yL9wkSFiEaKXog6aaSfobNDNC3T9i/c=@lists.freedesktop.org, AJvYcCVjf1W3hvkE8c3JCWW6e5sF7kh1jTokhjmpVgFYCoCQ5utQPXJ4LEKYNJs7oO3HGj2M3K9f0TMuMpU=@lists.freedesktop.org, AJvYcCX3zU5+Vsu67wMvoG5i44kiWJdwaVvcbxW4Dw7Elo1vvt9X3SB1TEkUk13DwHSlpHYnSy6rknuG6ZF0@lists.freedesktop.org X-Gm-Message-State: AOJu0Yy6UzLbAdFP5T5w9TKeXi6Wh+VSvFtuitFJu0RaAi2hQiCuXaYQ Uy50iIUm+TGsA0mpmc9w4dy3M/doW8Mh2vBQQg0RdO3zIjWGFTDx X-Gm-Gg: ASbGncvcR/BvKqvh6PbLuFEdV7woJZ9a/SHglt+uZPELWgfyVLPGQCB1Z65Dv2L5T9K 8W8ih37ddvcpd3XFYt6EVD9Pl3GyWxMY7EWJFAp8+3Rs4N2ceDt6BIvXV/ga7/+kFneXVKOaf2l qlzL1LFhnUmjR1tx0PdFQGk0o2WfT7aWjFHPnXpXV4qNpy+cgswzIQ7PelApLYqhYOdn/E2RsPI NBE254HWlgytxBsVD9RfLp8zbwmqV/kyW2e1qcHP4vnST8LpIlT8qCXeTbJztCCBmpdMvMrcWHj UFltnNo= X-Google-Smtp-Source: AGHT+IFWBnsyszL3fKLErMwBwi/nv5YJk8bNHSLutoorKV6bDApMEi8hBMM4652Yq5VqnH7LBX6qQg== X-Received: by 2002:a17:903:2a8d:b0:215:a3e4:d251 with SMTP id d9443c01a7336-2189298bb21mr20543965ad.6.1734068811964; Thu, 12 Dec 2024 21:46:51 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.46.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:46:51 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH 1/7] vsprintf: Add %pTN to print task name Date: Fri, 13 Dec 2024 13:46:04 +0800 Message-Id: <20241213054610.55843-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since the task->comm is guaranteed to be NUL-ternimated, we can print it directly. Add a new vsnprintf format specifier "%pTN" to print task comm, where 'p' represents the task Pointer, 'T' stands for Task, and 'N' denots Name. With this abstraction, the user no longer needs to care about retrieving task name. checkpatch.pl is updated accordingly. Link: https://lore.kernel.org/bpf/CAHk-=wgqrwFXK-CO8-V4fwUh5ymnUZ=wJnFyufV1dM9rC1t3Lg@mail.gmail.com Suggested-by: Linus Torvalds Signed-off-by: Yafang Shao Cc: Andrew Morton Cc: Petr Mladek Cc: Steven Rostedt Cc: Andy Shevchenko Cc: Rasmus Villemoes Cc: Sergey Senozhatsky Cc: Andy Whitcroft Cc: Joe Perches Cc: Dwaipayan Ray Cc: Lukas Bulwahn --- lib/vsprintf.c | 18 ++++++++++++++++++ scripts/checkpatch.pl | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6ac02bbb7df1..bb1018d79655 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2273,6 +2273,17 @@ char *resource_or_range(const char *fmt, char *buf, char *end, void *ptr, return resource_string(buf, end, ptr, spec, fmt); } +static noinline_for_stack +char *task_name_string(char *buf, char *end, struct task_struct *p, + struct printf_spec spec) +{ + if (check_pointer(&buf, end, p, spec)) + return buf; + + buf = string(buf, end, p->comm, spec); + return buf; +} + int __init no_hash_pointers_enable(char *str) { if (no_hash_pointers) @@ -2525,6 +2536,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, default: return error_string(buf, end, "(einval)", spec); } + case 'T': + switch (fmt[1]) { + case 'N': + return task_name_string(buf, end, ptr, spec); + default: + return error_string(buf, end, "(einval)", spec); + } default: return default_pointer(buf, end, ptr, spec); } diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9eed3683ad76..fe0d80f55ce8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6908,11 +6908,13 @@ sub process { $specifier = $1; $extension = $2; $qualifier = $3; - if ($extension !~ /[4SsBKRraEehMmIiUDdgVCbGNOxtf]/ || + if ($extension !~ /[4SsBKRraEehMmIiUDdgVCbGNOxtfT]/ || ($extension eq "f" && defined $qualifier && $qualifier !~ /^w/) || ($extension eq "4" && - defined $qualifier && $qualifier !~ /^cc/)) { + defined $qualifier && $qualifier !~ /^cc/) || + ($extension eq "T" && + defined $qualifier && $qualifier ne "N")) { $bad_specifier = $specifier; last; } From patchwork Fri Dec 13 05:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19C08E77180 for ; Fri, 13 Dec 2024 14:02:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73CCF10F018; Fri, 13 Dec 2024 14:02:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GakuZVnt"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01CC810E238; Fri, 13 Dec 2024 05:46:59 +0000 (UTC) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-21636268e43so18023675ad.2; Thu, 12 Dec 2024 21:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068819; x=1734673619; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fVaAhWgLsrOIaawWt+Es3lyBYssP2HU9Cngct4cKfGw=; b=GakuZVntB6g7YpyRFXN1LbQaFvhX6Tp4C8dD626BGiWJJ8miCR2UhHBtB7tF8EdU8b 2+vNf/6vroXgQ6i52QtCoMPhLgm6mr1IYlqNaqXbmiTnfKa7BRDL/ff88hgD1F8EY1GA TD9z/8lQPo0TY7c3/y3L7wN0fxw3p0mnUg3lFeLe+PcVwZYz/bLm8LD0pncxItqUcZql 9xx2voDZ31Y3FlxQbTRPir2wXbdY8RagkuUNMf7AoKGsmi4elQ8WT5CWgxOtNvy1EPwJ KMRH9FWNzxovAMm0AGEMoRTZ5PqJHU2ZA6wn4tGRIg2SXUzgZ+YBI26Nu5802I8HwGBH 4CIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068819; x=1734673619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fVaAhWgLsrOIaawWt+Es3lyBYssP2HU9Cngct4cKfGw=; b=Z1Al96d1fL4r9t2EjTkugLXuI0xor/2ms9V8xx/IgIvWEKNPOUSYkIKJsYFbZypXWP 2q6hCWXDvpT8a4WhaJWQzk6d0+jcFmkhbCs8YLvrEzmSvDgrHCELxX2OrvISz7MvK9W8 AIUS2bxdJMMKI/lSaHoohOkMbA3JVuM6J74JZhp5LXOITpqOnEimbsK652GPeWHSafUe /q0tG8qe+eZHxiSpme018+ixhDGvDraXgECVZQjvuvFnFyReFwJ4DaYO77pgx30e44rc pWrem8XZKHjYYgaGXmJJUAQbWSOUkLzUOeZuQ2P4hJBFHOd+2MbVhhuVW2ATjT/QzVO4 PfhA== X-Forwarded-Encrypted: i=1; AJvYcCUJJtT0kFOWVEv3VxhQRX+oTYrbEcrbeBAzAJqAe6OdfpMQeC3y8RWwLkoD3x7sFsr1JdaOWEDuJw==@lists.freedesktop.org, AJvYcCVNZ3zokedkAsWjJ7xk6cxLC0JIBVO517mcI26ATgTKKM2AkrteM3gJX7Xs3gyvDGUfwaFBr2g0sDg=@lists.freedesktop.org, AJvYcCWqiMKjXEs42LwXYNTrUVfyvoqf5vYqaFN3jP52Fk9THebwvqKYrrNgj6W4hLkGhrRyF2BXcIlefvg6@lists.freedesktop.org, AJvYcCXsiJS9IsxTwP0fanebPlfWVYCUXnVxjhc6t56iJszZiRTZE37psfhDTivKagEaVPtz6IXGbgd1hrs=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yzk7C3ITsCz1kD0wUtFddwUFHR9hcHrpvgnIk2+fwQzFrw0SbGa 72+1cWCBtpVT1Eg06hlemej+27igEjUEEwmfylsPFc+27BER6j86 X-Gm-Gg: ASbGncvrupJm5nvhOc+ls9OksrE1EbczdoNiszt90N+Lb+G9hyHlxqQzU3s7YmOrKZR wp2Y2hiivTe79AEVrHihlB1Ep67zoqLI2jIvGqtkVIKFA0DZZOpbyrGf0L0fcD/dSQphSFu4n2M IVnvJkKq3nHeCYgSo6UBZgnWRZtpwzo81WpEjB4WkvpLPcGpCLh4UoJz9ySVZJfDkgcZXuaxOEn 490q3wAGg9f+aaCPft6bvmyUz0wh5nWorgCVDabrDGKyQFh24+NlNSpG5SR7F8CZndK2vfiy55M CgeGeZI= X-Google-Smtp-Source: AGHT+IGnQMpyX4qO4c9TaUxIvkW9bvqpb4HtTDVE3C9gZFkXCVV6ksZB8lAWhFJzpiBj11HO1t8PNw== X-Received: by 2002:a17:902:e88b:b0:212:615f:c1 with SMTP id d9443c01a7336-218929a19c2mr20599995ad.14.1734068819460; Thu, 12 Dec 2024 21:46:59 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.46.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:46:58 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Serge Hallyn , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 2/7] kernel: Replace get_task_comm() with %pTN Date: Fri, 13 Dec 2024 13:46:05 +0800 Message-Id: <20241213054610.55843-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copye it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Serge Hallyn Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Darren Hart Cc: Davidlohr Bueso Cc: "André Almeida" --- kernel/capability.c | 12 ++++-------- kernel/futex/waitwake.c | 5 ++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/kernel/capability.c b/kernel/capability.c index dac4df77e376..4512cd797f49 100644 --- a/kernel/capability.c +++ b/kernel/capability.c @@ -38,10 +38,8 @@ __setup("no_file_caps", file_caps_disable); static void warn_legacy_capability_use(void) { - char name[sizeof(current->comm)]; - - pr_info_once("warning: `%s' uses 32-bit capabilities (legacy support in use)\n", - get_task_comm(name, current)); + pr_info_once("warning: `%pTN' uses 32-bit capabilities (legacy support in use)\n", + current); } /* @@ -62,10 +60,8 @@ static void warn_legacy_capability_use(void) static void warn_deprecated_v2(void) { - char name[sizeof(current->comm)]; - - pr_info_once("warning: `%s' uses deprecated v2 capabilities in a way that may be insecure\n", - get_task_comm(name, current)); + pr_info_once("warning: `%pTN' uses deprecated v2 capabilities in a way that may be insecure\n", + current); } /* diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c index 3a10375d9521..df8f8c85d776 100644 --- a/kernel/futex/waitwake.c +++ b/kernel/futex/waitwake.c @@ -210,13 +210,12 @@ static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr) if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) { if (oparg < 0 || oparg > 31) { - char comm[sizeof(current->comm)]; /* * kill this print and return -EINVAL when userspace * is sane again */ - pr_info_ratelimited("futex_wake_op: %s tries to shift op by %d; fix this program\n", - get_task_comm(comm, current), oparg); + pr_info_ratelimited("futex_wake_op: %pTN tries to shift op by %d; fix this program\n", + current, oparg); oparg &= 31; } oparg = 1 << oparg; From patchwork Fri Dec 13 05:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC6BAE7717D for ; Fri, 13 Dec 2024 14:02:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 81C4510F01D; Fri, 13 Dec 2024 14:02:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HKckgVgk"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9276B10E441; Fri, 13 Dec 2024 05:47:07 +0000 (UTC) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2165448243fso14748985ad.1; Thu, 12 Dec 2024 21:47:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068827; x=1734673627; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EmVT0W96xTTbgIHaje9qHPh+sH+dkYFHuEVe3qXraIA=; b=HKckgVgkXR8lst/xQOO3A2Mllj2EiENfQvsczcRf40JZ8kQ4LE4Bjaf0MGldiIp9zi BzxOUnDqs1inF7fjN8unovxw2On1rf3KkmAcdOWmvfzgDi7pEJDb95LFdDlpsEJAOVXL ZAoFzoPmeeT0Bc5sp9nAR0rkX7OBjhXMdc6ugKMeo7gHsk2JSaEtnf1zlTrWzagDnKVX t8UM0YM50PU1JaRQPj39715TJ7JGudUMJkFT8UXjHyqeE5iQ/a+F7Uais91E4Okrt7ku 11Ut8avMT1uCtb7SuR87kmQymPz8K2DyddG1py8+W/fS3Fcyi23MnTk/kxevPhViBulf J9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068827; x=1734673627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EmVT0W96xTTbgIHaje9qHPh+sH+dkYFHuEVe3qXraIA=; b=cweL9r/SN64G1vndWKSSPAsNjvOVffgBaQy3qOo9+Aebs3KV5EMTV2ON0bIA2YWaKl cR/+v0hDyozhPvmvL7cqw9f4L5ntvJkl7mMkWQerGzBYp2kk+KCLMsJTMmaoItR2+cR4 2uw1Qru0v65w7PMkXp7r8t4zXD8G69kNvMIEvlyZtvSm4XbpT75GHGr7byniPXz5YGBk WpyQIvqo26lwuiKwf1Sw0Rf/881kRn2hK6M3/mzVvfvsHUsm3dkrt9h2sv572fz96kjR XP5zyonkQ7G2JKhPEy+zGlYeVdITo3seFGlGqzPuS6xpf510wJVxs2PkkDZMr3x4SQtj BFFw== X-Forwarded-Encrypted: i=1; AJvYcCUN2YJJoXHS8uOMOcwhi0kBh0irYqPhWPrb/XkDwdEEjkOllaOGxwW9ZFA9Lck2fbB6KlRi729FTKAD@lists.freedesktop.org, AJvYcCV+bwF/zGLLVcUMG2LEjMXjsK446F6JqEJLyUUQ8HNkzjWj+/x2tLwWNOS5+haDLXr6zyERu4bZC3g=@lists.freedesktop.org, AJvYcCVIkCuDOr5mzMGO9X6ILsRQODbUJBSddIZBQKou7xp5JH7XtA9yui+S7N+Eces+wruzIQAhC9Oy+g==@lists.freedesktop.org, AJvYcCXVG+IDi/KPyaih+MOts/dfhYxnXTWqdhDeXqCq9xkhrJ1Pjv0MgUyIeQVm9emswz7YCVnSIK35qPE=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzvC01oMfJ6XRQBJ0psznOgFjqohGH8n5B4KbLDCgmH9b7eRrM9 X6lAOG1KDOKkqUslA/OamNobhlZbFbKW8KWPF+2Zb/8insutdDz/ X-Gm-Gg: ASbGnctgchtJyQbmurXVAeDNQrVAKrlWKUvNrFFtO8oGuhpdAaozgKdjWtPVvLqDsbq oHcQOitf2UtzOxDoVMZDu83wQAe6TEV3+c7sh2ZSMtu6seRMaV1GxhstvPAQGXuzCnghtzIYzME ik6Ym0TLZQ3A5MY+joEKljdfq0Hs/UmKLfWlq5sSwLdtJ0ZlpsYPMT1W5bsQwafcNJFye1O7mdd XLBS0eBmFsIrKf3wu/Rpm6sOrwSYN7ZKRN0aDDtg3PtdYOX3JSyAR/KS9NpLCTd+LPgbsZ895dk IUWc0/0= X-Google-Smtp-Source: AGHT+IGGw/OV/ScatMLc+XWrd5qwOO8iHzpYdxpzWycga8KUsVtQ1P1ntSP55wYL5SQs/JpC5cq7/g== X-Received: by 2002:a17:902:d484:b0:215:431f:268f with SMTP id d9443c01a7336-21892999536mr21105555ad.10.1734068827157; Thu, 12 Dec 2024 21:47:07 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.47.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:47:06 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Vineet Gupta , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH 3/7] arch: Replace get_task_comm() with %pTN Date: Fri, 13 Dec 2024 13:46:06 +0800 Message-Id: <20241213054610.55843-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Vineet Gupta Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/arc/kernel/unaligned.c | 9 ++++----- arch/x86/kernel/vm86_32.c | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arc/kernel/unaligned.c b/arch/arc/kernel/unaligned.c index d2f5ceaaed1b..fb8e995823e3 100644 --- a/arch/arc/kernel/unaligned.c +++ b/arch/arc/kernel/unaligned.c @@ -200,23 +200,22 @@ int misaligned_fixup(unsigned long address, struct pt_regs *regs, struct callee_regs *cregs) { struct disasm_state state; - char buf[TASK_COMM_LEN]; /* handle user mode only and only if enabled by sysadmin */ if (!user_mode(regs) || !unaligned_enabled) return 1; if (no_unaligned_warning) { - pr_warn_once("%s(%d) made unaligned access which was emulated" + pr_warn_once("%pTN(%d) made unaligned access which was emulated" " by kernel assist\n. This can degrade application" " performance significantly\n. To enable further" " logging of such instances, please \n" " echo 0 > /proc/sys/kernel/ignore-unaligned-usertrap\n", - get_task_comm(buf, current), task_pid_nr(current)); + current, task_pid_nr(current)); } else { /* Add rate limiting if it gets down to it */ - pr_warn("%s(%d): unaligned access to/from 0x%lx by PC: 0x%lx\n", - get_task_comm(buf, current), task_pid_nr(current), + pr_warn("%pTN(%d): unaligned access to/from 0x%lx by PC: 0x%lx\n", + current, task_pid_nr(current), address, regs->ret); } diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c index e9e803a4d44c..1f55d5c2628d 100644 --- a/arch/x86/kernel/vm86_32.c +++ b/arch/x86/kernel/vm86_32.c @@ -246,9 +246,8 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus) /* VM86_SCREEN_BITMAP had numerous bugs and appears to have no users. */ if (v.flags & VM86_SCREEN_BITMAP) { - char comm[TASK_COMM_LEN]; - - pr_info_once("vm86: '%s' uses VM86_SCREEN_BITMAP, which is no longer supported\n", get_task_comm(comm, current)); + pr_info_once("vm86: '%pTN' uses VM86_SCREEN_BITMAP, which is no longer supported\n", + current); return -EINVAL; } From patchwork Fri Dec 13 05:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C3B3E7717F for ; Fri, 13 Dec 2024 14:02:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5E9410F019; Fri, 13 Dec 2024 14:02:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SooqcpWO"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0FACB10E4E1; Fri, 13 Dec 2024 05:47:14 +0000 (UTC) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2166022c5caso12160875ad.2; Thu, 12 Dec 2024 21:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068833; x=1734673633; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gS7oaK0RsPIguog+zKCBYVnzq+DdL6weynD0punt/E0=; b=SooqcpWOMyT6L+d+J8A3U+MM6HS1Zct3Uya92glSX1EsZwBrCuMRBjQaB6G6XmZBKX OhLz9+fsvP3tFVeXM7+thySamGOtqs/gFs2tjE/nqvwcsKLThtGtI7ix+lFKVgLqFhDY jOoP25O7oOoITZPjoeYwqHpelrbXHESqmBYJtMmpX+HYm1FDetf7PO7pGxPIgAYREhrj MRS5stK3MauoY14vGXaPxZ8XjyB66SLbQ0oJfrdbRUiQJxnLwqlPl4tK/zJQyuiAI1JF k5pG1eBUqn5rkop5m/GJmvVnXl6nMyfzx7oT7Fdp2ODjsmWPYu0EliWercV0Hqm9mNKO 4iVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068833; x=1734673633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gS7oaK0RsPIguog+zKCBYVnzq+DdL6weynD0punt/E0=; b=hcrQr/q5Oyxb4i2SNljT6oH9IK0BCnWBxLrAZfZuLpvU8rOoZCTB8F/DZL1UWUv+GA Qmcpp4jzN/u6xhr/g98+xE8Va20AcTLBEhv68qORry9txwsqh8pIXNKgMvGb6Q240tFP XcIzChjEg+NCg+nr+7aGC8LcSnQAvM8vrWkBIdbFOJ0btTqW17vj8s+NU8mVVAluqIt5 mOSOOMFs1UypVWRgPf3vJm/SFgiVgxB0gJugrr6RKngIzLEJ0wk23F2ebfV2GLHCZbyz AGiPY2pMAPd6Uo7DoCxS83v0IRykdr6zDRcK/7iQwzFDLGxMVNeRoYOwG9Ram0fiPtoy XYng== X-Forwarded-Encrypted: i=1; AJvYcCUCa8MZT7JxxkR+Wn3CtC/w3e3o3rJPemQbtEYH7Ps84GuyHaOjq7UEYS79vSovDEmm/B/bzISB2JCh@lists.freedesktop.org, AJvYcCVVbESmras5uK42Vgfasp7ClkBlEbvL8jLLU+pRuVj1GrqhtTPNVOe3lUYJROUiqxf21tOEc4cvAs4=@lists.freedesktop.org, AJvYcCWXjZ3bENLnflz78b8GANS87lyRWES8YIXymmUo8dYLrETuv5s/tZd6T/eS3hX0IJBE3dl3JvMH4w==@lists.freedesktop.org, AJvYcCXCa+THm8osG364Y3SpXFzGma5+igllk+8N8bbtW6kpwT2QIxIT7QJIZ9ffuX+fc+v7ZF8dSUMSJkQ=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwUPY780y6GReLjARmsBGoKodW72tdbvcJtJQSwumDUo1w3JY06 gyi7Pe8SfxgoXBiP8qSLN/m9tVRQu1zuBYT1wdhvC/wtQ1BQH86c+pNda9fHFm4= X-Gm-Gg: ASbGncu1IQUDFe8mqzBTQ/enmjFTglyicHNaTNRT3jJqkYBSQtwn3lghP5WZamCeQw2 bwhmj0KmoBC+nbg18DBG4249aIjvVqHKOOLe8H+l89pAxDuYR8f5ntgZAf14nyjMeBd1zmitgKy YRIKPbDOYy8KYpVrX+m/pJWYKrSLZgAQLF9SYeWje9z7gCzRYSiFkiHFIh8dulEHjqly0jVV3rE pWCkiHbRDvs8TGee5nhGsIa9Wbf1IPRML9XKmmj5nnkB5Sv7ZwcqJoDhK3dXSm6EqbYkkq1Rf26 JGhe5T0= X-Google-Smtp-Source: AGHT+IG/u9vPHYJsr72JqaDrYLM72r0Mv+gF1sZwvgldiU0c1giVELNbwcEluD8XRP6pboK2QDHicw== X-Received: by 2002:a17:902:f60c:b0:216:7c33:8994 with SMTP id d9443c01a7336-21892a7a811mr23989435ad.53.1734068833602; Thu, 12 Dec 2024 21:47:13 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.47.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:47:13 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Johannes Berg Subject: [PATCH 4/7] net: Replace get_task_comm() with %pTN Date: Fri, 13 Dec 2024 13:46:07 +0800 Message-Id: <20241213054610.55843-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Johannes Berg --- net/wireless/wext-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index 3bb04b05c5ce..1f2a7ab546ba 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c @@ -640,10 +640,8 @@ EXPORT_SYMBOL(wireless_send_event); #ifdef CONFIG_CFG80211_WEXT static void wireless_warn_cfg80211_wext(void) { - char name[sizeof(current->comm)]; - - pr_warn_once("warning: `%s' uses wireless extensions which will stop working for Wi-Fi 7 hardware; use nl80211\n", - get_task_comm(name, current)); + pr_warn_once("warning: `%pTN' uses wireless extensions which will stop working for Wi-Fi 7 hardware; use nl80211\n", + current); } #endif From patchwork Fri Dec 13 05:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B572E7717D for ; Fri, 13 Dec 2024 14:02:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E315410F012; Fri, 13 Dec 2024 14:02:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N9q6gLfV"; dkim-atps=neutral Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by gabe.freedesktop.org (Postfix) with ESMTPS id C332610E673; Fri, 13 Dec 2024 05:47:20 +0000 (UTC) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2167141dfa1so12331935ad.1; Thu, 12 Dec 2024 21:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068840; x=1734673640; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XQpRmGydqcdMOxZRzmLm98GnY2wtgMQ5ZotZeI2M2YQ=; b=N9q6gLfVavC1GU2+eutoMhVmrqo+SE0dOsUv7F9/ws+UP6mUtV4i3ctUhi1kuuEALu RBKoP5eUBROiDQ39IeupNpIGKbBkCEvjVw4oXon3+7jCG+kvLuH+vKs/kf2v7dd3ecJK yD00N96UNWm28N+PBB7w2xwFgPOSnB1eW1Hegaemsql0wHow5Dd7ldXl9GmnglK7nd+R B7M5jQ/LQJ0STlXtrhVrinZhtjO4ploPFZPkO9qASztB416PiFY7nA7FW7WxFD8zfWBP 3GPhvc+J5xLwZ9J2Jt++mXo0IfTCIBKa9rOtCJpxu0zswXP1NhgLuXNLoUbLOgsdpYjh Eayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068840; x=1734673640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQpRmGydqcdMOxZRzmLm98GnY2wtgMQ5ZotZeI2M2YQ=; b=cxSTIPUnKLZVg56gKALiaed32yVcoCyXM3V3BemlhPOIblqdQ9icL5cjGdwRgsbb3p g9Cjk85KuPlnni+ucBfVJeDXNm8U16GDtrVsapB5VUpjn7qw6/h2/FkNjiIopshiuG7c Qay9qBRT7kAZO0yFe+6SgUVg3PMKEAUYgOBwjhjpvNSol964VAR3xIkroyVWLl7mJkdy n9DvN+I+F3CGanI+FSFoYyGk8ZLll3/pStWhZpQCD2e1tPaSfPnpTbStZF1vWprnsHIs qQDcCsCFJbOooZIjoR5D9br/PXy/Jr62COyZ60RS+zZiWamJ9te3fjGIgNHLtJJ2WqtW iSUA== X-Forwarded-Encrypted: i=1; AJvYcCUrDVCLNoT5fMKFamAMMLvdnzvfeFfaSHSkZHOIIn8MKCYt0dEcFnppElSSd8CAutC1FpkhpDGb5io=@lists.freedesktop.org, AJvYcCVY6w+CWG+vllLd/2Mkk/B151yekpaMezTloz4NV72wdS2t/WiCyiUSO43EufLFnUriv8XSCCZVgg==@lists.freedesktop.org, AJvYcCWWt79O9naidYazTZOPUK7CUL2uCdOgfruN7fCzIhQYNqp9EPjEGypVP1pa+Niegt+syv6fX1KkpCMt@lists.freedesktop.org, AJvYcCWyUbzVEhr0YJ00tl7X4QDsDlB3nMZWfOPXxqdsH4fre08YUWJFwM/+QlbEarHIZ57w0EfceOk+fsg=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxNWx73xPXbujSiq6uWHuWLj2zmD75laaCpSQ9cP8bLQ8+KeKOu XzWcGX3AxSjqM4VzetjBwq890qDGOvqLU4jaz+ln4wcAsZ+93Q9y X-Gm-Gg: ASbGncsszJnjEmCpcigJS5PU4FbIuJcVJK9bj9mmrwp8zY2H88cNQO9bL64N035BDh2 3fJFh0EnwHzNaH0O+c4jaNHm9leqcd2rV1nfthoZjqbfpFRs59YE+oZA1egnyNE/4Dj9LrOjXqO IATMBHjBUpmJhQhQva+kEjmgl8hYdNKvDIHXjwzFq5av/paHHeUGZ6HO8Niv00+xkEy+1SwI2uA cnycd3lQaVoFBYmg2f5RpbQimKrHi0XZ4ps9Z/waaO8LCavDZL6QkuBTUTq902TUbEMEsUxpect 2ixtDRc= X-Google-Smtp-Source: AGHT+IGy5lWO5x7q/SCrL+dH9NQnv1Rp0u2NkmqEtY14rjHQEczQdhUClmCmrxdf9miFcIspK1e1uA== X-Received: by 2002:a17:902:d506:b0:215:9c06:272a with SMTP id d9443c01a7336-2178c872102mr82765085ad.24.1734068840305; Thu, 12 Dec 2024 21:47:20 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.47.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:47:19 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Kees Cook , Paul Moore , James Morris , "Serge E. Hallyn" Subject: [PATCH 5/7] security: Replace get_task_comm() with %pTN Date: Fri, 13 Dec 2024 13:46:08 +0800 Message-Id: <20241213054610.55843-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Kees Cook Cc: Paul Moore Cc: James Morris Cc: "Serge E. Hallyn" Reviewed-by: Paul Moore Acked-by: Kees Cook --- security/yama/yama_lsm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index e1a5e13ea269..4bdfa51ea6fd 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -76,7 +76,6 @@ static void report_access(const char *access, struct task_struct *target, struct task_struct *agent) { struct access_report_info *info; - char agent_comm[sizeof(agent->comm)]; assert_spin_locked(&target->alloc_lock); /* for target->comm */ @@ -85,9 +84,8 @@ static void report_access(const char *access, struct task_struct *target, * Imagine angry ranting about procfs here. */ pr_notice_ratelimited( - "ptrace %s of \"%s\"[%d] was attempted by \"%s\"[%d]\n", - access, target->comm, target->pid, - get_task_comm(agent_comm, agent), agent->pid); + "ptrace %s of \"%pTN\"[%d] was attempted by \"%pTN\"[%d]\n", + access, target, target->pid, agent, agent->pid); return; } From patchwork Fri Dec 13 05:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C9ACE77182 for ; Fri, 13 Dec 2024 14:02:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 207AC10F023; Fri, 13 Dec 2024 14:02:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iScZozK8"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8BE3610EEF5; Fri, 13 Dec 2024 05:47:30 +0000 (UTC) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-216426b0865so12495435ad.0; Thu, 12 Dec 2024 21:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068850; x=1734673650; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WABVozVaGAUeC6WVv6dNDEWCXVmF+XIaxOqP2xXRnSs=; b=iScZozK8ZnFr0iSryj/biErGBGEAo/fKu//a/wd+SURkfFBMeDCDtZn66YsGGvWcHF IawR0pySgKgS46tFofoFtDUQtfbNJm5dtv8xFjvFC2tc4kEgp9yePdL1U9+MT1XRjQVM 46m/kipTOasy1lfV80E9fTFqR+4jmTTXHV/HgtZKb9khMo+7CGL+lu7izWPq9Cxhp8C6 eREBxVWIT5/gzyXfM9iVZ2fch6DflVA3ctpehqlwkVjdINPm4XM25nemS9ncuO6lYLAJ kmTbAWWzl83ZSCrKzYIvqAmoaBSmY5ZYWWz6paQ6vr15937rfLmH5qN5rhb1zLzqij96 W05Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068850; x=1734673650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WABVozVaGAUeC6WVv6dNDEWCXVmF+XIaxOqP2xXRnSs=; b=oG6a5yhJe/zaBJJQ1BE9AdVtAOgTIY3BpdRB/loNcJfH0XUxx/kQnpnsLoaTlxoOyQ zXTwAeygVIn4aHIXMOxjzxb+7vNS24onwV/5n+Zkww0ABC/jwVz1tG6HlcNZTwJvxWcL hTjGjOdDRDKxpZ+6qVyfoAmQEs+H37QE+lJ3A4EBKuIAVzPMImO9aOAcjaj+DAjbrM4H 8NjPsLwzLEh3eeJfkjSOobiHOtJTOYhaZlUilfg5oXlGUzRO13Xx7eTtAFBxAmbmph9s jdi7LKZoxr6n5zoIyhY+xKKzQ7J4AUCSy7moolnDStc/uHRtNHPzPgyp+2PDertInVFQ da1A== X-Forwarded-Encrypted: i=1; AJvYcCV0V/hdVkOXikA5lqtQS/qkWhTtMl0e4P7TfUe7fn4AnHlOv1AcGIjdnjMDe1E2JOgXgLsnD5nukAM=@lists.freedesktop.org, AJvYcCVUDuiA2tWZQBXHdE+N6smQQdGeni3T/9JHPp7zcexut3u4qMsMQa1ORVx6dLdH0iFdiHO4vmqjsw==@lists.freedesktop.org, AJvYcCW1gquKJdaex67jF9QsDBaTq9Fu5MSSoThtUSP/ufG7TAwrPhtSRVBAfGFS1bNAerfqCypc9VGISaNF@lists.freedesktop.org, AJvYcCXS2X2Cv0GXVRuE58zpKt4wH13okBiqIJ7Ev05o8Cf0RZL0ddmcg2T940zl9t35dNxrEcXiDGEmc5M=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yxvblv/e5jmEfbu8SaME7xeQYKMz9bZFskUUa88YS1+X71mBRni Gskh/dqN8JCYBpIRqWhllt9cuUzpVF4ZGRUp0aexwvssMSdq+bHw X-Gm-Gg: ASbGncsoAwQeyjGoq3Q5g51wmZp2EuazS0X7sdkw/Cu3HIWE6gOfZrdwNuaznCZh8Rn 7G7/ybWwC6R2LRt7YcBQYNg/wxIyVy5ctLQFYOO6LjSq0ruY6/8dR8ButGqhLkdMkN+j3IG1KZ6 c+YoTcMUg0zXt3jdYImbJKKPln5ueJ412ethV+GZHuhutoxRnn5QvYU4grl1XYT1vJMmpa/s3Rf aPN9MBn3RjcJBONLeJFXm4ARgBTcork+daT5uBVlzl+3CrnH+8tXwqsvQaiceJr5HWNcaqowxAY HdgMYUQ= X-Google-Smtp-Source: AGHT+IGFE1mRmyM5NL2PUAWpAoscqFHXvU8vwTTuUZkYB6i9lL3x0jZgiaefTaKhcRetCPxuiJ6lzw== X-Received: by 2002:a17:90b:3889:b0:2ee:aa28:79aa with SMTP id 98e67ed59e1d1-2f28fa55d20mr2136406a91.6.1734068850070; Thu, 12 Dec 2024 21:47:30 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216483dd292sm82564985ad.226.2024.12.12.21.47.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:47:29 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Ofir Bitton , Oded Gabbay , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Karol Herbst , Lyude Paul , Danilo Krummrich , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH 6/7] drivers: Repace get_task_comm() with %pTN Date: Fri, 13 Dec 2024 13:46:09 +0800 Message-Id: <20241213054610.55843-7-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241213054610.55843-1-laoar.shao@gmail.com> References: <20241213054610.55843-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Ofir Bitton Cc: Oded Gabbay Cc: Jani Nikula Cc: Rodrigo Vivi Cc: Joonas Lahtinen Cc: Tvrtko Ursulin Cc: David Airlie Cc: Simona Vetter Cc: Karol Herbst Cc: Lyude Paul Cc: Danilo Krummrich Cc: Greg Kroah-Hartman Cc: Jiri Slaby Reviewed-by: Lyude Paul --- drivers/accel/habanalabs/common/context.c | 5 ++--- .../accel/habanalabs/common/habanalabs_ioctl.c | 15 +++++---------- .../gpu/drm/i915/display/intel_display_driver.c | 10 ++++------ drivers/gpu/drm/nouveau/nouveau_chan.c | 4 +--- drivers/gpu/drm/nouveau/nouveau_drm.c | 7 +++---- drivers/tty/tty_io.c | 5 ++--- 6 files changed, 17 insertions(+), 29 deletions(-) diff --git a/drivers/accel/habanalabs/common/context.c b/drivers/accel/habanalabs/common/context.c index b83141f58319..e4026051b735 100644 --- a/drivers/accel/habanalabs/common/context.c +++ b/drivers/accel/habanalabs/common/context.c @@ -199,7 +199,6 @@ int hl_ctx_create(struct hl_device *hdev, struct hl_fpriv *hpriv) int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) { - char task_comm[TASK_COMM_LEN]; int rc = 0, i; ctx->hdev = hdev; @@ -271,8 +270,8 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx) mutex_init(&ctx->ts_reg_lock); - dev_dbg(hdev->dev, "create user context, comm=\"%s\", asid=%u\n", - get_task_comm(task_comm, current), ctx->asid); + dev_dbg(hdev->dev, "create user context, comm=\"%pTN\", asid=%u\n", + current, ctx->asid); } return 0; diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c index 1dd6e23172ca..32678cd0775a 100644 --- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c +++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c @@ -1279,13 +1279,10 @@ static long _hl_ioctl(struct hl_fpriv *hpriv, unsigned int cmd, unsigned long ar retcode = -EFAULT; out_err: - if (retcode) { - char task_comm[TASK_COMM_LEN]; - + if (retcode) dev_dbg_ratelimited(dev, - "error in ioctl: pid=%d, comm=\"%s\", cmd=%#010x, nr=%#04x\n", - task_pid_nr(current), get_task_comm(task_comm, current), cmd, nr); - } + "error in ioctl: pid=%d, comm=\"%pTN\", cmd=%#010x, nr=%#04x\n", + task_pid_nr(current), current, cmd, nr); if (kdata != stack_kdata) kfree(kdata); @@ -1308,11 +1305,9 @@ long hl_ioctl_control(struct file *filep, unsigned int cmd, unsigned long arg) if (nr == _IOC_NR(DRM_IOCTL_HL_INFO)) { ioctl = &hl_ioctls_control[nr - HL_COMMAND_START]; } else { - char task_comm[TASK_COMM_LEN]; - dev_dbg_ratelimited(hdev->dev_ctrl, - "invalid ioctl: pid=%d, comm=\"%s\", cmd=%#010x, nr=%#04x\n", - task_pid_nr(current), get_task_comm(task_comm, current), cmd, nr); + "invalid ioctl: pid=%d, comm=\"%pTN\", cmd=%#010x, nr=%#04x\n", + task_pid_nr(current), current, cmd, nr); return -ENOTTY; } diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c b/drivers/gpu/drm/i915/display/intel_display_driver.c index 56b78cf6b854..416aff49ceb8 100644 --- a/drivers/gpu/drm/i915/display/intel_display_driver.c +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c @@ -391,7 +391,6 @@ void intel_display_driver_resume_access(struct drm_i915_private *i915) */ bool intel_display_driver_check_access(struct drm_i915_private *i915) { - char comm[TASK_COMM_LEN]; char current_task[TASK_COMM_LEN + 16]; char allowed_task[TASK_COMM_LEN + 16] = "none"; @@ -399,13 +398,12 @@ bool intel_display_driver_check_access(struct drm_i915_private *i915) i915->display.access.allowed_task == current) return true; - snprintf(current_task, sizeof(current_task), "%s[%d]", - get_task_comm(comm, current), - task_pid_vnr(current)); + snprintf(current_task, sizeof(current_task), "%pTN[%d]", + current, task_pid_vnr(current)); if (i915->display.access.allowed_task) - snprintf(allowed_task, sizeof(allowed_task), "%s[%d]", - get_task_comm(comm, i915->display.access.allowed_task), + snprintf(allowed_task, sizeof(allowed_task), "%pTN[%d]", + i915->display.access.allowed_task, task_pid_vnr(i915->display.access.allowed_task)); drm_dbg_kms(&i915->drm, diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c index 2cb2e5675807..5bcfda6ecafe 100644 --- a/drivers/gpu/drm/nouveau/nouveau_chan.c +++ b/drivers/gpu/drm/nouveau/nouveau_chan.c @@ -279,7 +279,6 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm, const u64 plength = 0x10000; const u64 ioffset = plength; const u64 ilength = 0x02000; - char name[TASK_COMM_LEN]; int cid, ret; u64 size; @@ -338,8 +337,7 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm, chan->userd = &chan->user; } - get_task_comm(name, current); - snprintf(args.name, sizeof(args.name), "%s[%d]", name, task_pid_nr(current)); + snprintf(args.name, sizeof(args.name), "%pTN[%d]", current, task_pid_nr(current)); ret = nvif_object_ctor(&device->object, "abi16ChanUser", 0, hosts[cid].oclass, &args, sizeof(args), &chan->user); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 107f63f08bd9..3264465cded6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1159,7 +1159,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) { struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_cli *cli; - char name[32], tmpname[TASK_COMM_LEN]; + char name[32]; int ret; /* need to bring up power immediately if opening device */ @@ -1169,10 +1169,9 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) return ret; } - get_task_comm(tmpname, current); rcu_read_lock(); - snprintf(name, sizeof(name), "%s[%d]", - tmpname, pid_nr(rcu_dereference(fpriv->pid))); + snprintf(name, sizeof(name), "%pTN[%d]", + current, pid_nr(rcu_dereference(fpriv->pid))); rcu_read_unlock(); if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 9771072da177..bd39167d4234 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2622,14 +2622,13 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) static int tty_set_serial(struct tty_struct *tty, struct serial_struct *ss) { - char comm[TASK_COMM_LEN]; int flags; flags = ss->flags & ASYNC_DEPRECATED; if (flags) - pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", - __func__, get_task_comm(comm, current), flags); + pr_warn_ratelimited("%s: '%pTN' is using deprecated serial flags (with no effect): %.8x\n", + __func__, current, flags); if (!tty->ops->set_serial) return -ENOTTY; From patchwork Fri Dec 13 05:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13907164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39FC6E77180 for ; Fri, 13 Dec 2024 14:02:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BFCC210F022; Fri, 13 Dec 2024 14:02:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LA5W3T47"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2E0710EEF6; Fri, 13 Dec 2024 05:49:27 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-728f1e66418so1225252b3a.2; Thu, 12 Dec 2024 21:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068967; x=1734673767; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=m2jUPvsdlfQUhZsdbtI4Ke1sLD5+tvHbQzW9Gl1gyas=; b=LA5W3T47PvwIf7VmXGnZPFB39WUEhKo7m2Em+r8J6qf0S0I93mTrVAOLaGapaKH64V Pdww8aFHJm+jIK3org0dLcJ86lyic4eVqOtJ761bKG5Wx75KbXpwbkl9ITYsZo4FErcg wEov1VhKGY02TQkbxDkBg5gQm0r32u2hlCif/sVMgYn0hIqi1rkKd6FMIrDTuZjqFhFl BA5Xl9dcm9QkikNplPXQjsW4/MLSMN6GcygJrhIKlnuPcoTGHr4OGztiYQDb9RRq3WQe UXu289hLPU+hQyDdab6ZY5raguxeNZQQrmFCIw7XVs3mW/E0jqQaJoh6EVVsjSAHx4Vh LoHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734068967; x=1734673767; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m2jUPvsdlfQUhZsdbtI4Ke1sLD5+tvHbQzW9Gl1gyas=; b=XkP/L/JedEfzX5KOsJxsQt1D7wyv6NdIWDZSaVzAX38Wx1ZAaqG7YH4ial1sK8dEZ5 oXlp77x/1FqqHKYdugp85J5Mcqq5nMNfoKWvNlhWr+55FgNVXOajC/TLZjui+yBeiVsp eEAb2Z0BxBYAT/bYyYhIWDabnSS3ZxYynUN2jaGOWfNAa4Rb2S8+hkHL8YLTmMcpm8hi XopNBGaM7Whd0fuiCJ9SKmsPbH2zahsz3ubci6P/5e0dB7tjJtTfxStxU7L5d9yELRY5 20PMBdYLgzqfSTV9nDt6DMcUk40WS2Sn/OaEek4voIYmz4XnK9XLinSOhliGcVJoavWM jxzw== X-Forwarded-Encrypted: i=1; AJvYcCVPtdmGsbYDus5geJXj4hyaK1Jl/fXX1RptTx0hj7ayu0mFFKrzed4OwNW0RZ19r5DSoKfXy9eXW0I=@lists.freedesktop.org, AJvYcCVfN45mQASctwiPvmwMuAdZN3Y/hFq3GN+PmOUX0wNEXfCWjvUPGIYdYkYOV4i2ZXqFbEzkIAMjf9b7@lists.freedesktop.org, AJvYcCVvTuMRknmT83sk/vF+2N0dL4v7An/BVz0bzO4PRN+Ms/n6uG0Alr9MIKiHzJNu5G8sk1aBQtP1aQ==@lists.freedesktop.org, AJvYcCXcCyTitm5nQN2G6N6whO0J+dCqHA3XpQvoPQYaEyh/JzEUkqIuZUsZNZiwg+iQsSG2nVCsjxlYsDU=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yz5QI0Ey7lM1SYcy9g1M6pPdxTIJPBL5opRhAIHocac0gpr4Cx2 6qW2OUHmzSlgCt1cfJA6hO9PR0wq+sdy0WhuFbsVRlsGihluDTlY X-Gm-Gg: ASbGncsxj/I6srSDlns1syc9CIa6r+Fzw2wJB3PHSAAAl4PjfDaJJYlVTmT7clOyOXi Z++v/fbpooShycVHUjN3DRv8bW+bJ93e2ZG82bdoI2W3vWi4b4cqtYfQOj+EeTfepUl2J023Ib4 2oZqqneVKZYpcKNIHluyxjSQtZIReHUcSBcTe4jfgUJggDN+dNSYAlo1aGhWPnzvDQbRZCHTJWg Uk7AMFXdXjpwG6lD/eIwyGaolqIxicaI07ar8HnaLkPNPACi4sUAoTeOjADjojfVY4crELiCln3 mqtk8Fk= X-Google-Smtp-Source: AGHT+IGsjn2HsD9B470GSaZ7/WuS4a1ciiqbzWwWUR77XR0Zla03DKiQ+x82aV6yWtJ1LuxULtoYsw== X-Received: by 2002:a05:6a00:b46:b0:71e:4786:98ee with SMTP id d2e1a72fcca58-7290c2702e3mr2257553b3a.21.1734068967116; Thu, 12 Dec 2024 21:49:27 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725ee10f928sm8166032b3a.32.2024.12.12.21.49.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 21:49:26 -0800 (PST) From: Yafang Shao To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Mark Fasheh , Joel Becker , Joseph Qi Subject: [PATCH 7/7] fs: Use %pTN to print task name Date: Fri, 13 Dec 2024 13:49:18 +0800 Message-Id: <20241213054918.56441-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 13 Dec 2024 14:02:42 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Mark Fasheh Cc: Joel Becker Cc: Joseph Qi --- fs/ocfs2/cluster/netdebug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index bc27301eab6d..039d99f951ea 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -122,11 +122,10 @@ static int nst_seq_show(struct seq_file *seq, void *v) send = ktime_to_us(ktime_sub(now, nst->st_send_time)); status = ktime_to_us(ktime_sub(now, nst->st_status_time)); - /* get_task_comm isn't exported. oh well. */ seq_printf(seq, "%p:\n" " pid: %lu\n" " tgid: %lu\n" - " process name: %s\n" + " process name: %pTN\n" " node: %u\n" " sc: %p\n" " message id: %d\n" @@ -137,7 +136,7 @@ static int nst_seq_show(struct seq_file *seq, void *v) " wait start: %lld usecs ago\n", nst, (unsigned long)task_pid_nr(nst->st_task), (unsigned long)nst->st_task->tgid, - nst->st_task->comm, nst->st_node, + nst->st_task, nst->st_node, nst->st_sc, nst->st_id, nst->st_msg_type, nst->st_msg_key, (long long)sock,