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: 13906555 X-Patchwork-Delegate: paul@paul-moore.com 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-security-module@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: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: 13906556 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 36A1418BBBB; Fri, 13 Dec 2024 05:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068822; cv=none; b=UHaXOP/cYeQvPd0/c/M7ZK1q6KL3UgjI57RmveDskbUeJL4ZEu5VwNfmMuN9WLr3NAS2GpEMqLh/+am5Fv/zidijrLm0OybB5zFUYhQ1FN3rqt7hFMmDRpxdaRolf4iQtaOsmFqtHTBajrCCpTLUkPS7019di6IMknlUxiMAf8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068822; c=relaxed/simple; bh=PCh1gNdVkWHp7L2j8aSJAn81J3xtchPE0tLiHOyl/eU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lYutrjLRryUeFpzOqIrs78a+j9PwZkE9yc7iR0fR49ALzWkS1lr3NULPydjcKNNhLxBUFb5iBsKlAwbQlrU7DZoaX+28VdHbbLFwnIUuN4+0cD6IKFzc4wZhge1kLmiEe1mkIZolwvTDknfn3agoQjSwLlWKKkfZqedmD4uSuJM= 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=j6hthnqi; arc=none smtp.client-ip=209.85.214.179 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="j6hthnqi" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21636268e43so18023665ad.2; Thu, 12 Dec 2024 21:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734068819; x=1734673619; 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=fVaAhWgLsrOIaawWt+Es3lyBYssP2HU9Cngct4cKfGw=; b=j6hthnqiW0uRrSBBNpeFstiL3xuM4Qgv8z1P0+XCJnuxbmI0zub5Nk9V+90fK9fPsv IFdjrL+jez+oZFWJbnvD5/ejRxwWOX0DrzoTz0PcS39N4oMF0bJwe+5j81dPnAoipgWA 2IdIqPf8GzMBJDKd5V0S+m3NSqdUfyrp4gC8GF3Ns/32LixwTjAW/6c2Xrvw6rdkT7hY Gc1//OVVzGKtRAJiw4uNcRx+53NaqR6/URjdcjPwPWNTQb7KhlLwUHiWV9okPYQySHx+ uI1TJAYVxQ11HcCkUgj1wy9FEdrazUghEUcZfJ3B9c9/d9SBWkbsYZZ2TS7yLblnRdGr KpiA== 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=TJ07awjO7PPBHXT9quL+5D1JeFcsGzHv/99g25L6/prT//p7W2b6VHkG8kwZ/Gr6jJ xM4Nt2lgc6maCiHCjb5pM+2kjyvQTM52k0e4pIRvE795zdpAp12i7bhb8JNrXH1mJT+x wg+Zs2ohx13Z0v+KHaFlieRWppXEDIICKd2lvjuf+8enAKvNMgc8VvkJw6BfFg3ucvqK HB4V7RZmHJ4ziDTAQeq8BHfZiOKOji1BPwwxh1qwp4KNXyTj82SPAJtqliSc90YS1MS2 vW1f08dEJVDJYwyuUpeIDmdEEn+3yZuvQBAHXmZzjaaBoUKI9Rnp5+rd4ZPu0ihjJmkd S/MA== X-Forwarded-Encrypted: i=1; AJvYcCUet/wZsca1OzU40p1FEBjOyfdMFdXZFpI94hZ1wpb7DGK7uwSV7OrYdSY5w09W+LoJ1xjCc/6RjQwMl19iBYt4ZIvCbNE=@vger.kernel.org, AJvYcCXHCChkaFw9eHpdWsQtstlRAK4rc1tAQRt83PbJV08FjcaR3Bi6Ir92q0RMlundzGPedAHO8F5KXq+PkGSNdGM=@vger.kernel.org X-Gm-Message-State: AOJu0YyEzr23w6qrGNFpLbmsEys9S0jSQ9no9/2Hkjlttv9q+Zm/cdPW 408oiO0wVc8jepzoGVQQvEVKy54A9QWQ6+Y71ZJ4l6a0aZnjhRsO X-Gm-Gg: ASbGncvKincPcacOFRsNIzGaRMbfLbPoS6GB9x/CherAYsbBnZWQqvq2s8b54C1eMXs CPGDxyG52x71qkqwQjbtsTOmjEzZn6pu+DCNzVgcDEhcA4MnNKSl9bfWbB3e0HS3xl/VtwkLnnK m6WznM8g9EP1a32h/YQ7cnSSPr9i4l4UtA67225qWk2Q/z6DuPR4k6xwQkj6ev19zVwh5ez8GHf PVdHCwlWZKRzQ1FXZJMDl8GcL+tojh2PhBbsL+VVeULusiakTf+qyzi8buA+w/c/16SvNHcDAbg GpH0qWg= 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: linux-security-module@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 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: 13906557 X-Patchwork-Delegate: paul@paul-moore.com 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-security-module@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: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: 13906558 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.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 3B28718C910; Fri, 13 Dec 2024 05:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068835; cv=none; b=Z5X8YbqtfFpp1nxvTAHaymbwI8Phy/X4aOKDPRWMEn26hPp1ahZ7XFALqxYGNm7jPHSBOxid8ZRmroloLbeaLCin3A8OdddanKODjrqzTb4AKJvzsmb6nfWALn3k/2OvL06YCUU5c/CN/sVpctwsPvLNF7JeFFSXUyGM7Kga2+w= 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=GPCHLluk; arc=none smtp.client-ip=209.85.214.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="GPCHLluk" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21654fdd5daso12213995ad.1; 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=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=gS7oaK0RsPIguog+zKCBYVnzq+DdL6weynD0punt/E0=; b=GPCHLlukaGNIxRhr1ziHpmmkeCVROHQrh73jrS8yVNstrKgaOU57JW35c7VpBcTjpt 6vClchNvyQsFv6jWE4MldutN0Be/VjlyA++67sidXEyW6AjAOqKkA/A0nddbouCrFioV c8hopZN41NKyB1CsoZuChNAxk6AkYUemSYqzgEUaCZU54jV1Ye0bPvGX8LjhlZgeFXS9 dLHsJkAee7YQDoP836Wm6vexTZGkcnfPLkG07ehRKznznqIDiQCpfl1W5d5p8sR4DUR2 TXzQS+qKURaJNjLWk3qP4cZ6zM1nMxIYxSX/L4nAvUv/lK7tbQquAOjw9XtlCWEsTRI8 aTjw== 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=ci1MUuw7PdlFlOpWADCRC3kLQcw6eHhwVINNHyan9jLSgG5PjmEJVSuywA36paHRc1 Ihze6Tp3XYn+hU+mi1kr9BP6HDmpGbmsBPXxnvdc2eIA8sP0WsOv21JsuCTI9O+iDwTe rR92oWCg+JYa9taW/bTZ8kOh85Y53nAQDE9Q1zq/hHI6Y03Re6x1GW5VfOREWOpgyMrv VImdiLikekZDJ+FWWZTFx2GOr1qPE9FRA0VUEOaEK7mn9IkElwarjOLvpGpnDgidOzLU 7fagYcxxj8WxUNqzCXupf37f2ZtVtAPZ21dvjo8i1VO4uSPgzEsAZUK5HBDUcaf1kQQs 3e6A== X-Forwarded-Encrypted: i=1; AJvYcCUTsaxrSLmQWaC0ggwsX5xpdbNZCYRZ5rXK15frh1PBLjzdnNK0NmXsILIMukrz5c3sdsRhw7D461+2DzSp26MZ/ADvO6o=@vger.kernel.org, AJvYcCUVXiHJBeEtwRefNgSFxKMa1tKOz1Htul1gqkSsAYh0opxEt44fY9AIANLDN9Wk4e6vnPW0UMDFvaG8Xg8X3zU=@vger.kernel.org X-Gm-Message-State: AOJu0YxVvPsTPeeNowm+glmgErP30Xfob8xShmAhdb89mbhMSFZJIrSt yQkpX6svIPolrXMI1Q3TyLah3gnz4T6qg07LAspFdi+5sclkX0b5 X-Gm-Gg: ASbGncuTWJXiSPkaSDA/jYHCoSv40hC2bJs1HVKuIul7LCW0A5QYSztuhsKS5XOwHAR s5bc0uRZsI4Rk7/ZTTW5P77IGK3rFSQHRjS9195I5lIBFU3btEwkizqLGD10fjRV97jHjW9+QZm rBMdGnw2fRx05+OvJN7E+aGa2C0vL+x+FtbHM6i6TR+XStwzGQ02SBG2g/UYQh9lhQDZYRN98bt Aqz5joY3AsXrIyyt4bexbdapHL0eE+3rseoyJ4iu6BB3rpD13hHw1seVRhHryhjaqjlcY9xBkV9 LWrtvuE= 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: linux-security-module@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: 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: 13906559 X-Patchwork-Delegate: paul@paul-moore.com 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-security-module@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" 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: 13906560 X-Patchwork-Delegate: paul@paul-moore.com Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.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 BD1D618C03B; Fri, 13 Dec 2024 05:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734068852; cv=none; b=mopV+fsubHJ0KYJYkid2FLqvPsq2hHY3ItWHfpegS1xsScjP1QeSptk7NmWbWcBs9RMdMnWXDKPZntjRa325nN0evyb5nbnrI+aJRSUw/P8w1XDmGuCYcTIKZXjxHCzzlaaHkR2ojm/6XMLU7ud9uM46cJfvUCKpHTqHOJNMwww= 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=LJuqp3yV; arc=none smtp.client-ip=209.85.215.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="LJuqp3yV" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7feb6871730so980808a12.2; 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=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=WABVozVaGAUeC6WVv6dNDEWCXVmF+XIaxOqP2xXRnSs=; b=LJuqp3yVhmGWLGcD9S7APrALZnF7i2fnaEG5Yhw176+Jjy6UYXM6H/LBMMonX+7Hsp rA0EGNnLGTTF003unito2Yz7P422zOhQtMz6nhpKyX4fCiUQWSLzix9rzswHyPMzp+4U SXTB/8eZ+XU51o9FdKUbhCuibaIUnaL0wdLOLxgbj4fckQTkmND/8xuhbGZ78DZwnA0n qTFE4SP5W/9xvOPNLQxTX38yT5oRjbukLv5ygxKXaER5PfGCLCY3UDIc8HA97Dm9beDb XKssdUZ6PcU8a12AW7alaWrI2qY7hROFwmfVyVXE/SwuZa0BcxaqHDGYJewJZzJL5XH8 ORwg== 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=Ch1/cL5FbOBiSEhovxkNi8JCU/DiEmEeS5jPgbVmjmxjaBUqCJEa2huquGVDoICz+K ZmsuNSCUXOL1Pg9hn0aBnwOgYJ/Goxkv2B6a0n2O/jzaa8eoRRjY3mXa2xzwNoUFNB19 n/puoFh9x7d38yOtc4+KAEo9CxRzldu5o08ST5yATx1KbzOaY6u1T/XrIhiiFN8k6xOU kU13y+39SErx4VmInZOP4reXhgyGZHh0b4/NYuIEa1Z2bgJVjh95S8Mc0UIurMkT5nKZ dOKTW5joXhDWkZyIu4Qe5k1LSAPj5mrofKPbqKzQxa0KT+hVJaylK5FDdU+QFICF4cYs 84SA== X-Forwarded-Encrypted: i=1; AJvYcCUpHRbdn8yp48G2ER6BI6Kxi+UvHEg1xIDeAM0x0jK0QPAMjtNqiFQHVxcgjIJNUIg1tkW9GGzm9sJRzZzZ7ApyMw8f2MY=@vger.kernel.org, AJvYcCVI6hx69v53ErCLe5m3sJnkqEUxVY0WzBhb8F3YrpNU1avCC/msihvr5bqpsPOQUoHNRi8JQEj10WMKtN0rKxQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxa7nRJH8IdXCGLugKl9HdtdeOTRFEDyjsuR1kVexZ4OCz2oku5 88lnKTkrOUhTtXxkGjHhhWy+H/oBAlib9kdk2n06GnpCwgExyHwU X-Gm-Gg: ASbGncv7g7UnL5Yp2jF9TVh8PrPcedfbi8LzOaJhXXETLynsZ7C9XvAL1E10+oGx2n1 R6zIPcBJDdT45E8/WozC6QdUnHdLQY9H9rGI+nYp1Fl+p12N4ENJ3mjGwaP5nF24INolklYYzE9 E1r8+FMp2InrcDrOjTh88NHbIGYtiJHurRh1yr/Y/yY9v/CeVMYREjwSaIeZ6kqGDsCaDrPgJy8 3zBtnTd7sz3OoaRVutK6oBOH7xf3LoCmup2mWLcosmH1tNz1PpDP3es37DNTGXKwysT1w7jm4Kj 4rZ+Jlc= 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: linux-security-module@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: 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: 13906570 X-Patchwork-Delegate: paul@paul-moore.com 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-security-module@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,