lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241213054610.55843-2-laoar.shao@gmail.com>
Date: Fri, 13 Dec 2024 13:46:04 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: torvalds@...ux-foundation.org,
	akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org,
	linux-security-module@...r.kernel.org,
	x86@...nel.org,
	linux-snps-arc@...ts.infradead.org,
	linux-wireless@...r.kernel.org,
	intel-gfx@...ts.freedesktop.org,
	intel-xe@...ts.freedesktop.org,
	nouveau@...ts.freedesktop.org,
	dri-devel@...ts.freedesktop.org,
	ocfs2-devel@...ts.linux.dev,
	Yafang Shao <laoar.shao@...il.com>,
	Petr Mladek <pmladek@...e.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Andy Whitcroft <apw@...onical.com>,
	Joe Perches <joe@...ches.com>,
	Dwaipayan Ray <dwaipayanray1@...il.com>,
	Lukas Bulwahn <lukas.bulwahn@...il.com>
Subject: [PATCH 1/7] vsprintf: Add %pTN to print task name

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 <torvalds@...ux-foundation.org>
Signed-off-by: Yafang Shao <laoar.shao@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Petr Mladek <pmladek@...e.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Andy Whitcroft <apw@...onical.com>
Cc: Joe Perches <joe@...ches.com>
Cc: Dwaipayan Ray <dwaipayanray1@...il.com>
Cc: Lukas Bulwahn <lukas.bulwahn@...il.com>
---
 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;
 					}
-- 
2.43.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ