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: 13906562 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE2BA183CC2 for ; Fri, 13 Dec 2024 05:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068814; cv=none; b=hUSHt1GIS8mX5S6T+PYfXe0N7WesuyfndCPvGc4z358UhvdbQqIvedsD+GoVyFtlfyfNhoN0mwDlNZfTe3hJmAJ4mtushJxV2kPj3vQwpYeXXQxPKISNPun8TdukqlCCkaja9Cp/9fXr4/V8LdoxMSg0UM+e3xpf2ysBfgLNbT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068814; c=relaxed/simple; bh=Dbl6IM9eDg62zjXvaePP45Yh+mymlhXe9Q+BwlJcMGk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J45isa2279jpkkneUXslWrzuXUnu8I8FNphSAxI6eJYdhEht5I417dMHaDedKRtasgur9F8yKyfYe+8sSHkSo6JwUDBMUbbYdpjMCMWpkyhO9CPdM4GV/+IoSDkUxWZXV6cfD1K/qfs6qaca9Ie2JcwfKjr14MRIEp/MoNRsKuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EHIbehak; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EHIbehak" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2161eb95317so12934835ad.1 for ; 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.linux.dev; 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=EHIbehaktVKYvCA9CyJ+TsytAWFOjfQpXWsWzwptANdwtZdlbOuYqW8weBcQmEEMwd OGQLPasU6MRJ39VqEE59crfPoDo44ryzQgmjCV+AltBmwzWY5D2MgelrYC+V0D47fcM3 Pmwb5KbgbFBvz1exBxbEcZLpRULsZSme5Q9w23QLrFEJeCSUTSu4bxmep/1Tmpz9d/ww 37ZhttB285ibGwQ095hIu+glgyOiUvKDuL/w3FI9asl1hsWbl8bg9yDdgrcgYmoMEm6V Y3/iVYEavi9xtAPcNv2rm0oE7nHTOhFlmsUWkBaqjQZtsPpmM+ALy0pvyXtzpilrxgu3 MmHg== 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=WpVI+letrD7e76ARbt8Kkry3lSHH+S64mh2JzlcuvU8//vRpvgu+3P4OTgezsX59jG 4KhJxl7mnQ6CZhwqZTEn/EaoduG2Lrxh/loiS5sPSFuYrNaV+j0DxeT+7rgtw97ZyVv/ cxBNVlF/WEbDyZchEWuuta2qVxFX7H/R8EENO/7tDndRXxCwROsTcgflTFF/Y1zT7fRh itgHStIHSPHhT0uxI2MBpw/xzU0I/ze8fgdpI4T77JdS0dRm0pvP7zOt8Ff9OOsdcWli o+elfWBzN1sY9WoUZyeLgnvuRSymQ5qzeb+2FF7/pd2aVcTebFVHwkT4EGXpGCpjj3Oj nbtg== X-Forwarded-Encrypted: i=1; AJvYcCVhTfEve4vELq4DfwexdNZ8KS2S7hl7GcuDMMI0WDKgPSPtZlFLNlZJG3C5V7M7+vwgHLLfkjRea3scBA==@lists.linux.dev X-Gm-Message-State: AOJu0Yw/HW8TJqvDv2jTKOlt9DL0uktI9YMLaj8yAlAa6HqaE4CEi3ld v4c+8pW8/hBOpVujhS1msk/gQn6Xr5F36GCES5BC21e7o2HEUc2F X-Gm-Gg: ASbGnctXxU0cYiaRslVNQ9xbBv2VkS8s6bPnXgMIH5r/mjcXVBj+8Nm6kCRqZqTBVJo 9Gbbj48xXEW07IvOXJjjvE4ektyuqfXOwb8wejuI/qNQt855IK4YWd/u3qYq72EjxZxbsa9hy6d iBqDkZ4BoQ2yirYkkhjz4ZRFX39PAVJYbQ+MroWsrPpa4bDsSKLVH3rcU9nGni/DS8kXz0fXQaK OYjqzIyddwzkKftf/aeo+0ctAkPPS05LMEz1wWIZ4nAFYeqhfQvD34AdmwIlZQqvy+DYhjmDM1t Br1pxhs= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13906563 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3110A18BBAC for ; Fri, 13 Dec 2024 05:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068821; cv=none; b=tSYl8t4YE72d82OvV8MVtN7y9N+tUxAtmD0bTdpPhA8wxL3EpMJzhRecSxufiPBbXOprq1WnZkc1zQCw15zZlBjjSd7/D+U2UTA0WrcsV3XLP/LcmTbfs7+pcBlKuiuSjwfCJJg3PrbrQakgvEPRnwr+d8MxxGAY8LjW/8bNVhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068821; c=relaxed/simple; bh=PCh1gNdVkWHp7L2j8aSJAn81J3xtchPE0tLiHOyl/eU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=uP8Ket50Nde/2WGXKtYPo+or2bpZKdAgAW40tru8l/fmPEt/m+HmGwy3hswdkFqcboBrn5LVw395M/l8gyNfPoNE8J6rbAXOfRzDHFzhTj7EeiY4EdHCmp734MV4d141hqNqSfpGV9x1mnoUBA+HpbCSs/ngMsHbmqpZtoV2KPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jrapazSM; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jrapazSM" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21636268e43so18023685ad.2 for ; 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.linux.dev; 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=jrapazSMypZ6u0IUDVHo3ctjrLJH+M7ikqrcg7oSGcMnP8Kp2H753amQ/A3SfzUUfc K3orRYGGI5ysVv+nzeOe+P68tILiTwYiQSZ/XMcF++R1sbAkQWObs4oKOe9RPZGbJ0pJ JVRPs9ugsS+L1jLn+eWEjmjH0vAf57bbvP7BKRS4GJxZ1PpxjkJEzaOyXML/ooQJla9Z 1iTU1zb1Rm6tOXFUh7/CKrBCl7HUHfd2InfpVq7Ku9K4Y3YjjyuBod87TByKhLjBLyyb hHRW1nHPs3gNG071YyYHSUAQflOkx9bRcQrew0phQqoqW1Z6piYNYmj6npH3yygsJ8YH OLhA== 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=brSBEPsyCCEwY+nylF9hcGiloXsrilTT/cqAUgzyphYRQYWFOnCeyPtUcWBl9IP5xj T7CxZA5D0rtFqgrJkmQ+nCS0J1tD1Mx1cOMx0NU/dbPNsZrwFaBmoUY9HQuHA0XZmWib NqavEgQdJDVozowj4sG8TjiAIol8ag3yLeQMD87KLuyUKB6GuHBAIX+P1OBxn4fPMdNC qc2wkuLI6W1R5hyDZTtmLG6soUCun4WK0PFBATfePY72IRkuaE3aODtg7BfW5J/+Tdvp ukP5uI4EKc5E/puVisc6gUMk0ent2WuBmTEfUrw0FjSpIKOFTGFZNY6qCtNsgTQR6Yc5 0wag== X-Forwarded-Encrypted: i=1; AJvYcCVgZWqw3n4ILMLwlV48OXaWDUaWjQxyhlzWt5+0U7pFE4ro+CjyPxlXy98EascWQMuknCO89+cVixiK9w==@lists.linux.dev X-Gm-Message-State: AOJu0YyF2mbbK4EQzXC3RfMl0KOKr6+8lhdIOJUPtM7Dm8PCUW24k6Eg mIVVQDxM03ETBc87dSrXsko0J6Gwhr59XLEJtdCUjWAf7q47NuHN X-Gm-Gg: ASbGncsMy29Zb8j6kbqjYjL4k0393WO0TPKBjBlIM9X1eXQptwfM9RuE79wsVD8UiNW Ccx1D9UmWBceFtgE4hvHS/Pu8ZQBlbtvR/VeidosP+2UH+U07rWUY5/xRy1gYN5+QEwvDIwWB0M K2w/o1P+I2LuZ7Gwoyo4p9XaWUQIvTzEznrBypytQ0WSG8SJ3hYJVaK0Raa/I8RHXCuRoy9R1pO 8Iebj98CvM/u5eln0qwE9/8SOaODotTp+LEOe2moPslLucvOFQ25cbGjdH2o5YHTj+8hzBVKbfz T5Wq04U= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13906564 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C483918A6B7 for ; Fri, 13 Dec 2024 05:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068829; cv=none; b=q7ijgz1cpDUdbbt5cppVf9kepmncR7R6iD5KUYSdWWZkfIX5/osO8PATa7dor7OQUwlllulXlJQZoSVTUaMP98RvKaANmmrxP5lL+K9LCVjH3ks4bwORftSPfGgH7aQywSu/m6yQVePYPmmRUzeHcurMdvj5UaGpZkpYs/lebeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068829; c=relaxed/simple; bh=HwkMe9hq5hr2QRbPNXcqLtCxfZxrGOY1qad0lN7B90M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h1oXSl0jyEO2hh4DjkkNEQO1GpLDR5fwhFsMilXyjRHsHtNnMhNZvYpmIR78GSEI1YAYkj43Fm1ES9IVdO6FL5V7dhRfuzP0kqREZCbpST28N6b7OfT4PBfP0RjRbQnirxXS+fBd4lJsNPyo8bqpJ6cZEb3w+2ohSibY+Zyvm/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Mo0UlYMC; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Mo0UlYMC" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21675fd60feso15908675ad.2 for ; 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.linux.dev; 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=Mo0UlYMCeUKLZbM9SBx2lYrwuJq/F+O9is0dpO6JidNQ1KnhJsUINcSgur9U1Qafb6 /yMpdJZSM6K2RoZqG3asXTVfw1mdNHtxTJQUjPWJ/SEGiX8TIhdFEmNSocoOrWrqKYXV Xj1msNDlqJqjciiTZoNSNB9z/azw7bB+sQv4gOIHi0btewHpqwTl1CyB2/OLfddabhB1 g/u/sTgDOfdr95eFs63E8ifmWDTAQ2Z8gGWsSno3JwWqaxfWYa4dks6X2uH4zSMBU/1/ zQptvV3CClwo1Y2BPMQmxQLGS6bNvHfEQrh4UdR8+AFNDh+KUcNpbY2gH749VX8DBsn/ +SLw== 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=fD4JQWRTQxIOg+mmrf4MfSQmhAwwi7zKrH+kxcKk8hUXdcUbioBvLzoCc+O+p9cLiJ Xn93mJyevAaIfmX0CGPcV5xWIo3VqlVgJt/m1DjOf+Znojc5ELxv3MlZIYapjtQP+Uoc lLIxtV98IQDSgBbNiMvARXPsVhiLFgRFq30EOxuEqoCZnnCDGgcqMZanbJ1cbsPJx5vI 5FcSlUVdOIGRwRelQZ5KBSv76gwRklCNgEm6/ifEgfNE/fjoarben+Gm/h/NVGg3nQdX PkMqGT+Bc3tdAteduW/IeDT98ynUXosEhUjQUjmsOHcFsIP6ES5QxbCa85J7wiC3GofA 9TlA== X-Forwarded-Encrypted: i=1; AJvYcCXmyXBdvmRKa0pil1uDhL7Lde6/imlHXKAMlV9zlHulXuWiYlsvMp5PUaR2uw0C72Y9fpNADb9pAX8fDg==@lists.linux.dev X-Gm-Message-State: AOJu0YyZ9oyxFAmPldCfz2980JfZtH0u9zdf/nSeRbDN0/punQHiMA4P L4sQyiNkgJKIoIBmdhKiZ43uU/UWtXXp5aZioohJRz/P/IDQKzlstC1UAdD1cLc= X-Gm-Gg: ASbGncv6APPu/cE1Hzr8zP31TrlADOt/rwrF2Ir2vT/3s9kr3Sa6VGpJ08y3eXtrpnQ MyRl3RjM8sfKJ6LaBdsjBBTdln31YG2hbPdjN8Kqvy0YPLsOy1Yi/9NdFboQlsZnPpuSdf3muvP sJJll/26R+ZziP64fkWMUJNUSd0xN1CQpfaXdXU800208KZ9QfVNTtHC63HNJHL2s08YRUiBqNc QtS7TtofoGybu06YXI5eh5t/ojEyotxojs6jvJk2dqOPbkGw2BISGDAm0UGQ6Nt907HazjJvBbZ uGDuHvs= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13906565 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53F9718C91F for ; Fri, 13 Dec 2024 05:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068835; cv=none; b=BUBXrxSBBO54G3L5rrObGivQA1Ndxo8z2AjYpa+IlurTCl0atlPuhC09XXhUb4sliRAZjS0Lej4Je+X9k8ZxThXnqXjpa6wLoLWfJjZIsPZrnglWzzv4h55JcsCTyYUjMaG10mJU2FC681sai4KfaEFX4TDipQ41igFA1clQp8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068835; c=relaxed/simple; bh=QTcEM0pa4oOmr4wRV1zBU96zbdoeKwVEN5PXZd67iuA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oywq5fL20caYnc0I2SLfLJEaihjrvyhxXyFBMPO37S9RDKCnbwu6L+rkrIAKUQdlbzOWl//bnnCHlZ30UHNWod9UpsNtgUGqPSipXKoIhUKepOrlqvTmurMcL3yJX6AiCmcUjv7eZ5IRpa6RKYs1LR4CykSZvEIFcjy7Z/7xc8g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=axiXwipQ; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="axiXwipQ" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-216728b1836so12307375ad.0 for ; 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.linux.dev; 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=axiXwipQCrz/eKiACdDJzBgDNi/6spK0tJ5f4jaEgrlXwb/8n2cjM+Cxj0H8nXeFuG jKopf+RtrEfh/yMzfaQ9NJvZTonQvFBcS74bwzbxuU4qb7SmnWRkuAtpuFGYj/+B3sbQ F9VS69fJowp2vDul3lUkGVicOMXpHR2xuIWVp1/P/ZcElzRCvHrrTEkhdpYGRY1VAK9z mUBQo8k6Egy4HttB+i/+4NVrPb3hJpZf06s/Jc9NHrzhJx0DnPimMJvcfEiuf/nbHacZ rMPVGU0u9Of2sFJrFdpVn91BYayPdCgUQlBDXgCcU0wk1vQ+O5PrrKVCx0BniIyRiaqH kTCA== 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=kFtR0ZRus1AByVU3kBWp/+BLHv3dEtWvPzaW7bxSM0ApIgdEg2UDD6rIR3YAWrpLmN ILC/45yKiT47P3zV4CZ2umf2lun0+ppZhstworCu70PR6ZtKH1I/gz8F1RGJD4+7Cu4M 8qPlg4ciyOufI4tuHBjWIyPFJX/7xeG6Ye0ka+DU8mnL6r3garaBZEBiZ3bEB8N2mpIy 31VfnfcohiFkvuz3j1N8YZx4j8mQQd+ok6VuWXrYVpHgGNbWMNhxWeBnB+ks5rtmjzDC eoKnwbB6paL08llGDbs5nSRCEF4ai8puTAFFf6iJZycjiAm/rvBEhcm17t+H3FA1jm5r dvtA== X-Forwarded-Encrypted: i=1; AJvYcCWpSsL2FmaoHwjtGoiHSkx7HRME0h/CzqkXnf7arrS9O7avQ+3BAAiuQbaayICsWNEMLx9SZaMRFTjsvQ==@lists.linux.dev X-Gm-Message-State: AOJu0Yzts53EhB1spgEFUB7tRKpTbe3TDXx02YNeJndXg35yMEqARCRH kn0SQu+AqNRBUQErr1/wOJONRYcTjUdv+TAQIe2AJ48z4Vwihc6m X-Gm-Gg: ASbGncuViN+yItYvg6Aevm/Lw4TeFRuk8yRNBotfvZ9iJol83Pw9V3ydRsHB2Vl67ou mJn4d0A8LU5UOAMga0I3cvipA93TccT7g48DxgW4ZFcTHa7L9kTe0CFDwpl0TFSo/N2M9x4I/tE jqaddDxem76KjyU0ol8xCRgKznDS5Wa2u7kuqf0E6eUQ2g5koETGISsmyIYPvwSX3OSrztb+MNa rCxAsV3MsGqnD7qZlS4lsoXxxBp+5CCGPdfi7dleZ76YK3qM4thK92iTZfN6fDjJ/CRjTcbIQxd Wk5ho/4= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13906566 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00EE818A6BC for ; Fri, 13 Dec 2024 05:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068843; cv=none; b=ih+IYwAnVOJwfVGrUbSl9JRWEFclhntb/zW+X41zbfviQnFJBJYkd0I+xvdTCDu4ac3dySnJNQIRoRk2hyZfVGsBQtVBsTZUB36y8ILX4uAv6eT3QOq0OTpY8vP8NcbcpEaW9hrsneRTHKaDPMe5Mp6LRMLxHvtbjonY1fffh9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068843; c=relaxed/simple; bh=HBeo4xWE6l5jixWcMRrsf7eVi0MSPm7+QXC8ECpQ+bA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TgZb/Xm8f3e0phMWn2evwx8BNWD3pgyoUiiYkSyQ+B4/P4D6m4DePw9IfyWRWNX3l314TiUkAZI87Lae5NN8CBw/fK617adhyH4oUoUqmdM9UM5GCAofP07MpBVXPUysHE+gIcR1p17ziW0/uQSkJdwZoLxSBHZTXzAe3ax5j6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DDpQM+mD; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DDpQM+mD" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-216395e151bso9166725ad.0 for ; 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.linux.dev; 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=DDpQM+mDnX4RefGk0RYT3eqYxqzji0TGhzKYgNt4mVG5skudlqCYKfvAy7aQKz02eN lIn4enl4x6+MJH4wblVCPmQcR4vrIdLDBXnbyNfBNvxYxSBNqVe3CxkGXP4sPtPA+uOh ANrRHKn/2q6M8FwTkoe8eVu0HVPnkG3fyHM3bmJXTLbydOCMntE1UVDkm5oSOh7Ce2aO z5xmfhyKhQEF4bI0S4fhHLVXVajMRUGu30qc+v234SQB/i0tKJnPkXAdk6mMgWS5ZSxS 3Ac0RKyK5d9+0pVyjeb3cgzniylPvifzZa9Y+UL2pFIkPEXdautBHj47am5fS91A/bbk ZwqQ== 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=MY/DlxR9YcPOOKYEuZLcaxRh8DKLHmq18Remn75MO6yTyOu2q01Mxl5KdUgS4JaB8T rQ8gbaZdBatHMCdaGiUkidhGHoMFRh2lnGxakgLxgmrzHjFtrE8ObPtVtA9hFRV8LZMh TTxCp7hm0Phcyb2FoTrQ6H/YMYdfndY0Fn4xM3kHdTgYwP3aO287mYSjq6epdE8siFfc x6KTBaRZqxLGZDckPGnJoqVhB3xeN3E87OnM7t86AjkgCzsFuEWSpcpBNxdjWnTVReDl rIF4TWYdLZhoGtJg5ZE8gkqd6difrIsdCvrVqBIGzKPL4bBYKX0N9lZO5rIzGBiyd9p1 PoTw== X-Forwarded-Encrypted: i=1; AJvYcCWSlOtZ2B5DtzmapV+QhCw+lac1+0M2sijQdPG/W4hu4lnqZlvmFD2uKIQ9Pd0RO9X84XwYllU7GkVfAA==@lists.linux.dev X-Gm-Message-State: AOJu0YxQtZuulQiw23IKwgT2q1HXugZs7FLvwDVZSDswbX0yDJT+n00b QDSGwdf3AWLN6AxHY+5jbabNqEpGXMfjNYkBfKhRa7ljEPVwmrdf X-Gm-Gg: ASbGncuEfZ6e71Gl+sOR0HQPLTXtx2oTTzB0lA6d9XILABXr3qNvwTfw8Q2p25fWnbx WIDyWZOUrLjmKFmcdvGOZ4QNeISyDJKtGj3EEfPbgXxt56+13ao5xhYJDqzXjCZNOuavJjr1MoY U1g3ahpnLKKnRglwHKx97OTrTpYs3ysCwg0IzZBrCYlvLo58U3IgzOdxQ3EVZe0L9GAfF9C1Hkd VfgyD1Tc9thGf8jx3LBvxMOn/ozP1/9PwkDsxqIwJdfoWRvxvMYgQvAbzXQSLC3JX9hzZ0t4SRv bQ7he6M= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13906567 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E850D18C039 for ; Fri, 13 Dec 2024 05:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068852; cv=none; b=YDb/IDsbfYFZh/Z94HPAWjIpFWU6LmZbDk9ijRLSrj2ngZ/fBjwLJScPdprTE+OTiTDPsLsi6WVZpBltyvZHOBbGbyTHFS95CH+p2hKA/D/aKlnOlbOSaKfW30W6XVS5VfT8p909CFQXzJwYONH00qTZ3IzwYJmxJ/jxIrVG/Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068852; c=relaxed/simple; bh=KjNx//tf6qnRkSn9x4PGnNW5eZ14kzaocEF//pfnNk0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jsI4q9QjKFbM0+TqeBlR/ycRhLy4/OpBT2fbAc9mnLB7PGetEBBeeAk7EfgArxi39ij9lDKSSQhmzYlEkKG/+LWDz9g3l0bwcudxLEaUKAcrH0bDbB4J6c7CXnUyVjxycOUoxOZxrWJVqe26vDBVcBxSZEcW5a6VTpTVFFgbHL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P4kw6RqP; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P4kw6RqP" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-8019f048bc7so1024970a12.1 for ; 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.linux.dev; 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=P4kw6RqPrXSPymq0QvLIdLzoW+q5PF2vQgU4v9/EazyJoE2m1NGinDYImQQazp/lWB Jrm7/ATxRW+XpOmMMkwN7FKrmXw3UdWhRRKBavNfQ9LRwDhzpVr/xUCwqY1YleAcrLZO xCspLLD7FY/Nm5obPOqNjJbJvJKbVvZTqrLm/Ab1FQNrFuEuOkpLGpCEo9xfly66wBYD sC17+PKDzDumAAWoXLcxhMj5KI2dMM/mAHuuQPf9ishoy96GosbIEdXPeaN157E6I9tm qcAc31kiQoyGtctQ1vIZOH8bRkgL3Yc8Un/nuNTqGW0YlvAP+oDhRJcBoc/wOHWg/noI XRKQ== 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=cL45jT1o2uD8bUawogTVZ/Oz6EaywUF8+Vry0YwF0W/w6LlVYnCqlbu3NNwxJPa+x0 imUGsRyY1nZ73aG9qhxpdT8iiHrznsm5fHxWbe7faCyNZqW3PrIz1l0iEJItlI61g7oQ 1ZI9cdbrqm4RyzvZvjdkKHX4Z8bwlkPFNzyqQMOl+AzKAtw9ceXEeHsun9EN9j5K1tXv Ge8GAu8UvP+95PV4WtHGC5cd04PZVq71MORgKxA+93jdwgeJcFDDPCtMu8jqCGcelmfj sBNg3AQu8AM21ZQpbpIuEXJNJBeKSQslnJNwSh8d1QH0ttr1/VJ6hLBdCM24sOW07FG2 Or9g== X-Forwarded-Encrypted: i=1; AJvYcCXc/EhXWcnuQ90667xVMUgXbZBCEX+fn3hHqqbdifAUQPUypI+4nBV+APPE3tHZ0iVZag69riyrLtj2mA==@lists.linux.dev X-Gm-Message-State: AOJu0YwExgnaVCzP+42PDQ6tSCGnh2h3DmMU9QkRFGckoUr+RbZ1ebGL jpWiPI80Pm0OP8BCl1JwaMD2XAHZakT02ujyIGArPkGIXNEGEfom X-Gm-Gg: ASbGnctaGZom2GQTzLM3e7G4D9kv2zoqVcaPjKB9pFhM2kBdFZRCLU3mCZAc+ZKJ1kj 2xBN/m6MQe976fjW/3eK9mReoriEF5+ZyM2qrqo64g53VV5i7twS4ssJcxhkHuiZYiQ+JigWnBq p6S39hUbggGxHyJ+vgSfm93fATeNQ4J3/hsU6Xs7EyV7u/p4wkmq9kwqsjnyvnh/rKvqV2NAPPc a5ZO3jyStv/L2wJcK60cdRsZyNWB76Vihzawy8Dl3gJXwWWpXwx0TiHO5Doh9ZYmW0E538lWRZS MeZV9xs= 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> Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 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: 13906571 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0C2D1862B8 for ; Fri, 13 Dec 2024 05:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068970; cv=none; b=ldS1bmPkskuZfWYO6tpB5blVq6SE1OPgaRWQWwe8fskP/dC7sucf2dPf8AHHnw0DEvqaGJEGeyL3OiFxsX1US4qFLEcD0hu9YNDNJzS7F8nKUQHbIe6YgPeZjxeu5jon8oVI/FH4ScMT3LSd4DjroKjXxRg0UTQrjBm1DSmM7W8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068970; c=relaxed/simple; bh=v+pMu9kg4VrTuiGatKb8KwXRW5PcoI6cotIuO17+lWI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jPxpaKWuYAbP+SGnwRcJNaUeFBzXjnJ7cKXh01h2tumJu+Ht3PiVaBRUtjd+/pFbTmULyQ7GWte9OFy8YZNbljc3gcQA72ge+WOzssoY94da7r4JmitktEpoBYH/VOGY9EzrXjALuRFxrvkmTYWeLqyuA65llzggR2GGIfz9K64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JjTHUQ9e; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JjTHUQ9e" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-728ea1e0bdbso1127646b3a.0 for ; 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.linux.dev; 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=JjTHUQ9e1JfhYYLa417xuwDB3s6aYsgrit2IJyyhFv8k/6SyiX1pPlFqLixeZy0CcP aip/JfJyZDx/1RKYUvmyLcg2/7P5B1GoTbPZOXSB65gZAdSSeHn9SbuwvGX9n0kJTjIw vmN5a4fL5sNWdZIhe7tyQa4wGcnmHWiQVvb7mR8lbyiPzJvQyAi91QImDm8Yzuk7rbVe RryeBMKNvHJxnzBO6VEKgrkUzcy76b5+Jo9KIlWUmwzJpHSdD5EYLMaC+eGBTHHF3bae GS+HaBnEUovOBqM5j63tFLdBjcn25nrGp2JoCfz/RaMJOsGT55NEg/ks5Ez4f9P2hTPd IMDQ== 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=SMZM+ECyOKRFsYyxSwexXZg0AdBr7IiQePGVwaOxCC/OWfTX2nVS2VcJMERjl7sCb2 JNmv5KDOMrEMxMBO1toB/5HwrESC+BX/2DedppBpRyQVXkIjTt/zFEykjos2v/WBQuZh LBER39qeIb61OARhywfz1PYY2WitZEJjD41PmeuJ5+tm0AW/KQfyTk83MIhqg9lJpWZ6 3MOcWdXrbgvkjDtom0TIrtEGM3xrGOdfjvPamv0zx46jaTQsHPhgRlZJVFy1LA8jBJmE jQtbCh5SXEu1oOlrRxt5tAsorhYJ4pGBK+US23w8WzKJKrztykuLH0IiqYB/5icR18d6 KVtw== X-Forwarded-Encrypted: i=1; AJvYcCWiwqSuvR/lhUhMa6zBo7tqAOfmhywhwS6omSWaelutQ0FwJSFxC6S0zguqwOaDv/l3O5abw9IdzTnhOg==@lists.linux.dev X-Gm-Message-State: AOJu0YxW08zXorot6OuVZnS4s/FE29aH+xSeeDUPn1EP5a6kTjGYMzut YbdeOFgppbyCMOotsm4YOKU3JS/Rjk2CIT6pc8sEzp5VlrNA66Ya X-Gm-Gg: ASbGncuDKCT5wOxZh5V0NJb8rNgwwfgP9RM/hrJvgzX5rQUMAlw9BV6oQ8NPvIz/AFX sHkr5dIEm2aE3WgCQiJ95iYIovHGBiiIC0J/YfRnzA/x7Uc9vsidYTzwiI+VOM6jkSvJvBXoZFh iEZmPNWuXlht3ao3BJ6iDf2BwPeuC7TPg7Or4deXGu5t2QmeiQgWzzMazbkwsMSWO1X2ei+79Qh 6+SMuy9omkR3k17/rcROTATPBk0lRqOWR7/esedQvIcvugI+02O+zLA+T3iNfUHKpk3IG4pVYJC OQ9FsK0= 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) Precedence: bulk X-Mailing-List: ocfs2-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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,