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: 13914391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6F06E77188 for ; Thu, 19 Dec 2024 02:35:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 367A16B0085; Wed, 18 Dec 2024 21:35:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F0C16B0088; Wed, 18 Dec 2024 21:35:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 142D06B0089; Wed, 18 Dec 2024 21:35:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E7E666B0085 for ; Wed, 18 Dec 2024 21:35:09 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 93F14141389 for ; Thu, 19 Dec 2024 02:35:09 +0000 (UTC) X-FDA: 82910140908.04.0E18C34 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf12.hostedemail.com (Postfix) with ESMTP id 755734000A for ; Thu, 19 Dec 2024 02:34:53 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CljPE5T5; spf=pass (imf12.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575683; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6yZ75uwrgzXS/KAS9XiI4pfcH/Aa7U+Upt9QqSiD0i8=; b=xYb6GcNEapwY2tXmjYdtjgMOPcMs6QhLDwKa+pPjN8Gfz+S97rtqmxdCX3EoqimFPD+OM5 JYCbeSmP6v+ytWwDN/RVjNXpOBtObIAxGWvA4+cRS/8JgfSN7oOGqtL7Z2QK0HYqh23BQz 1RsMXjFRRLpgNIOXn2fpQkaCJbd0hVU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CljPE5T5; spf=pass (imf12.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575683; a=rsa-sha256; cv=none; b=6Ta3WWLym0TWfZttCD3oOPcNGRSqOhA00tO5qJtbReimpP2DHsLj5glP2gkZWvCM95Bul3 9E8mE7oZKwdwo0WJp7YWZAQBtzyilvxZo3E/dy4wmNM6t6cvEmDj474KjQgOySgxXyTWGv 6YAOdNe3iZhsEPU93TwN3NvqfE53fP0= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-216395e151bso2164105ad.0 for ; Wed, 18 Dec 2024 18:35:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575706; x=1735180506; darn=kvack.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=6yZ75uwrgzXS/KAS9XiI4pfcH/Aa7U+Upt9QqSiD0i8=; b=CljPE5T5X99G5gVlWXB3CtihXgkyCAmNj0NwxrJQmVHeOBsWxChhKCgyQn56dSgqJH TF+dJ1bg3VJnZXnfuG1R8a0P31Y5RxoGM8fFxMBijnnCQeJDU607Fd+4ceyhJeIbu1EM fGifd/O9HSFkU27POQ9aqF3lFP+WsbPYFS4Nq1PdX2nooiLQvujoET4DbvbWIjjV+wED 9Tej2mPBtPWXv3EDcytONQxV2FzLw8HWYrskNaLDllxuzEBqPTs8ZlY594pPBrNz5NjG igazEQKm8j/jg4103v8S1wwQiCT0SiqZUjbLjUs8N6WKWdsD5H43G0ShgK35gKkOo3NV tJiA== 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=V+uqPj8cYROte9pzEe+DWU2Z0s8p6oFv8KTx0lxrnpUZdIYlgBTOYbs1uu3iGbozYp KaqGyWwnjFuh1KdTX80gMcgk2RuU9+7I6f/OiwJHlzA7q0+HXJ6/pI0AlBFsbh+o89+M fefoKn+1Oo1ej4tqX4yya6P6Aj/hKeSnDnHE8hyG4FcE1TyeOY7I7I1g/wP9em5r9cfo ZTtOP6pUGRNXwBL8JsfsBKoClgemKpWU7p4L8vfTX9FpC/df4i2eNGwX/xg+cnfFKWOy H8rOZJWz5z9NRGxEMRkcn0TeQwDvSosAmtsy9THuki9zal8E6Qk7tpc5axCrt9G+netp gxZw== X-Forwarded-Encrypted: i=1; AJvYcCXtW/mieFMxDzHvO543s+lNweiv6NY6TTY5JFf4kDcIsRVkc/DM5WG2RjfZ04J1p85DmN8Th3nC5w==@kvack.org X-Gm-Message-State: AOJu0YwtjJt9Vxan46hFiqsiQKlFa6wDmg/XiY5rtFZWLrApFvcwkI/P SPOlpVaEQosZn8p+4fCH6owVbmvQmGLe/M1YA6+RCAWVQeAvyEuZ X-Gm-Gg: ASbGnct/Ehl9hgTLdSUE/yeQP2Y9R1mDc5mR/kXXvH/Lxaqat0Q0bHrvXwDTY7YG120 l5H8so6WHKpAnrVywO0KbL/+Ag6vg1b649MKKnFUA3zNsBHsDMuIHHWsBW1o5DHtwiDMLlwhP42 GRxVIvWAy67++GhMjwsw963u/BkP6gsHDJcIpD5zWLQeK1xPO4HFOwhbgQNe4ZUa/t850rzLkfi n70upZ/Xtx4xWuj2qVR+VI9s5j83icEd9otqzhZwY2e2JPaYaen218vrCc7/ZSEGuVqORDpAkc1 jtIAtto= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 755734000A X-Rspamd-Server: rspam12 X-Stat-Signature: 9gss6objz9dzx5d9yh99yj6fe9fmk1ep X-Rspam-User: X-HE-Tag: 1734575693-360104 X-HE-Meta: U2FsdGVkX1/ChRBKcuBis7GgBSm9FKfV3SlPYTEtYlFkeQ0rctzRTIewpkemnmBApAsWebHNPVZOeCq52UEeac1+4y+MNy6yTjjd4Ft9KTokWU6tZhs8pw/m9H72LEIQ1SYn4ZKTrCBoE3G7hHHVxO3e7uamWxpajIHd0vgNrFxAGDXHtNMZ9JZ24Ixl5ajqXh3vrja0y0fPFN+13gXUUeR6qF9vxLHrX5as255zFp9qe3M0M2qVYEOFXcGo6MYap4Vq9EnPNzt39pDyOvjVW2AIgpsXd5iJUg3xxEf/ortotIGHhwdJp9DMLrr+iG6pUJWHrC227eMG2GI2VCIEbSfhk6PhorQue96S4LQ2a3PBkSqerZSEfKcfh/lbQ+2szKrln5XIAEIFCpJkQKaDkfXfFWsFdTxxAG5XYXa3HdxsAbLOKQdztQe42lGiPNacEFKeDDd0nUI+Xbx778ALNTxk8+xEzSAYKMrJOD3Ryc8PyONbnVjE6v9vjDJ5RKVVM5eTMaVZfLs1jxOhOvqcN7+eQZjozjY4Ot2Wt3xafwydqUO4figceZWTmb90LkqawarfICtybhdSTmTYlVlEkuMOzbaaZnYHqt554+KgbBfvVTKtoCLqYVyG4XYtF/kQmQzcOMLhA91tjWk6o+bwtFRBYQRK5WCc3dGTOeYnfGq4y/MY6d1SNAfFMotxtl6jw8OnGvLY4n6WBEocntRaGfwHzDzSXOISUCYOlAIDDg+1ZQXHAzjzhjbpKDH7aFFAMLOvbe+/wqhGxrwrO3bjVXmgUsLCmb1fEUp0MKOxBadOgkgnlTsMKxXUOsKia+pw6xsk30j8UPrk6NCzfqBpu3CgtEfb0fNoIIx3Qve+POGQHAWvCrhwgzioxQI4LyLFy/F0ldxhS+TE/Fejopps+3YOevG+C1jpi8qjjxodDMm7nxokiTvqu7c0ucLFOPTFfbxLBOFyxnKq6O8pU65 lYePNleg qvnpKb1V64ZgDjASjQLgM9NmmuG4tIdmxPoRlbQ70tdDFSTOWN23YIUKJ+VZ/MDUPkSrUKaZEMgWedLI3oU2cJM37y1Uiwi7r9PLKGmJOQaLIFibmNzGRyQWoYw5ZIFmltoreNpKKJz1g/97utyGVVWY8I/N7HLCmHx7lDIQx3+WaTpq5+z2mv9pDq3FTV4ckcOcgzNW3qf+6LZyf8ikB237c6CC/+QXQ2R7NB80Ljb1fHvVzPc2Zz5RPnKJOuyA0qp8yBPyJmXHDgd+eZmBvuLMIPui9LBaoMkIceFE/OfgxUUPGdMjJ6E+2DQ7PDsDk4GQbmC1xKUmA7XcrFSCRvCwUtGSJdEvJJtHmYfpAHiKzcZqLpdEOmmmnmlZaOpGKmx8l3iT1Nbi0Kl+zZRSUK7nvshNnHeTgN6svwTvmS75Qyp6W6WUrV5hNle9KT/Z9mPDBGR1hvJu4UnhiZxYK9gAZZQTTs0uyKqXB5jHJ+YFsg0JbnXa0TltOKbkUK29f31/0tRoyfNFZ/XtQddZEC/JYoF8m69+ozuowpIj5Sv8YENKoKGBaclOKbFLs+ZlOSkp3CAF+15m/X129QOlbLnuVTFX8enuOkhN9l8K2Etr++dQV2oSCwFnYj2riumNWivSi+hyUt8syMPKEas1MZUowUM1QNM71Ikgv470/v8dzl3UkfVYH9dzZFdM5r7Ti9HQ1AM2fb5HDXV53EZnPOXp5s6PL9njOSu5SD22ohi4shAt8y03wWaTdIu+gKnGlB9TGZlHgdlxIY5fz0X0CIItzrvoZ3xTL0dyS5x7qihzJ0jwpUiCaWea6JgfQmkmnsGKe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13914392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90FD8E7718A for ; Thu, 19 Dec 2024 02:35:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 256376B0089; Wed, 18 Dec 2024 21:35:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DEB56B008A; Wed, 18 Dec 2024 21:35:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0317F6B008C; Wed, 18 Dec 2024 21:35:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D5DFF6B0089 for ; Wed, 18 Dec 2024 21:35:14 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 54DE9B06D7 for ; Thu, 19 Dec 2024 02:35:14 +0000 (UTC) X-FDA: 82910140656.21.9230682 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf22.hostedemail.com (Postfix) with ESMTP id 6C286C0003 for ; Thu, 19 Dec 2024 02:34:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XlP+UaKA; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575697; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GFcOX4O91tQFD6muydW9g9dtgYf4vZjGzF6jEGHBeGo=; b=kspwSA5p5CZzNs6TSfzdL/sCeHfVd6P2OT0cFZfjuHnQzv5Laazd/hD5KrKvG9q0sOfpM9 DhVA4thdeaGDDSaVmngiKuVpT3vIcM6v/EMssU/1aLn06+1AJ3pYX64yIgVmKa+pf8yTYi EaEoQ8SRXxM5YOiLvajM294hyNA5lXM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XlP+UaKA; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575697; a=rsa-sha256; cv=none; b=rj3EAajP9krsYscHQEGCC06ZEdXpPkeRcnEhWZulZuDWI6lnyaBuZ66rhFBbibLf13zebV +g7lPT7zQfQRgfT26+MdF2sobYspMFpZKOgtmh9WZhRbMsmJ2toBlipS8VK97ndEAI3kFY WM7+t/muAcSbQ6hp6pqUxbrMB8S312M= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-728e1799d95so387802b3a.2 for ; Wed, 18 Dec 2024 18:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575711; x=1735180511; darn=kvack.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=GFcOX4O91tQFD6muydW9g9dtgYf4vZjGzF6jEGHBeGo=; b=XlP+UaKAmvuCUDIZKTrrZrrhu0WsNUFDcXITBXnyZlXJW+M24TiXsu9y3aQhXa5k7e pkSBzIyHrKmkKdA3RGBpIihKG7f+pDPvR5QVB9+tLme7WJa7KrlqkkcC7W5W+vlSr3Vh 9MA09iMEiLqWV8T7Hf2gRDG51oyvX8B8hpMlg8YkfLLAi8BQbxhPuQUeUFoRwA2k0kN0 cNyZBeaeAQdjYB7w0MKjFSuRaGALmtGP0+eAiXpzXh9vFlqDNMjVpMDq6NmGZx5ezFbX kbGNMNPUXGtDf7OE9To+x3U+9Tt5Ka36d0bhoIMY6rtm3QAJm/fCO6MeDv9sAMWS/ug7 tMZA== 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=Eh/XeoMnOjdT2APoVNCcj8zAYQad2+X1mzxDbdZh/lnI+g0R6c+UakzcxAIFuHrljz gs655jzwPFEUIZC64DUinwCpthumpO0En7OfdJp/7m4lw2iEZlZ7KfQUYdQprSqwEOmL LNrQJ7NZWLDO+uIJudHLqLJvtbL8Rd1XkiR21qO1FoglFJLFmnoUzupqGZzuzxOjsqsj moN7x/ihPxaZmPuZjJBw4WpNFjLpg8cjLrkiEUOC7mTIoNjwKo6w2A4cW7KGFL0xuFP5 b5Y6Dpf2O1gwwz4qKD9J3FWoIYBztR/AoWxt123hg8nNsNk4Si+gKXoREDkTJmrb6WiQ BjTw== X-Forwarded-Encrypted: i=1; AJvYcCUZxvozXUmkviygTeFw1af6brUw7drTicxt59EEbZSaOM+MVgzGUW38DUqvFx89StRFjV3zi/qlTw==@kvack.org X-Gm-Message-State: AOJu0YyMNT1pedar0Akf/b7eKYb+PqdADL63QVAX18gd24d3MQQMtkx7 EZduGoqxjDub1/f/2twJ4PIEHX9iNG2Qi5QuTrxkg6iIvqYp6gSh X-Gm-Gg: ASbGncvy3UuUrR6P1NAO9mr4wtHtFC72+Pjfkm9epEhG/JN4J81GzC8xHzwHW9FrIY0 bFW7v7GXHR1KSt+1Xe8MMw2sI3x2LmqcWIj5ojXC75QI5ZJ+AhIXyVaOlL/BOGnz0PWfARlnvlW JGhkh4iedRfdM6by3LAr0o29ALNKL7x60LzRbmqZ+R1YvGAJiBtKZuCg5nE+uUWpL/A+xn6SY1N q+m0k//S+1FgyUyKhkwg4Ix1wk9pRNidZYyDWbO7TtPvW/eLkKgolAr+D9TnN3l8wmXgxmaMX9u 6WHKP0U= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6C286C0003 X-Stat-Signature: ru5d3wxmaauh6petdtu7awggorbe5fey X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734575678-331151 X-HE-Meta: U2FsdGVkX19GhxSt8IgWygWpxty5h+dPSbnl9NQH5TAUff8ujdNRIEIpn5/tqxA0HLA9BiBXZX4jb8t43VpVnuDLrqPYhkOgaxAvK6A+yhXU8HEeJmfFraSm6yzmrqlPgRINnWYzgS32UjklUGtycUDFCtTB4TIaRwRu0MvHum+j61wezOxMYV7Owu30It3ZOiPaTT+N4MGEqLXp0JhZkrDu9y972mmp9L3x0PZYQ4QZ1stRPaa/JQ8CYVfKaRouheNtjP5fuhr6daq2ZVciggYawO1YN/DRWbBrdC2MjL4wAeOg5Ljfuz0M28rFsccsNJCoy/ew1SQD/Mqax+xoE0bvCWYqX0ZfqWCokPywMnowbYZDxQkMORlB11e+MZ+gl6C/BgDLy4qw3unWy0vyyEkeEbPJQ6/KBTTJw/uOyipPFJiA3DTt0Dbc6HnLV+QWZrovof22+vDAU6ZhMXlMid+g4rwwdOpS3y2Rg75Q1iY+YkBzMk2aPbrb1K6ISHGN8S1IcOa2wmUISw2jf41cMUTtenFOynlEhaq8RHabmZYbG1ytLsxj4lWrltQpqn8iM6siJ/IOtAsj1utz6ficNXqcjMxAikR8eeSJ+zI38rfF40ls5+F07FKtshNL25bBacr6deuJ4NwSVhAbaZyr0mOxIxcWGPwwCIrkeVLPh0+djGBL4L5M5L5WsctvLxpZEXLbEqalpDVJFukZ7dRD3i/V61Cm3gbgVhKVzMstgtobkv8z6NCbR3LfBPFiOtf5t7V3E5ej9sBvNF1kWnwh2sdRDd3OCeioyxmO08LDxTyiEy4KGI1iutaeu7isM0GS10O61XXTEbgVo5hwa+cuJwzKj1VtlQRBeOfCQsQ18NZ4LDYPztEHzbHeUR3qdy3J7fKK4PNxGy0YVsy/J9BlnWX3dV2jyGqs7FxDISdkTHlk0hywPWAxGW8gfoS9xz875tmpUiaAuGPJht3BrcP i8bL1t49 Zi8zhUOn3ebA4d0/U591ZjGR6ke88Q8x066OwyqnvqTQaYnQu97zc4zTyvYUaS8/eRFuDhSZcD+lt07j7Do3dq60Q8bL7P5YhcbzBO9+u+3kaAGy3mS7TZmvQv4hj/FoeeUyxNNcM5EL3QpuVgJHo4Eo8Js9zRfzVV8cPvWM8/5ODT3G2W/pqhov+vWTeQP1CN6G4+D1bPcEGzgh8Q6mR/NWYCQlc5bdIuyJC/uhmQ8PQ8vlPnGEp+A1csZpPNERY+6ZN8YphA2u0x1OZXFR/refGM4CRHi249YLvvwyhLYYsG2wpOthxY0EIKdYb1U5DQ8NMoKH9mXjy40GgkiEArda3OddBnnIbtJI1SnwsIzLzBdvUHeVzaG6fl2GQQtP0+p+2ZYpQrhTGxWkUTxah58C127/hGSAjLG4pZIixmCK5/H8iRm7qg07twre/XYH5PmybRQ664givsTZ/6NY6DyyXpOfhxjPpCyQryXMwfo29gNlFbw0BL3rOQgKAWMXyyREA5d8/0ghNpXtRg/JwksFauSRIbpN8tZh6FveXuFXmPTk9eOmoRYDopk8r79yrabkAxFjc99oUTq5YvYmUbmo4pOg1aMvldcTAspgjweLgtIwWBArEfczMgcg11eD8FpqSF8sP1Jiw6+mmaTSmyNtbKg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13914393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B64ACE7718C for ; Thu, 19 Dec 2024 02:35:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 404556B008C; Wed, 18 Dec 2024 21:35:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 38CE86B0092; Wed, 18 Dec 2024 21:35:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DF466B0093; Wed, 18 Dec 2024 21:35:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F0AA76B008C for ; Wed, 18 Dec 2024 21:35:18 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ACCEB1A1348 for ; Thu, 19 Dec 2024 02:35:18 +0000 (UTC) X-FDA: 82910140362.03.0C0F76D Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf22.hostedemail.com (Postfix) with ESMTP id C6756C0009 for ; Thu, 19 Dec 2024 02:34:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VP+ECQf6; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575680; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Zz5f2fkK5TyUEN5/ypHLYKDvnfLQ33CHwDb71kc+wK0=; b=zwd4MUPkcO1kqGcXaIDuNNpTdqRXZFkkP/uoU84uzVUC/nbOVKcLJ9d7FEKL+qSV0bds9T rf+2CN5BJDwcnlemnvOwkNZdZhYtMpu+yrj37hM6WYP9B1v48UCl11sPwlOPdZm66uywiX FTeu+jT+qdi2rphWr9UqoJCXy2zRHIo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575680; a=rsa-sha256; cv=none; b=oxdcUsG2l+YGpYIdt3n+QhNs5m0czTZePRNsxuM35Lua2aQUdx5+wSyvoQPhtOAqFU/wNb LT/ArFY9ycCK4z8KXzNMJFWnSvciKaYw2zufRpcTVoPUh9YsXOCoyRU3f9YDdFq3NBGc/H WD/AYWyb432AYVPKVmQ8r7U0RY7sKGc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VP+ECQf6; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725d9f57d90so236197b3a.1 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=kvack.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=Zz5f2fkK5TyUEN5/ypHLYKDvnfLQ33CHwDb71kc+wK0=; b=VP+ECQf6TRfthkCTU3tJJrcDFByE59BNr4WqH2i7goC9BC7PjwLV0kYJx9GhblPMlY WysqZUx3Gc9lfbCtYVtBW28t5JtOli21r6m6DiuWfhHg9E5lYSC4Gx3c/PQi9tTzE0yw tPR85QoY9+yJfH+mhjpWTKCzECrG5JAZY0rjhFCoURoR28/Q6PGsQSXJOJWQCNZ6Ujef MhjS0FhT/1Y2AMvI8f8Ctt+OT3Hg52jy4jTjHt9+IjL5yCZTe7uAhhzv888W/svScmJ/ Ds8b6CyaWAnFger6E+1HRZKeDWh6Qf7/JJGLOpvJGUW7F90VTCXbrStUO5vtUVYWzwBL hsCg== 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=fskdbSds2C0P4zat5JumLINtSHiDBIro8hT4d/ukHnS9z8BkoPW4dqZoigOjHrkc/N vyklI4vQUi1aJ3jFf5DJwzhF1hXYMjRIGEI4r60qdsPGH0y+d8XzQfDB4zqqMmA08u5K Kg4PzIIQh5EnQMK6OiGk1dqMADeDIFTFjNBTNi9nskH2FZWo/Qezzf0+FUOxK++6s72l h9htac68kTWkPqBObHnQKGRdW5RYue0peIJQrTdFp6v8UwpX9b5mAt/W3VchAY57g8PQ CM3lBbyPon+Vs6D0oF425wdoYdQ9V+eWdjVl2hqtZm8CHi2jF5y3qmt+igSCj6Y8hrXe mbwA== X-Forwarded-Encrypted: i=1; AJvYcCXiuLmXYWKtF7GPsrEBnaJJQ5hX709hMi6j2nVmz6RgExsDVImpAqWADCT301Vk6lXCuCPMndRtcQ==@kvack.org X-Gm-Message-State: AOJu0Yz3Jy6O9WGW1YoiSgCGcIFnaAd3YHmvGrUZ7v3aImbsbq8Zjgpg wUqxr4vOuyQ0EVMUJdbozQ4wRC8HIQwsl2RxUv+eZkWI1MoygVKf X-Gm-Gg: ASbGncurz0v006V9P3VGqmPt08KAEcO3HDxIUOxsteaf8MIRKZ3mTkI4sTXuN4kx9ZW DyM+pOxk8ZvJra0zuH7h7Gp8VRvqZwdAGi/X4MNOJm/A7cW/Dgmxs8VUv1f9kNvlR0XuKEyz8t6 026rU18FZPaJnh2Ph6IUVC3QtpfwApj07cOWSRq29iXsvFFnl0IXEahVGnDr+vbkEGe80VFsaiv dItAEq+pa7Jy85+xM2ys+pBxBZlvgcliXGyH669QP723WRFmq62ZMisTYM5paPZYVQEtKbjPySK tI9lcjU= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: C6756C0009 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: 3e7inthkx3noiepju9gaw9dk4eh7qw57 X-HE-Tag: 1734575682-713984 X-HE-Meta: U2FsdGVkX18AdVt5qoqXuWIFKkbmWft49lBn6RHd50hGe+WWNUk2wnt35AHBf1OUXg+04ZHI1p+x215lgngh0CWilFz1xZGYFB3HqOhkRHApg2F2InmQm1p6h+qlAXDzXeZfbGaA0LRn0YFtxEK/AwynTCQS9YL/1BBestFitCjbldYMKpYpmXHEOoQa+1GStqauSAJSPcPArfVktjGX9pY1FhxJGvK4EQfF+AJm2RMTEIfuXQs74SgpD8Wt2aNax1vWpgeR04DZ4yjgHgilDuzxJHR0Rs7raXiRWWGsLvU915eaH1NiLC7GWJ1o3B3qcTjMq6xhevLoHODekzbjlrUVv6ZYaWPQJ2vQOs0bcoqltOXoQYLQ/OOHvsp/pR9DF7nGC/3bqnX04wsytsTO/oUBzQItgMHcFZLZM6GG46Nan41C7TEf1uJ64+Lu9bOotY65egPeC5AYOmNwzow1bYpa1wA/lKNdQB1Kega5uUetYuHUyQLBwji7jGJ7JfTs34rGDBkyn6Zx9Km61hNh17M34N+gADUluprkrl1KZbQLWdaBVAJrmdEPUC51W++OtxBdLpYUtpP3+J36zi37S1gHrIlXWM+cx2mG8usoIJ3oeGMdAYSLhCWbDaB1zYmntmAVpVzb0rpl+jLBmvuBxGP4+wwUiDqC4l/8Tk+UGAHRZdldTBQU57UxQ5ibVbmZoVZRFlLrXlw+D9GE1hITPjs6owe8UFRcrDr2RLKCn31wqcwOkTqQF7bRRwAqjiwGKPgsB2tBI3oyXN6MROrvllZedNGHaLX83mdXbOoykxaAtzH9uUNxwtNYvItXdX0nlHNB34+jIgGH+qRlPf/8LNerjixXGWSEFWWt7DQVQ2KC26es1O73pVWjhVaCDMRitalpNsvxrPcJCd0IcCS4FtXxOZbS83Nr+KrBnlWxk3q5Pt7yTNFPsdxajZN3LZH1sxV5zycP8oKXGo+iO+n D7EYdU5H 6jxNoyCoVSuWHGa12BdNZzIprHAxbdGXcQTccoB7iKz6i1gft3mx7DWa19AD0TLjLnSkYvDoKzKjg7eu08+m+nYaLb03U0oIdayslJTn1AoVdfFabdv5Tmx/XTagFjMJ/HEEU5jomGWXsrKYdZ4fyugzkmMF4s2yFKKAidoXsJw5x18X2VYVZGjkQrnpyplFm6ddxtr38kRt6wb3h8ANSwz7zimKuJHlJFb95ZAv9flNFnj4JM7wwv3Psgg+0yQUWqRuJnrXF2FJ3hymg7Bif/fzutgLbJGVcjWz5dwTe0OmHZLPtotxe2mB9vM4TyAdVNavGaqvsu9QErVWsQBWnuHcUqkjR1mAqMKeE1yWmnfupiUaETYc8qkbjWixBr87HQWlkVE8IJ5Oe49oPo0dz7t1YTW1nbzSDcR/7M38UCXJyKYGnrO8QjezB3VbRAUn6//JloX/hkdkqmUWls9Yn5XaOgBZON98+AHJJ+Unf2UrYYDeyehCgl3Cv3iMobjXQIAQQ4t1OrAqYoGjjhXvqI3ubb7fwZnnliAL4gpLZhiz1QQ4k81w3hy1y+rnmrPIjypmcsc+bsApfwGg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.202658, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13914394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1243CE7718A for ; Thu, 19 Dec 2024 02:35:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 478726B0093; Wed, 18 Dec 2024 21:35:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4015F6B0095; Wed, 18 Dec 2024 21:35:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27B6D6B0096; Wed, 18 Dec 2024 21:35:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 08F366B0093 for ; Wed, 18 Dec 2024 21:35:24 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A63B544022 for ; Thu, 19 Dec 2024 02:35:23 +0000 (UTC) X-FDA: 82910141202.12.CC5FC1D Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf03.hostedemail.com (Postfix) with ESMTP id 05DB420007 for ; Thu, 19 Dec 2024 02:35:06 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=m1j89vRQ; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575707; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=35FnTfH4WG+K4PY792luJMCXMpwCP4Hox12oxUuAxYU=; b=AljRTUGpcQJf1KMXrA5M99GaZPyu9me0sLOSvTqqmwjiT8s+s6sTT85dbxD3uNRxgVoaCj 7a9+610Sovv7IpEzOeUN52vJ0faXYEJzFpmIfrP5D4kQpuzB5u01Mc+PgBcL0zxLhQrSnr whLlDzr/VeO8L3KrVQI/uk85GFQ1DJU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=m1j89vRQ; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575707; a=rsa-sha256; cv=none; b=V6i8cTbnMn/voQTjs+YRMEWU0FVkG1Y8gKRPPX69g0c4FashFT+cqQ47k1HWf34IrABlX1 1eTCf6gYv20/TNY7FFkQLZmom5/yy05Pmvm6kDUWq76K8X+cf8Z4VgzX27poGMMaMrFWV1 gRuqpeVzax53BGOPfkeS1pdzO7HAp2Q= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-728f28744c5so307393b3a.1 for ; Wed, 18 Dec 2024 18:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734575720; x=1735180520; darn=kvack.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=35FnTfH4WG+K4PY792luJMCXMpwCP4Hox12oxUuAxYU=; b=m1j89vRQdOXLi1Tnw3xGso0ZmAHK2cvZgixfNFuSpAx4+PmhPVuqnnDDXC+H8c4l3L jhHFGMZ4SShCEBfMfJfJeaVfGbKlsNYmhPnAFw9Pw9FvAwloWoSGfrl4xCeNLffnJtGL C+ihn36VWKO4DM8zifKpC7USWUx8OmdJZwAuVsDzV7xISMdoujv9hWspLmq6wo2qtLl4 iYkBpQo37/jaZXzFon8H22/Kly6pDXN+pTB9QzkgMafAwXHHtN1z5Ttp+Rox7Yf2BJQG UyuDJWZ9Nn+fHTHLDCWsM9MU/STtTA62KJqJ/7t0JtknOxVUq1CTk90t6aMyaemhiilS pJUQ== 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=kD2X82FmZryX2Yyx9RYATJz27TY5+Aded5yG6UoTfx5/T1ZSo2U2d6gl2eUhx/3Dko /5ByQ+rIrnccVxA5bfHXejd9NJtVpZp5BcGNQasD7K7FDIPBEF5K1oyKdx1fD04auIWX m2vXowJjxgQwx6rVYRgZTCgUecw3DmJvXo8I0niqjsLxa3Oo4+6tdvu1F9RPPSuXHRjP Fn2VolPz3M1p3k+RkyTb1VJvGj4K8xo+uW6fT/DHMPpdN/2bBTVqJXC+JPqgr1ZUvetr pojbAFLNYnWipBSkPogfx8AQeh9DFYf3QGkRdwFumvi1GWqjDEGJL3GDZSEun5TNX+P3 wSLw== X-Forwarded-Encrypted: i=1; AJvYcCXMyUcQSlqecWZ6ppEq1RTJjvVdTpRiwmqKFTavqEq0cDiPSMwSF6X/R54v06+4CzWT3eA00jlUxw==@kvack.org X-Gm-Message-State: AOJu0YynBtV3H7n+XSdiDtj12Kh3w2zUI49cYB30LTBz7vOXc5FC0CiA IMQuk7lTzy6km8y/pvUZAr5jTknanXDWcnkL6nBqieVe5ZjIFuhs X-Gm-Gg: ASbGncuOvNggS2ysJ5yFfuM8yFCFefcRIyyLstlJ1lE3l/aC3a2L6mpfEwhNuT4pjkv 7nu2GBytdnk08S3FMMWMw7sxbhwJsuAi1cGfH7c/kQ15IAY1e3Z5/ta2UImEbG2XguSCyVBThWf 2QeZZHM0zSpiZBtuovM/0lm0qIw+M+yOd8/VQDt0Q5kKxypmxbOWb2TBeoa6kjQgsCoXiu7qHIV MtAYksRuGak37dHMNYcHHUpAhwIwt8kvKqh6p0RMPMGXqtpXZF4tUHZJiWN123bQEElNWsqE1gc L+rUseo= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 05DB420007 X-Stat-Signature: 5dcc8yddbk4u6swceaz1brji1z4i9ojd X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734575706-465413 X-HE-Meta: U2FsdGVkX1/kX9Umls+7rQW+6l48RbMpOsp9krNE0fPO9fJyqNwOHBWkPFR4ZwJEMG+PeEZhVA71zwzPjT8+PyaqgWwtCG/41GvaXCIBcRKq2cHjAIXWv7QJun57/SHYtvhKd3g12oILKUq9z1Fl5TToadAqN/STN1ez+dPeZJFlKPk+ruluI2MCl+Gg0Lcqh2qGoO/FqndklvHPdWS5Xct1iNCwacVEvsPpt6wlIWreIdAwTQNDZei7DzAwJP7tTgnfLLRiZSRCgNTdyavbISUZBwT2NYz4mj+0q3LTMJABF8d/mIXVQyesOMuSzBcadUz81P368e+U+3kYLK/T6tbj+YhOtD/ll5pzVKG9Ts/XcYh1Mgr5/5jSndXwrtZObcxVQWPiGFlNR77odCfWXeDe/Ry6upZHvSaXYCRJB1qXhKZbCcouLYJFKUcxMVawI9xxVrneLDY7jNc5tSwD8qH1ar7h/dtvnM/fmAk2/ygEhvr81XroVqWS+lqokL2emIJlxSqELYCsNTKf2WbYec+5NWveTXfg2pohB/z3t8ncZxXlmHP9N90MekMXw/a2cJJyRUf8Fw2wSRGdnkKf8kM35P0qrMqXeuI+mY3q1eIdmghjI6XWxRj7QVrXojmKlTQ4GuwnukFgb7djEECiryVJmCvk4qnLApxz5TX1W+6SoLpk+f9ezp/Bs2MjykU4SDKklFXAnjVvdktuIhEsdTCq2Sdt5ZEMdN/LN4L/iV0ZBUFn1ErIilwsoPz60EQ/eA2I+2ugghUASUCEcB8BNY+bIdwu+7m1FKeB+ZqeP+z3cvjPIHOqCr9ZhPxk9J1L2xwuFmY3fhEJmcYgXf7gUKm9xejrK/MgqIi0gcoc2BmlYsief5VnAzOINFWKRHUbCYJFoqCoqDhI5DLoJljVOGD8c00vHXMHbf96NBA21NOali7zNFtBQzPD5LhTcbnzs0XOy0/w64bqno1Z0Jo QIyvq2Hi GwOouWP14DX//mgZdnmEV0vGD6NlVj51NnwIifXjDBWYTeZNIoRdORLDtFV0FnS/1J030t67A7Iu7zd6wciXfs025pM+ISKv391JM+m+cvFlQ8P+ISClOe7wavmSG9uEWlaT8tXzb+92WDztlsUGw1XNCkrj+Bsk3NyWkBjk4g1dvb3zOQByLobAmu/X0RnJpQpE094zfY5HuqnfaRfooEiBslc1LrniYijVY/GDzPbIB28lSEnm7HFrNMysfWWIgdotCY2qSf9A8emt11iBzuATF/W7LoJpgbp2tCMYQXSOnOpg9Vsllw4NhatV409JVibA/7jtwBpg3/1F4quvc9KjVRSLYUeWLRDMX1tMP5bEB0b65joZgFTcN8v9ozks+FDh2j/0twJo6gPjsjQvhoFjelbvCDEddhjIPjwpvfmnIFdxubEsPn4FwIO3tWRJ+nGbNIomP8t17puM1ficih2A1BYFxZ0FSnjvW1mIAxIhq8KydmX/+BbaflmDljBwaGErWIIXqoD/IRXO2rSUJsPgA5bH0XVesQcoQ5hvnTWHsFmHjapqtn1bLilDqp8gWfTsyanTDYCEJAMziw2MBvqGlB5s67O/q9iI2xlQkRdG6xO4UV/z1STRDipnRqkYcFXx7G+AcBYF92HIGn7NCp6JQx2DSd/mYRKAogQgKrDABL3n8qgfJXH0+7NJluqI+7od7hcBKx+7Ve5h1+gJMLQ6xnor9wXDUzHOY X-Bogosity: Ham, tests=bogofilter, spamicity=0.003189, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13914395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C927AE7718A for ; Thu, 19 Dec 2024 02:35:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 625D16B0096; Wed, 18 Dec 2024 21:35:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AF776B0098; Wed, 18 Dec 2024 21:35:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 429E56B0099; Wed, 18 Dec 2024 21:35:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2043A6B0096 for ; Wed, 18 Dec 2024 21:35:30 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0FF681354 for ; Thu, 19 Dec 2024 02:35:29 +0000 (UTC) X-FDA: 82910140824.03.6B717FF Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf02.hostedemail.com (Postfix) with ESMTP id CC3B48000E for ; Thu, 19 Dec 2024 02:34:25 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EniI6gij; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734575713; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=Fs4BW2VhYOSf2SBnnDTcYpOQb9WKaBKYZ8jyXjIm0erCIr1WrgIuy0qArjzX/HpVF6Z7Mt tutbHyYOEA9+gfOaWqV2JcSuWRixdRoSEmXfM85eYQZonFXoQXZrOKLBX3uu+y8SEeoR5G /JCmjoweyhS9sXEHk7WSQOP4dHDbBaI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EniI6gij; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734575713; a=rsa-sha256; cv=none; b=WvrTsia5rrW6evH4jYxaqcPoe2cM+BOAfGrwGT6v6YhUfXRcAaJ6T3d7ddLTSwY7u6vT5w UsTYbk9DaUFAsVtG10z3uj/Lt8xS76sN7xO4lQBzeod3ZFvfa8wv2UddLHdJ6QJrHaUlrq ccyrR4HCqZxsgwPIdKoOfO+kn0Ma6EM= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-725ce7b82cbso400319b3a.0 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=kvack.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=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=EniI6gijVAEHs00IJ2XYmsm5CrCpFfydvJXWRnCx0s89VbyBDXHavEQcPUAKwkT293 J/KkUr33J1zFQoxsj5nRrIOCgy4laNWe4VeKH3IwxOK3Ht82GD0cTddNUxSHX7tSWgA1 mH6ymnedF2BlolGY9U9HnTDQCiNyzUtvgbmtXv0hkVx2e42irhwaxYJudAlAjp9O7w6L Uuk2f24X/wvAmfp9tqqj8C4aXoCIZ+udMAr+eIaODzSb2Fv8OWIZIjfJxGQPey1hi1Y8 ih21Jr/oGgZtIXbkiHsb7qrzCs7kDWnJBc5WPifNThNSvwFokme6CSSm95LQDo4iotXC mBKg== 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=RXX+VnPxLvQlUYpTkOUwhsACOekJ+dHk4PZvCRWu3Wvj2ZFKtHFlF/e7fsaCLuMcAF DIbcT16BUfwxCZB4g5+nXdrhFBnI94fCIuv0o4xAdPJt+h606z9l93Xf4KO9Wtnq+hl1 Q8CrQeit/JXZeQ+paqtXPrjoxBLFXJ0jlmM6nQe51ZEH14fQRac7G1ApRmjNIFjVKiPs evdhDVuVCkQ86XfGxZEmRR89zBes6DCf/nXVswanXKg+JuX3eX8ZDG2PIuFVbfui7At0 xHXrPefaPyDOr38uN+nmyp8tngdkEKC0UMQ+4u3Ssn+8APpq6R+IR1fix52GfqzGFmXj OOwg== X-Forwarded-Encrypted: i=1; AJvYcCWXOSF+njtQ1XGdymm+SyRYrIVpE9iFaLUaauydCvqVoda6CcNlaCHCYVjw5PU3b1dJo4noU49zKQ==@kvack.org X-Gm-Message-State: AOJu0Yx98eM3HnQqo0h8FQ3zPlFtauuGDe5oSoerCTIb6UsUL5YSiHV7 Ws7//pDdhD0q4t1JtbZTGfUGaI6suKqcSqAX3j7sdZUVb1IYD9Tg X-Gm-Gg: ASbGnctdK8VmHPSGjGlI4GfihTDKoII4WkIy2CgNned4bEfJFql7g/W/cSMc1FilVeg g1sejmN2KIHfYMmDiMt9kmHrJhpdI/egRFz5ONNW7CJ/wdJIZkaTgaslR4wAtGDswsruNbEUQC0 U4IpMdAMrGRYkEN4QbYPl12O8W2CXVwqZlnZbkXRXAaKPy5wKbWC5b/Mtg/iKDb2tRcfXobMDgP M7Y09vYjmXQ46+zxZGEBT6iazioO6kE/V3zmZY+o6N4cfmPRJU+55jpTGQawywfgpOSaAVuyqwn jLp4mMM= 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: CC3B48000E X-Stat-Signature: ie1cchwhkb5q7onn8utey93ft4ytzhiw X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1734575665-348218 X-HE-Meta: U2FsdGVkX1/xgC5jIMY+TTZdyE/VRZga3Xy2nhjVM8ZRmIjqT56sQQpKKrDYkcCXcgEgksV3L7v25txTSXby1yp7Dw87fGu3jW1UEgpDPV/Q+qsf5aRmFWWmVNwUD26sqoQuGnHOf6QFBdDiL+BXp4q7qRJRyJzr8ndS9sGx1OB0yeV6YiVx27Yoz3qBMoNypBbU/IvguxkNS+ocwZZMEmM8oiTPX0/o4ZqWIAV8TUtBbHzk+5DHLAgfAItxEDgzHLZp55zlTMOUeeGZSQyMuLPAbEAxblgTw9wBLSkYbdFs83/yP7UTjSh1CdoPf7YQ0Fgy00VSpOlJGkO6UdpVKldJLpO2BsSoVhuMnTE/Ylw7wYcI/vZU8v0weaKO1/tWGf+ZeyzVsWhHfisxBDwQEqUBewNBOsAewH16kJ0sRBcds6TpHfCB9YuNpSSB2kwvGr/b4Y+5LyyUcmLzHMbLIgTxddCVpC+KoZDuJZzzMWHauu15hxxNtGkaJD80xxIEO2wx1nmJMzCPyNiMX97b+qX27B81if2ieFrK8DKpIG3v7HSy1vmGKt5nP9PCkqzJ8tpF4SfANfsmCqEthfmxcK4QyOFcDtz+4S9P0sUguhLfRhhxUgpqc35SzLB3LqwuPittDlQf2jH7NccQcDHc6xKQZPTgbiGEuViLd4kvxbisUW+s7+e8iERpFJJFqcHNgqpseqAkK4KYYHk3utFfiuiy0y8YCSwrzPdwTqVMfa7H5dzkR3wQPHFTftXojdYpmK0ZtDMMTdGADwsht8wgjN4qE5X8GJoW0dTk070hkkPELSRk1a+AXXtzGsCKeFXPgdbPAbKIEFaYeatNHMbDWNlnRhFgV8tChrKcS1AXk7nuTuh6Kfx+GhsDVcdLM4WtjNJlxsfke0TVoifF0/OiTyW93Za4xOIhnyQ6J3+i2LG+cPdWOJ3dAKfn2BJatntGaf9a2QKRNs81FZZ900e xIAdDIB8 n9NZ3RhuyDUwNHOL0vyHXRYSlRpWZIg6+jIjG6A7TDhedju9+FIIc+JXZk2Tzgb0yLJELFvZHYTiSZK4fjvK6oI+zG57CU24nOiL3FVgvtnGFix0Gs5QXhsYVqO3tbR7tjDCqEcqJAk3V8/yTLSzueutQFMThca/fLWIU3GQhg6QzTRC7KuCDp5NGFXdicFiTMdEUPGTpgjbhf31jWjTCyybTvZPzro4wB/ytnxoGuzr1SHfE7NFhy/8WSNWaX77Ln/DAwnC3w/JyC55X0MTplY0oaALRQAD0Kl8vYm3/A6BIgPyFTYeMsbpIMJE1HmCZxUyLqc1ZQT32Y6/XqCo/WQ7agd3yH5ICCRAauOzwKxpZ2fELUKbrzXyxTwGrrAhF08dO5gm1XuZXMue0to/mZ/Iq22eVFdlplo8BHljD7L1Os1ocbewZabvkUZS3C9aTV3UIEDdTywE5+Zjl4A4Rv1sHqmRMGpmhJPMeqf932oGuwvSlKi2WjRkKbR/8f2ugTWHPKcYhOCHMA/7epTVC0n+xqbyKEmQHZVj8OzqAHoJ2htp7Hgzb1Oxwz7XXKwyhoufvqDBvKsh3rg96Kz9P08OhV+ppSJucTwwJLvi2iSksGFAxRxcYyWdQJWh2vNJmxf1hUKsC0P4c1r5Z9CLAYxBGQArSa/+LpXKUrxLuTJbTbeuTY/E2BwEOUnflnasNujHZxWcw5b0Sg8wvJk8B2+ZwEA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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;