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: 850786 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 C377B184520; Fri, 13 Dec 2024 05:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068814; cv=none; b=U51G7cCu3CoEc/hCrHogiZHSmghcEhfL+ruTAmEOOrNYZxfiyi0Fgbr9lI7emZfVSNWQ3pHb+YA3epCk1MbqdmN2RNGOAHvDxCONH9Y7Vuv62bJEBosjpcbCY8cTUqFxrPYaylFXL9K972RRoWuEZzeVRRXo1rsdnN7wGLIAAdo= 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=nO4fUTo+; arc=none smtp.client-ip=209.85.214.172 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="nO4fUTo+" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-216426b0865so12491895ad.0; 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=vger.kernel.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=nO4fUTo+ujRaJlE0S93o2VLnOHCaVD7688hvdLJlVwIgGhj1CxG5Rh5z5b6W4CWPgt VXGb5dUZ104qbbJ7zavbnJdH5Em90pNp6EDw6aAeAVSNrLa5IPyz2ZgxnQpBTXLxgs7e tteF7dtURQ5bW6atCZvHaB99Ro9ejpHKPLCsY3CEryt4QtdBGvn1V5I/6divebQguR8x vynCIhkC6zNsxyjgJMx/YGpacI63wRPdu4KcQ1rBzn5WRh94XTfQsHw2Pl+euP6o8NXJ Z0/kJPNThvi+kJbuSyC571Molw7MRd2w3nFqVZ+kzMaVZZseYtc/3NDfXJmAXDyZC7ad 2IBA== 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=NkGbrCOAZUaCsCyLd1YviDLDevn1S4Zk4jCo4n8J3cTZ97sXqJAHpsmV6e0xpcYYLe mHa1PxpVs72MMJoi8yZFP4N7IUqEpozvsTlaa6x6JSQ2Fq3ZgkJhVS0wCTPWaQn8/7gM jGENbp1vpixNamIHuj7n3XPbfAFev6xrsHOAmchB22d1G5GecrzqF1PjcZgBvvb0a+US 6k3QbYr5LePdn1Nur1mmTTykxrHihsFY64JVPR+pHQDQFKerzKZfPymrdrBiNDKiw+Rs S/GNq9DXXHJPjF3SB1CmiYXETci4uk6vb3YmdtZyfnIm29MtZCCsuj68Ozcbx9btiJEC h5fQ== X-Forwarded-Encrypted: i=1; AJvYcCUZSZRSb5Sgwrkze7KLzTqs/hWuV4qxE557fyn4MU8gh88syxkQ8MiKBcOCKwG8m8+8au2+RKjXqzalJcTW3mk=@vger.kernel.org, AJvYcCXW4hLlio1w5fcQiUMGJlUlsS/kZUC5FeTiQPT83RaN7DypYZinKdK6CFrun1C/FPMq3RlUKyXb1tGRYhzrBe9+bCOeIFo=@vger.kernel.org X-Gm-Message-State: AOJu0YzNXqt7kUvnSH+GxLtJVlINp929hAbhZRoCS4A22TX6Tv+wjiJZ gbnj6K37HhIhstKLHMp8dSv66gfc06QEorT9iM01mdKAyw15o3tY X-Gm-Gg: ASbGncuCdoyJok9fOTRISSWI11tDfulPO6aBiwW6ukWQigbFAO/dhpYD/wFsvh0N/M1 Coe00GkZ7IEE7qn+sbpIus+s+cpj48yB9dVOvCujNvy+Om0QVzPS2S1CCwPErr3BTSb1KQ85TKd gZs5FgLu4R7kRMaW3Uq7IEgE5ZaR8kLBR+n1962chBJxzKyl39gA2Y1zTayIrCOyMg96Qj/OLCk sjUEBJIskRXaMVbXcnHT2ym5PellZxvKFcTM9BdX8f56Z1aFTq+DATOJMRgK2KZVkeh8ENnHh7z WkOkqi8= 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: linux-wireless@vger.kernel.org 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: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: 850785 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 D8F0D18A6BC; Fri, 13 Dec 2024 05:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068829; cv=none; b=d3je9aYgrGkVAAmkPNIYOOCRcsKOBywPEFxlMtQTxAl7ZOq+EpLpoosgA5iJkOiZ/VjNjRyz5FAERmrhYAAPPgcysH9+Dx+Ul4rZRPmoXVxbxqIUxRzo4dr7EL92fSvOh3+HZaGJfv6dVLs1PgNZz8TqiRAMW7jXrppfiZPi1BA= 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=l6tG50JL; arc=none smtp.client-ip=209.85.214.172 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="l6tG50JL" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2165448243fso14748965ad.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=vger.kernel.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=l6tG50JLpSTdsDtWqfqvnzqzDF9HmSfga8IwvtVVfkGg6uszZJUPGDlvglSs/mRd7I 3OznjyRkFbtWxcj7EKOsmxNWTKaAPggPZuAO6OLMOCLDIoBFSEAZefiEp3pz0FVt9TNK 54SxAl28+xxATGwZ7o3Ti0Lf3abJ80/IESobOxfL9iyCw1zowOzp3ha8ZLMYyjA8KO1Q EzKIupYhIaK70BF8oQMFm5KKCP1ftQzE6fBWPds/eDSTVqcSx0almV3LBq06yuNyUkwI f72pMrw1wTPLE9fEywnicopucedEXYphtHv+o8Uyu5m5lFDRHTeeAk0m85KreBiJNj9d +C9g== 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=qVhRv20IapUVSoME52dsb8k9FhDpp8IjTPSM98nGNUXVYC7L/XOfLwU//MQq3WDXTo Zqxwwqasqn4opXTLHNmNChO3O+mXDkSKRhaZ8KNT5OJSW/jQ2gnMLb9iEHXLFklH1azB K3FEywUnur8LO/SEnTpPQWahNM0JliHfB0UK/0HIckl2QoMPywVM1LS8ThbhDUvnU3/n 6Xq7KoSIkDr+qhS0Y/zX8XTbQOMxhW2C1+iTYGWpNHROZxdzew1fn/jbg83ofZ6D2HA8 SYjUP0dDwqdR6O+2DGVkzZw4Rd6byTvB2zgebT441elQSqpoIJhj6D9z67omnuPbqlbv CPOA== X-Forwarded-Encrypted: i=1; AJvYcCWA21OX5tCLdBNBmdXa8KqcJ2L96klyV96A5jUnuFvqLI37Dna3bk5HzN5iUxXafL4CTMT/1/G+9o3C/Wv31C4=@vger.kernel.org, AJvYcCXpeROyOZToNx5MtS53fb47GUTdIpuEEpfdPBaMnkKAH3bW9mT4tz2+bT0cRodPL9VYgH+KYTYmhCeJ39NQyj3izzuO35g=@vger.kernel.org X-Gm-Message-State: AOJu0YxbR1OmDMoc79R8V0+9pctFOOG14JsLX7eoevQ3MOtWDXYWWb1E on15sJj/8EAbRkjpk6szOkr56kgk6b51PfyiCjMBs/JM+poWm1Xo X-Gm-Gg: ASbGnctVd50g0jmJWxRK08fyazl5PZYozVT3v7E0X1iRiNRqSr4+AFV6nznY94gWA7v lqHCS7bRWsBUcl7TgOBxJRALQCkkr4S7sjlDXfStbDAzHBPVStGe2BYn5drNDlJHNLPKv2f31XB WVVLuIkUHPXjwLmLOES57XyvG1J+5Rl7xgENF0PDe5M/0BSO3CAs3+4lmW6uzPZNiE+2X42SPPQ uJVFZj4nN57+a4RVq3M2/hBTlL2mVYm99nBBfcJV6Wgi+CzUZNiqvHid9tb76VN4h5YOT1zzF9C 3bjq9BQ= 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: linux-wireless@vger.kernel.org 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: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: 850784 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 08D9F18B492; Fri, 13 Dec 2024 05:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068843; cv=none; b=PZC7yyX56gu3505qh4GHXPfWBfFze2+iVY3vemJ4lo7NdMSMuhRvUQ2sjcCuvdbH76EblaaQm901GfX9HRoLD58nIh1EVyZGa6bcU7K5pBLFJj3mIwNOAd3urpQ+vaZTUU75Rv7wsamarxBuDFeRL8hEL4lFjqM4MfNZC9OdPhE= 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=TPKrle0X; arc=none smtp.client-ip=209.85.214.173 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="TPKrle0X" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2167141dfa1so12331955ad.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=vger.kernel.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=TPKrle0XnYRDJSGGcZknbiE/AKtJt75+Yi14xorxMcXOLe8POzFqq1y4I3DV9POl3H daPSCgmdFAXQZfCJl6aAB9p2rd3wnueGfBAuEjqvsPJSJIfvoGZdnTWOgPnhYFbMGk/F npLilZNtlJ1tbpMRwy0pGjvgonn0TX/BIN6g+tP1EahqZVLyRVYAXUIRL3/Ey8gCbcGq AmToQoKnrAazxnf0cNlPXMhVbm8SQGpBaMiQaf7NhuEPlA8L7MEM0J87VQB5OdQVc+y0 Xtd5g+3lTErBI2NuhWpP7eqiLNRdAAbJB8oyZI20RKHDWkDPzjgxy3IuShXKgbexjlcW 9iQQ== 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=B/gbXtRl1cnwB2ZZrV+Rzr0eibEMxOPs75o3F6Au76D77nhSi3i9Nrp8fkwsVRoNeN sUeOHM/utk6jnA5cvurgv+hi/ARNjq1yAkaBXmC8rG2m34fZGTOPzK5r4ERrEu3gxeBJ WQ8NFtaaPrmPt4w+lKFqQikzpKTHm3KkvJUeMKDHtaf/TbMzjesfiqU5lFd9bQb8GxsW UKwtQF6ujNBhvLG25PFvnIFXyPZrELV6RV+XhaeF5BOC1UTYUaSIfV+hF24KChaBWmDo 6AbahrhxGB0aYgYk7RcW7zJID8PByC15NQ+q93QU9nSb3dPMtnIQHRRZRDpYreTMSMOD kFxg== X-Forwarded-Encrypted: i=1; AJvYcCVpk/FQ7vFwKHy+faWqSCqeS71X+FXFstBA5Nh9TsGpe/9dEohER1e4CDYQdaWHMeMnRolAevgS4q8dwIUrbFXD9AGXunI=@vger.kernel.org, AJvYcCXX9IbrgjpgcihmekaV6GGoNwzD32a3tjRx9qieb4OTDeh8ENpYPhxows+hqWqXargbemjjfw8XCubup34DgQ4=@vger.kernel.org X-Gm-Message-State: AOJu0YwtQ/mOTBVDLbUIwdNxQK7C6fIDDh5YcR3B2Bf/9Y3utjxszfwt PawFGq0GlkU8WHoYEDiUb3TEcmt+rVcpWzvS6RThrRoBgNsWcKgL X-Gm-Gg: ASbGnctibRhs9Zo/SRgwFTb8jDqzmyp6Vb+aWdp++uzQ/Bu8NIhXCKD8giqNaYuNH7W 8uHGe19uA8rMo4VKjKhPjE7QRf7oFZl/HiENZU7nNFx5W0eFPbtOUIaZysiVh/4wVwGu5+SOUZb Ppv0tCSC1uGzqAWDIS3F9kEbgKvkUwuWMbcEQIpxHS0dG7XaXNi7nPSPttza1nnTcsVbsH3sYJ6 7y7LoUaSLpvgtM3cQOHzaL3AlO3r96DzZOGN5RObFaTzWWBO/NW9rQ3hV8ISvU3aM5A6lvabRSr CLvBEGY= 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: linux-wireless@vger.kernel.org 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" --- 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: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: 850783 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 D8E736F30F; Fri, 13 Dec 2024 05:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068970; cv=none; b=Yzn59xzhPPeYRolW14sMbwpoMTaX/NSvVWguUpOa4Rfg4iam65oCGycPL06Tcj8vSVrYI8KNcfA0Q5VNlh157OJPHaZZteeBXK9m/RdMIAm+WMMYfciSjNNb0cGcnpRDUpXe+eID2ejiUZfvmzlA11EJbfP1r8FZU7TJ6z+FVVE= 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=ZCbBD2l/; arc=none smtp.client-ip=209.85.210.175 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="ZCbBD2l/" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-728eccf836bso1246952b3a.1; 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=vger.kernel.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=ZCbBD2l/iDb6PloRpo6uwogSXrPVaRPybOnJpvUXAAqBE4iaxKmnBDaEoZQHBZEelq 0D0iyl8IbBXki3HI8bf7SXXmbKAOHm+iws9cHNceUCY9mx18wdN0B/iK1EtBAgEmyFZn 5MamgtFvy7tfPk5fKQ4/zTUOLPktjV8xo+B0D5mAFparK2iGyNGVob+i1vIWEEFSTstt XAyQMM+YxLVeG8psVABNEIWQjUQFYae8yQdOknEjPMCL+y6clEHWdtf6uQSmPbFrRJRT VliSDTFJixovDD7Y3L6q0OIiNfYSKEoJMuIKGgyoglFLuM6yQETn9b7mhORNIJQEPUT8 JQyw== 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=owTKe5vO3KzMyZZWMLQVfdRCl64A1Rn5PogPS8KWjV7smqUN0hL26mCIZlwCVXOED8 C4jDv9/Zkf94QL98izvQb1iyrveV0yVnoQRyzuHFLw9bFC7Z0fU7ZSVZIIu5zkJf/Hnp UMXbCWzsH8cheAem0FkYOWissJ5F0HUfeduFDG8i58x4O59wyPY+Sy/A1zw/XHKtJ44f +iBCQd8l1Mvys9WDiq800iYbze5HZs1mTkQFHybkPnbT359fd/7curXMsMZb9OTOJ4N+ 4W+0jWEJjo+nt7BIvVP1RBl9sA4NL9FyL8elB5ZadBF9P509XpQt7W3xANx+EIsIkvjZ LVQA== X-Forwarded-Encrypted: i=1; AJvYcCUd2zmuJ/dv12lELyIjSrePyEyx8ajHDZOJ2SSNKFvu2TXcKFmtm2FJtxhmKORhwRaZQD7WbfV5pPWLB0wJQCanM5Vvh24=@vger.kernel.org, AJvYcCVdLGVmBuJOknoQGa171CuanOXH/y81/CTALCDn4aMlDkLyN9qPc8SD1KVg68WeZhMwvFGxcE3kVLMyD/OjucU=@vger.kernel.org X-Gm-Message-State: AOJu0YxqtOoVRqqtUd4enpDt6WO7rZDX7eq89UWM4JjwK3CQZSPkRAF7 sjrSvMO22tgxgTK/1SovuA/DSjxYPJZe5VF6gx3SL2nB570k/gtemphsSltbolM= X-Gm-Gg: ASbGncu/8ThEtqlfXKdqcz0JB9GLTllJpWjxNfaqmHjiRxE/C6GDOQfCkA2mzkmH911 2z1rSXa4GbB8WumHFwhjsLa6bda+AZZ8vWicEoNMeOOl/5w858VQLFY18hWG0Tiwhin2iq/5bee jiRzW9b3zkOR9327lKByPDiyVI9Qkm2M8Q3YzdmvnxuVM7BDxWZ1F+JH8WHj5qZseBcF+oqoYmH M8mhDJCmertlcWAW6M/tW/o2l4XnhbkGcYZDSFskKQV/GdMahSL2XW9N/V9pHGL8hEUcmTjMwJx 6n2k/Vw= 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: linux-wireless@vger.kernel.org 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,