From patchwork Thu Dec 19 02:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914415 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.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 D30408634F for ; Thu, 19 Dec 2024 02:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575708; cv=none; b=mjbRluDeSUja6aKOmkMkBfQ4VFAZt2Zu/v40hE5R16g48HbbLFbGfk8aPsxLFeXXzop0oN1QJ+CnHizEEMZhTpK3fRS4Mm0YPuqO8j2/OlZVnVh2sUsJfchchexOzHr7MSb0CL37mwiKBd/qDIwvEwfY8EKw3G923YhlmNQhwxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575708; c=relaxed/simple; bh=yqzB/UQ5CgxwEer/KAHpFdkzi3xdVyXYQPOSmuyPZ6g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c7NuJA2rmFEgYMCanSqtwr0dwKdtCF/azhwM9F9zs/Vi6ZuNDBHRo6eJleZN/w675Yx3Txdzb2MgyH/RyhsVr2HFKZjcUlLq5MpTTlG6Z5PUrnLd9XEFA/AwoVsCncBUVOS2SjhC9t76tAvGFFIm3uueb+jwPgkBV5JgJnzjaXI= 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=LqRVcb0+; arc=none smtp.client-ip=209.85.214.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="LqRVcb0+" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2167141dfa1so2840805ad.1 for ; Wed, 18 Dec 2024 18:35:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575706; x=1735180506; 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=6yZ75uwrgzXS/KAS9XiI4pfcH/Aa7U+Upt9QqSiD0i8=; b=LqRVcb0+jpoDNp585hO7hJpgi3QCsJZAc02zuXjyxGqt26AfS9h6sVie3NUnlfOvAo IXx01fm8j5IEd2fwV1LymS9TNdg5djL+luNwFx+UXFwiCS73zbhoctlQK1A1tfKmwVpT JtD3cOuk5gqN2Gm+y/+9EzYQ9jEcUiwJ6QI8MACMtX8tgTWPoIS+VioIbf6IRjUECnIY +wICLbQp9oRVIGplX1a2ho3ed8a6y45GAZnOq4Ty9lV6BMbFf5Fx30a3Nfi71H5R1kDj HRXf0eG74tG4mKfji3H2Oc/bvtc/TBO/E+plrsq8UGQRuzxX7e8YzTcydbpbEWo0NBOW Oz9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575706; x=1735180506; 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=6yZ75uwrgzXS/KAS9XiI4pfcH/Aa7U+Upt9QqSiD0i8=; b=PuT8yMUXZkByUaD1QAZ/aCRbqt2hYESCg1pV6hRB9bE7mm9FVdOyKWAfetgF2pZdeg etuX+XLA3poD14nkMDhyeRay/ztMmdqRMVka8DqMVxhP/bmediQUq7NirGmZdxk/HMOo KQHARPGOCLgm7JzIwchXZB6FVD1pFn/6dj7/JwhBVMGejUI0Bb3j4NpBc+l4UUSmnxo8 TfLXz34c+cd+66QCTdIN8TiP+A3dSI7Ya8IpD1JB5u1MVeQkLY2Ve8HMlKdrxnrSymB6 Ow2soQkUyBQPrNKBHaO5rlLnc826xa/FRHTho/lAjQ3r7m7k+IzFJemzhxkoV/EtqrZl 4RgA== X-Forwarded-Encrypted: i=1; AJvYcCVet0oBEwEcKIHABD9uW/2jSC0Din0UpCROicp7mF8rZF4DUOyCqbhM443Z3aJWMdMZyCgzyHnLYVJ0lw==@lists.linux.dev X-Gm-Message-State: AOJu0YxUINat8EMJJ9pZaG6D0VQqMvo8xTd9poc4EVQ4j0sakd9DVsQe qE/SnQt4NYIbVUtpeWO4EY44mg77aQIPB+rcODb+mEtDf61l89+R X-Gm-Gg: ASbGncsFTYaYFqEIzgEZI7FRqRJzJdM7grhvVnuY+/7VCbR0SK8hr5JoQ6NoHIQunz8 HFlq62riq+ZQAwswqTPRaGj4cFjvqXlIZZNw/3kfYpqVmaRW4/8XIrdN+py8vbS7k2dzg1aijRU GVH1eMMjM720mUZK9UYfbs8mRNK2c6EuqiSBCRrGrpsAcLk1xdQNdaPjT0DEIvPHE2guyNx96Ub z//xFXlt0HKqmfP4OM0qrD2B7SOYRakPNPKnqXTSUrBWJqU/1bFBkM+LEovAbQY8S1FsX3P91RZ wT3WVI4= X-Google-Smtp-Source: AGHT+IHDUXmWYVlYvXYhHIsD36N49JfOorXAToNFZUciCwG5nEYfG9fZ9g2sYrKUGUIeEzsd5pUGJQ== X-Received: by 2002:a17:902:f689:b0:215:2d2c:dd0c with SMTP id d9443c01a7336-219da5e3b97mr23433885ad.14.1734575706180; Wed, 18 Dec 2024 18:35:06 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:05 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, 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 v2 1/5] kernel: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:48 +0800 Message-Id: <20241219023452.69907-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-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: Serge Hallyn Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Darren Hart Cc: Davidlohr Bueso Cc: "André Almeida" --- kernel/capability.c | 8 ++------ kernel/futex/waitwake.c | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/kernel/capability.c b/kernel/capability.c index dac4df77e376..e089d2628c29 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)); + current->comm); } /* @@ -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)); + current->comm); } /* diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c index 3a10375d9521..eb86a7ade06a 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); + current->comm, oparg); oparg &= 31; } oparg = 1 << oparg; From patchwork Thu Dec 19 02:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914416 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 E6B74146A6B for ; Thu, 19 Dec 2024 02:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575713; cv=none; b=h0k0lmX828nzZe4Zb8Oyok+ift+bZ1O2Bq2L1UIO7BlzNpH7nmCWqqthQKqELk/ce22y9zLhT8H3FxleQlN5lYoB+HZxpbo/Opq/2tNPc4XpE59Xa60/V31tv76SjGaIzn7zv3dqbFjzjM8/Bl9xdvMS0e6LneCTdDK+hi7lJiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575713; c=relaxed/simple; bh=fjvo4dYkUreQMMEsg3L8KRAKXKBd4yx0ng+KH/F5vq8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uhz5PMSOzmyyUwJit7Ip8pmZ/dGyrowAgz02zk9gYsu3zM8gd4JxVUku9qfB2iQ2osOYrYM7wFfufVu6CimgmSNlLToH2aiQKN1sudlwpVKKa01Rl8286dVCtg9uBRDGUzEtn0VTIbn46gpshIKS2maxoaKVODy7qr8er+U74k8= 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=jxpr6qjR; arc=none smtp.client-ip=209.85.210.181 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="jxpr6qjR" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725ecc42d43so279660b3a.3 for ; Wed, 18 Dec 2024 18:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575711; x=1735180511; 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=GFcOX4O91tQFD6muydW9g9dtgYf4vZjGzF6jEGHBeGo=; b=jxpr6qjRIC3bsrV8Hfw5Q/uz72e6NeA6qIOVGxabARJayyYIGITvVZHeDVjBn0PFSt U1ZbvmFna2/llGyja6Or+VPku7nbMX4FpqkmM2LxW0z1UjoCZbNAu+P/7i1VFl1Pc7Cs 0Qwpiqww/B6ka2/dIuOsh6IIX/K1nkFw9O67i0CfxnpIf5c6WbEBzKkAJdNgpemZsJQH serdyT/LaEtYBvRCFpRiZ9X9R313Hflj3qPRNduHCsdmiISNNlwl4tabjjMWmKcNFlYy p4XgFkznl3rfmtsJHz5L81Nixj9bwgnMqp9JuptDaN+uJ8h963S8tRL2ADUf5t5xzGvW maNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575711; x=1735180511; 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=GFcOX4O91tQFD6muydW9g9dtgYf4vZjGzF6jEGHBeGo=; b=vG5kXhL4o6662NUefWSMuniE4r5elnVQ1mZb3FXka8jZHpJHV2zw2jfGzYGZG+RoY9 /sCW/xJ/GzWMkorEtfR3Lt7MKkowQL1+pzX6a7xHWDuP+cUb12EQuj/YwQBhllaQgi1m 4T3eWfHi9oqXgXoKKG3hqD1ZYQvKLzXfSG+ZDXUwx+u1c7eO8xjfEKuqVi1I9WO8ur2Y Ll0QiEIl4CNChgFt4Lv/x0sGlwU8eZk/r2fXNpQ/iqfYoPNLyzjVpqOBh5O0hr6uTJki aN5cKTe4ILHD1XltRbyFPF9DB+vIt9BxuAQ75gseMQLJD3WjYYzznqMre/1oqbkrWI5V nZ2Q== X-Forwarded-Encrypted: i=1; AJvYcCWu1XDlGHJUUVbflu8MyrkB8QcHutB++4gyci7uRWaTLkZVBdfVvFr03xoy1B/2Jq9iR+nhm83hdHIrBw==@lists.linux.dev X-Gm-Message-State: AOJu0YwHfXsvjSe2qvbsuFRHGQRV3jSSaXbxmtBqtzJ1BBaUG57x1w5+ 86NYF9GTl9Qa93FSDJwlq/z6VdcrOiSHxRMxgBbI/sb6IioSJwUnLXGtOyklsn0= X-Gm-Gg: ASbGncspL5JbDNwX8dJHuaQ2gSj0QyNoqWa+94nANE0tWpCV8MaKxSfwijtBFSdalBC Xpvw6i8fERKvYvihLpJdii9/OkwdW7hv4ohYhnJwuELl+Eyv0VGfm+RuBHN/Gguhbx6K0vMf9kt of5vzrUjwKZ2+9g5RlTBY70KK9b/fWs5JeV/cdZB9pg9NO9ySsAfMCqjTN5C84CnQkvuGrJgvSf whOyipSa8+wq8KT5Q56F8PLU3Th2Xun/x/zNCqGeD8Sc3VvLQxQZfU99Zw4CMXXGuf3eNWdFjFd lpxT7A0= X-Google-Smtp-Source: AGHT+IF8uDHPAeHRKoSWXDpZOfxN83+9I3jRkG5wW7qXuv+87XI+9vIxsP70Tcc6kEOf0TdmQfwRSg== X-Received: by 2002:a05:6a20:c6c2:b0:1e1:ca25:8da3 with SMTP id adf61e73a8af0-1e5b4820f26mr9200947637.20.1734575711218; Wed, 18 Dec 2024 18:35:11 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:10 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, 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 , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v2 2/5] arch: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:49 +0800 Message-Id: <20241219023452.69907-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-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 | 5 ++--- arch/x86/kernel/vm86_32.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/arc/kernel/unaligned.c b/arch/arc/kernel/unaligned.c index d2f5ceaaed1b..3b2d8b1bd271 100644 --- a/arch/arc/kernel/unaligned.c +++ b/arch/arc/kernel/unaligned.c @@ -200,7 +200,6 @@ 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) @@ -212,11 +211,11 @@ int misaligned_fixup(unsigned long address, struct pt_regs *regs, " 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->comm, 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), + current->comm, 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..e6cc84143f3e 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: '%s' uses VM86_SCREEN_BITMAP, which is no longer supported\n", + current->comm); return -EINVAL; } From patchwork Thu Dec 19 02:34:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914417 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 4C86C161311 for ; Thu, 19 Dec 2024 02:35:16 +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=1734575717; cv=none; b=ggPttJgUmPICaiRiCCKjPD603Nj9Hl8Upn+3mebQkjQyRS7wl0y3mIE5bwACICKS5TZb5aXXPqLyUucSC7NFw5SiDtu7S1zttlgMU2pBJ0N3Ml1HTMphnjzActOmOY9crc1Hl07z2LBUfYKYEQAbUoK/mVa+OkwzqAcbaJ64OlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575717; c=relaxed/simple; bh=hl37Iql5X8gsZ29nKhRpHi4iYM29ft8c5jBgwm122Go=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D+9Ko0isDKD17Da562U/G6LP1GAY6eZLJ0SdoWdPPe6b1J+FdF70jhHopTXNwUvLrTZaVEYu/IQLzR4NsC1ePGCkqgbHJS3TBNy7tVZV1ESc9CLpJy3xO1V+nXhegXlmYORy7lIlF0iMnLBGd6UY2orDmLU2O+jmQmzBoIZtlWE= 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=kf68mBOa; 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="kf68mBOa" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-725ef0397aeso257521b3a.2 for ; Wed, 18 Dec 2024 18:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575715; x=1735180515; 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=Zz5f2fkK5TyUEN5/ypHLYKDvnfLQ33CHwDb71kc+wK0=; b=kf68mBOaCVHyMFbtyqjGZMJ8J5XN1Q4puohkS+31qJXeuXUMM7wBHCREO4kCL/2IVT G5wyzAVHnURDbuPEwq0j/ihrGYAUweO9hTwup3Qobw8xwf0Fu7Xo6OXViSQEs/zQOQyD WHzbwg8SmS3jkgcnmI+/RzbdpJ5XwB0m04ES2mQ0JccFnNTDh7Y69zsZozOexyeuY5k5 9K+Ij/flpehn3yIxAD+Yr2YEnJn9KKWPA5Gp/LEDVfLdcJx6s9D/vy6wV+Iej++EJ2FO 1la3GDvgwWmsIYaWJA8SoChGED0kAspbRkWnjsSCsWKsIDCzNdlzF+X+6QX8XEyeFz7R oe6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575715; x=1735180515; 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=Zz5f2fkK5TyUEN5/ypHLYKDvnfLQ33CHwDb71kc+wK0=; b=GTNXKNDScclNNHVCxYL/LTrxw5cFqqd2qO2TFrtvz+nVF03BZP5cU7ukmJo5Vy20Yt FHg/VvdFRj2OUkA6kq7OAWgB5SpQEGUmja/xJy7ZQbjhGbFLqyNEkSllTcG/N8AtcTx0 ha2fXHZbF5pSP3q19IirXGI/aA7xonyqVoikhMLCatJZpj3siqbojhJbNetTKhSkizIf 9V7DRJ0GIFUburbSBtL5CgggYkolc5nrTxBdwNCWNOd6n/751PpqS6wCiQTsHK3Mc38U J4/nvrhWi7KjOJ0m9NkA6RrvObZn3/dlvJveY+gxVlD+0N103TuV+IYHcltqoW+5NKlO +9iA== X-Forwarded-Encrypted: i=1; AJvYcCWdz2PslTUe6rxdDhjmmpAK4szIlRsfTobo66KoTr1qXnxIROXymMSXnu/bjAJJmG/b9bR0ItHMsZx0NQ==@lists.linux.dev X-Gm-Message-State: AOJu0YxpUDMB4m5VXyPxPRsWistMJnyuGV9gXgZX0BDdXiIVdV35F5iQ o3ZuwaEV4V3lwqgKYglTzIRTl72J6xoF7yR/KaYLfWxIZF7DYE/l X-Gm-Gg: ASbGnctZO1M+LDTHNy+X/O9Lbe80MkqGyPRiX8EjB6unH9M5LEVcqGEDFLLHAKtcxwv hJepV3AB0R9HV5YoOEcOtxUN7CGRBdNmXZH6Mdwr97ZB/LsT52S07qAEnVfTyjEIK+hAHm8jEoa xvRN8L+vL6HHF50ut7oRugNyjr4UsD6gCuP28BbaTVYhZmyiplcYNQeGHZu9fHr9WVphk2EGoOs dZH485sWEGIh+/iGLPYc2m3BKFd2o0VZZqfDK9BWgixJROaNy2CGeWBv2xsovEUqN8td9BUmToG UggdSd4= X-Google-Smtp-Source: AGHT+IE+5BVERtvEj0uFGUNd3NBBPkGat0lwCNqupmyw0FAX2xvKE0cJmTowKcGod/Hmj9SrgliLyA== X-Received: by 2002:a05:6a20:a11f:b0:1e0:c0fa:e088 with SMTP id adf61e73a8af0-1e5b4810ff0mr7532504637.18.1734575715510; Wed, 18 Dec 2024 18:35:15 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:15 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, 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 v2 3/5] net: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:50 +0800 Message-Id: <20241219023452.69907-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index 3bb04b05c5ce..bea70eb6f034 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)); + current->comm); } #endif From patchwork Thu Dec 19 02:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914418 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 22313190685 for ; Thu, 19 Dec 2024 02:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575722; cv=none; b=nQzWQGToLWvG9hxDctJezwbwDrxVUE0J4QtBBPNxfi3pA317mZsT/4p0t09uNLZdMjjeGohaxvyWcTxLTGi6l2YyxIIhG9n3XDO7k4xea4QN7ZpAXRNuDjgODL4Hc8FGPDZ5RvB9tX0s6XDNFC0Pdo4jH5qUAfXfwZGZoj2fofc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575722; c=relaxed/simple; bh=uW6gREAjVtJ2OpRjMy/n/Vx7nbzOviJdyVpvyg6VGj0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QoftRPDyod5EtycDT+MQ/98YLVdMzTxZun6BaN/KKbi1gTtePhuo4bdjOR/FCwvKvEGY6A+eivRB2auHwuZTdcRINIV0rAavkgC/HWvlkU54pcFfyUKHwL9AKV2uv/njlZ/k99EQP/O2VvHQiIbPvmOAmuCTzBN0l889DLHTel0= 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=PY0EL23L; arc=none smtp.client-ip=209.85.210.171 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="PY0EL23L" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7292a83264eso280664b3a.0 for ; Wed, 18 Dec 2024 18:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575720; x=1735180520; 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=35FnTfH4WG+K4PY792luJMCXMpwCP4Hox12oxUuAxYU=; b=PY0EL23Ls1HynGkPn7mXnBeph+kA2TbDU7DIOXdEIwHa9/mQy69F2qxrFK7ErlWwQX SBIk7bthoPwgXamvLyBRcenHhzSiQi854jXNCadfA03OehpUP/L/LCtr0DD1V0Sr/Ntq IFy6eSEVj9hhpq6O7O9L/9676Cs9/8iyd0jzgTg8Y0USlvJzNuMzgwzTyeh4lbriOREq eBJxkag6Jh2ZCWglNq9pMmvcHFRhz5pSXZa8uQMZRxvJ9AYyy0WtRirr67P9FfNEn9yD Vhhn2ocARl/3LYSNgkqZqTYSSnMhf+VuRcichYeclFf54Tcsi1xV6xU51k8V5/5JcD4A BvvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575720; x=1735180520; 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=35FnTfH4WG+K4PY792luJMCXMpwCP4Hox12oxUuAxYU=; b=dDcZzoeqmqX/iT51xPJ7iKz1dbwAATfHSWZg/HwDckbFHm0YAH6lJH/s6Kb5K2LXXb wI8XEav47jMbVrAXiyxvEsidr/cW8Z4rMbpz5Fu+GwvVfZjCxTILbrFMGRMigx9ISlVb C9tLLcF9vww/4CMJ3hAn3+jDFNN5kbwlC8DR3SYM/vAjPb3W169jzepMwMQanUMkPulQ 3vk+U/gqdaSRPBQ8oP0xE0d0SpKDJAwNCx3gKkoPYeiBIUW0Yp2D/9w610vy08g5teYS rgU5DIyZ3QMuxN0aReuxCeVaQmF9Ksoe4WCp6sxJcTINsf9z1eH9nzK6Ha17X+CJJtlb XYwQ== X-Forwarded-Encrypted: i=1; AJvYcCVILtVzIiW1RMOtnSKPTl5pWOx8Na0ZWLMBqRCG48vw50PNgbkcuc2d9FoDki1OGm41yW7hqBDIQSYTZQ==@lists.linux.dev X-Gm-Message-State: AOJu0YzpG+QK2QCuJZA/sCXD8kSGWyCNq9RUECrj7LgNCIKp+0j8z2P0 lxkRcHqSSMFbp4ZF4CHJiSwkIvdmSLD7svwsQCcNzaqipGkz/DkK X-Gm-Gg: ASbGncuWs44JryLVj5+0VAbNktHp/p6FmV5psUFqYCl/++6SMzUdBNYDwOy235FCTZn TFUtvdd3hNrC8eEPz1z6M+05gr4cjE2vHBlm5UDjVH2CC2QV7KpmwXsrz5TqDzbCMvsxSyTfdfM xyXbTjGkRm+A+Hyth4hM6b18Hn1+99xbgc8WmJtwV+LshZdluMdcv5Fa2IMMBxxNbyf3ZCK33l5 3eizsCBS/Skg1c6yqeQQxPy5ITknSY6JSipfFRGQ+SAXmZUzwOSuSTOYZddqfVnwWI6TCvWYnEA SlVFRVs= X-Google-Smtp-Source: AGHT+IEYa8/cPCrPUtV+8BluujgYPFlXKrKcInk+YdaLokr+l/jazm3QEi9WUGXKVKTvc9yKVja0nA== X-Received: by 2002:a05:6a00:9096:b0:725:e37d:cd35 with SMTP id d2e1a72fcca58-72a8d2c2269mr8262629b3a.18.1734575720422; Wed, 18 Dec 2024 18:35:20 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:20 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, 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 , Paul Moore , Kees Cook , James Morris , "Serge E. Hallyn" Subject: [PATCH v2 4/5] security: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:51 +0800 Message-Id: <20241219023452.69907-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-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 Reviewed-by: Paul Moore Acked-by: Kees Cook Cc: James Morris Cc: "Serge E. Hallyn" --- security/yama/yama_lsm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index e1a5e13ea269..1a2d02fee09b 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 */ @@ -86,8 +85,7 @@ static void report_access(const char *access, struct task_struct *target, */ 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); + access, target->comm, target->pid, agent->comm, agent->pid); return; } From patchwork Thu Dec 19 02:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13914419 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 658DC86344 for ; Thu, 19 Dec 2024 02:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575730; cv=none; b=hFgtzHv54RrVE/MhwsInVSMI64Z1A2BfAv1HRnEUpVnC8xGYaN+rPalYl7OfPeVGHVVexqVv7GmSn/jivnB6fKaeooItA0Les2oacGwk87PxTJlx55gtMhi8tNx4BX5uA9C8dNdDVN1MIa1u84pj4j7IWRzO9dQkREApfbS5kqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575730; c=relaxed/simple; bh=VeLbyOfvsBoD/0QCt6XTwvSQyL69DBSOWRzzq8d05w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xp8h7m3SYEuB0TYKWylnQ30YO9b7L5HG3MNH7hyUBCAiPnV5fSw1ClTuKRHj6AFAOBrwVBHFMYlNSJ2wzW4UQG0AJ8LtRkPcix2VOjDTxzmQ4KIWEQwneQpnqk9ZLHmG+b+Jsst9ksCrhCTw23XXMcl9Xu8YPHG4JkEtLu6fgqg= 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=WI0xXvo2; arc=none smtp.client-ip=209.85.210.171 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="WI0xXvo2" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-728f337a921so332226b3a.3 for ; Wed, 18 Dec 2024 18:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575727; x=1735180527; 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=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=WI0xXvo2S1qGDjE/1+j0/0LgMd6TA9g2pMPmFZXJcWy4YKaBF4vgfJNdYCpJoCxTtx 9fFRWrNeCbcxlohYYELvGnjhkjgeAgY24W03bRORbohvV3ScHf0G5Djjdz71AywRuUfv lc30SODl5/KDGAro4txec0xbtK9WsB/T9bJtR38E2anvOFFHMdZqiXo0X4vfEqF23tjk GYjWpXId7UcqmgULttQaduJhgnR7PD8gbf32wxnTK3JmNt9LnfBpK4oy9q+OZlZQyl/H DYkgswZo2wp3Xn4X3w8qRlKyVupQdIFI1Co0viez9mX8BPJ0p9YY0KoTLVePtDQ9Zz/n ciPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575727; x=1735180527; 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=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=ncbgL9lJHIH1Qh9gnux0bve/piSWA3rjsWhc3OpbefJiYmpcVtgie+w6fYfKmqGL3H 7iqxJf4k61NxuGd6uLPD3NSybPfIfRvuJ/EwS35wlf43S/V1j9/Fqw17RHOme8QS+ZiZ H6G/+8FEsOUeWSAJe35BtD7UJLh3dZCdzyV4K8zSRvotSLbJm77DQ9VSqnGX6xlbT6uA +FWiqaUQKcDhegwGIdj/iSfcg4GmDDH9wV7/8gR3fKd0eEhQ3K4c3L6LCbQ+qEue0FoK oDL7Wi1N83USyaJYOGY9Eks7t5h07fjzg7seERdxVF/ZOnePsXqeDrvn4dwI820siP9s /J4w== X-Forwarded-Encrypted: i=1; AJvYcCUVE+MLECuy9mddU0H0LxVKCKZiiw47qOppSRDnVkvPypVIc6l/TJOmMmoQGwJiTebGSHMxCdr+EnIkJQ==@lists.linux.dev X-Gm-Message-State: AOJu0YxBS1Oj2LONMZ7Bf5Wi99lMrrnE4YdsL5UyfN4oIj84nFtRF8Qq RUMeYYfZtSd+Po7xeZPXwERe3iI15VDM8pO0pdMHawO0a6CjHdtu X-Gm-Gg: ASbGnctVi6cUVHgHSia9fZXQvT0BxSuignE/eW14EwWfAORkj28VAgzuVlcxOelJALD 0cQ24rjdLsEqQVPEPprL0mxb6W4PhuWdIk2fnR9W/3Kf/xOU2vYx2t9aMYZ16iwh/aF+pW3I8f3 StJPnBLqzFwM2vOFiraq9yxX+0MmWp+cgiOvU5vUexGuyMWCkgxESE21tXaExf+fNw7fR3SkrTA wCel4nk9HMggOIqG5IPDQbHk/FyAq1JAa+jljibj8FHVMUu6kTlw2kNd6S3KU8mZxei/MzcsDno Y6NGamc= X-Google-Smtp-Source: AGHT+IEASYTltYbmKh5ZDA03zBv0Z8CD36/wkPvI28CV3U8CPosE7HG5sfVxRVIBm8iQbfYV7EQNzQ== X-Received: by 2002:a05:6a21:788c:b0:1e1:b727:181a with SMTP id adf61e73a8af0-1e5c763cc43mr2386992637.24.1734575726666; Wed, 18 Dec 2024 18:35:26 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:26 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, 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 , Jiri Slaby , Lyude Paul , Oded Gabbay , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Karol Herbst , Danilo Krummrich , Greg Kroah-Hartman Subject: [PATCH v2 5/5] drivers: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:52 +0800 Message-Id: <20241219023452.69907-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-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 Reviewed-by: Jiri Slaby (For tty) Reviewed-by: Lyude Paul (For nouveau) 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 --- drivers/accel/habanalabs/common/context.c | 3 +-- drivers/accel/habanalabs/common/habanalabs_ioctl.c | 11 +++-------- drivers/gpu/drm/i915/display/intel_display_driver.c | 6 ++---- drivers/gpu/drm/nouveau/nouveau_chan.c | 4 +--- drivers/gpu/drm/nouveau/nouveau_drm.c | 5 ++--- drivers/tty/tty_io.c | 3 +-- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/accel/habanalabs/common/context.c b/drivers/accel/habanalabs/common/context.c index b83141f58319..9f212b17611a 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; @@ -272,7 +271,7 @@ 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); + current->comm, ctx->asid); } return 0; diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c index 1dd6e23172ca..8729a0c57d78 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); - } + task_pid_nr(current), current->comm, 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); + task_pid_nr(current), current->comm, 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..62596424a9aa 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"; @@ -400,12 +399,11 @@ bool intel_display_driver_check_access(struct drm_i915_private *i915) return true; snprintf(current_task, sizeof(current_task), "%s[%d]", - get_task_comm(comm, current), - task_pid_vnr(current)); + current->comm, 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), + i915->display.access.allowed_task->comm, 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..cd659b9fd1d9 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), "%s[%d]", current->comm, 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..ea7206484d22 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))); + current->comm, 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..102e31f62f76 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); + __func__, current->comm, flags); if (!tty->ops->set_serial) return -ENOTTY;