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: 13915196 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66755E77184 for ; Thu, 19 Dec 2024 16:07:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0533210ED2E; Thu, 19 Dec 2024 16:07:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HZe8BTSZ"; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by gabe.freedesktop.org (Postfix) with ESMTPS id B661C10E271; Thu, 19 Dec 2024 02:35:06 +0000 (UTC) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-216395e151bso2164065ad.0; 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.freedesktop.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=HZe8BTSZyJ+q9OGkdxCCAQx+r1VJ6B4lUDaoZ2M/B4yhqxskkOvNxU6zAC3W3PMT4h KWyW3LYM8S+LqxSmySPt2PCo3ckrAXW+zfg1Ato2Y7CX3Nrrz8iE/1i9a6TKzHCNgkAM NQV4IoqRTDuVNIAUP0YAOG9XWVcgqXsLg8DWhrDupuHE/3a15y04Y25TZSVMNc1juPrp LCeyeAB8U5HXgmuSU0JQsmZFQjy+AGnJHxNLMIOjhQYmn25RICqpgrbivXW6AJngE/Q5 6Rdo1hyUyog0wx3xMeeRevgmDrHUJvHC2B76D4OCvx1KJYTldxkCR0rekTrNkvpjtaqY yxfA== 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=cVJBrCDp5SBkUoscNKAeMHaMRaj7aLuWV3DeiWLav+vjezszTjRvPUpOAx3YFFmaZ1 226StqDHF6xinC899zkP7R6l3wZPe4xKwdLgZqMXEIvGPr/Vo2xWS29OQ8UsCkTtQZFG Kst8ILvRAxsJVGLM0ubHVJqv7AAAsntEBgZya3Xh1+cXTpNL+DzuU+HHIoJpAxzryHGr eJDmxBlheEoFVsi5XRSm/pA5eyjgD+wdU1F+MCw46ZMCtnUwDFcYduB5FtNTtjgrHBrM iv5hPCtCQAPxrW+ZsqxBxBe590KKiGF6rkXfrsyzG3+CRIzbcVL3QzmuQMLPtbQTC1jH 5CmQ== X-Forwarded-Encrypted: i=1; AJvYcCVBgPoSAn2KpbigBv3DY4KGBBMY3cBh4DqF9kQ3YCMWCdUiUT4akv96y23TvOtoYG5LnjLJrllxc6g=@lists.freedesktop.org, AJvYcCVRrvozocophIB3uM2gcCkmJLVB60xXhJSTb4/GLTRBz567oSD0HDjas43MdatWuCOdyHm06/eQOZ35@lists.freedesktop.org, AJvYcCW0CxuwCRc1XwfsfZB6w8qu0otKqHN0ulV5+cAU2kE9CLKeRT6VTN82UCQVpjP08i8BA5yfSf02og==@lists.freedesktop.org, AJvYcCXhldZKnKlmJD0Y7TIq5ZlOTcb29dUyPGdvsdW8QgdyoX5z0P4skdYN10vodDT5pkklQKju21iGsBY=@lists.freedesktop.org X-Gm-Message-State: AOJu0YyXA9GyD3/yxKsp6KZqGIh/sPetBIw79a9YKGKtU8ydT7BI0wdN cIBpXFQulhRv/bO4c6n+onMRyvBWBGFdIPjk44RY1kiwfjf2tWbV X-Gm-Gg: ASbGncu+KmTEYn0K1MfqYLN34iq9z+fDiSQNQ4cSeoxGpcmn7zL6Rg8cbCJD08ewNst ZrZcFEBmdUsoZJMyNz6h3ndYxSP9A6NI645H/qn1Hlmu8HqblqRgcmjeJq27AXzfOJ54MZUK+Tm lD4af+Igevk+V5M9ZKF9Mxt5rB101NRw3Qg7lmV/aXFkJBwXyfws6FA1RlKXvQEfCuIW87kPdhH xJjW5CcqJSaaP9FQKjEASi1YRboP4Ur99zoY3EXc53ozrwWtD2mTTOs9Id6ICo0SzKKa3TRG9JB BHpYovQ= 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-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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: 13915194 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F166FE7718B for ; Thu, 19 Dec 2024 16:07:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D854810ED28; Thu, 19 Dec 2024 16:07:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="louE8tOR"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5AC210E276; Thu, 19 Dec 2024 02:35:11 +0000 (UTC) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-728f1525565so395032b3a.1; 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.freedesktop.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=louE8tOR+kUhbQ+RyuqH7dQ5YQoKfVXulHTuHvRxbuelUOe/BEpKuOIRLcYpCxbC7y +GgycZ1O5tMl+SgeCT/s2V4jgaOCOOBYsw5ThLh5LDayG0f+RkeLVxhjsGKRswiFCNa3 A757U2HVx234Dz4/16JzNf/SJPhc/OcxcuEz53Fkm+Nzhka0fa2XXsYYV+MtmuE2qHBi 5ZwkSMtbXPQT/vpqfVvrSdHtXAXciKAUMR5fNRPT1SNmqqzdtw+243BL7Y3iQ4slw2r3 v+xnt9iZUWlQF8yTB1BdAFqEUze0cYatgQWT5kHq0xq6LNtDhM4SXp0CxgAF6wfEUHoL WQ1A== 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=dDxRMoRCmTgJgGDIkJ9zrD6yNDS0BQrEi7LbFK82/idZJC10uaq88qEQvb+kQ26bnz U3/pVxI3XDT7nXoJIRjgFHCfDaYJ2vn2pN6GIX5siKrRZH1PQJ4thZbU/OR/HPFBoUFf gAPzWfAZjkbedv70NgX6IzCpDGtyz5+FWqqLWmxEUjoNabbLPQHxDuVhaWjiL1HW7EeP qKH3lpKgtAOyoUrvbipDd1/YdIxNcPRxbPYTNBv0MKNFBxDSK5h9mzlzlvOVIbFKEAV3 gEBPS3lQ8HPwkqHHg+7BXUymN6BP+OtWD+E7WrXcBtrjY4oWvoAj6veGBENui78XmgiF Ww+w== X-Forwarded-Encrypted: i=1; AJvYcCWMU2Xvd40qo22wQZ05SrUuMI8SNwJqq51O40d+ZOzL7XrXDZi/jUE4+ZS1US5bZCf6HyseaU4vjA==@lists.freedesktop.org, AJvYcCX9ZMrKxziyaBjBFsJb7DWlN1sFcRQOeilNuzXdr9DeLf026cfn15p1rkROnCIZeU7WFzdBdsJGaj0=@lists.freedesktop.org, AJvYcCXb8y6UiTcinDF0a2l96ma+tBo6BLb07O4BBpKG3j+4qhu/sbZJMjtvF2Todcz/lR9xgKdl0pn/99t9@lists.freedesktop.org, AJvYcCXvOM7tY2o9Jp55SZpmVr4PDD/JOcjw40magbneSAOwhYZoK+vxSXPnYA1o+QrJX6+Y7RpscWGvdo8=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwvtVJuNNdAD2i/io51JG+3tuH6h68uUefnQj3CLaK2Rgo9y4XV tYlVM+CdqoycKQUb/43jj2ZCxiDBwqLzCzSUsCB0uC3DqFp6fY1T X-Gm-Gg: ASbGncv2ye3gZlCf2ZDjevekWizjHO5D9N4emvwKcj5Cj95bClan/xXOadH4qP/Ywo+ 0PvM/Wve8vMI3LSzCTl3+dv5rdSLz0IuQX5eJXT+oJo24BILoVVNQnYqyRq7H6c0LX6emPKsjKc WlD2ePXh28pgbI1TDr9jx+0EMgM+sllnSpfDMfVthxEQSjxekLl5U2xn7YdSNBLSnNXfkFKXAvv V2raxNf2zmm+3q6yrIms9voV0T8R8juwkOuUrwJMGbMKMZMboBRFTxZbOE+nRnnj+zs/XI4b2HK D9lXLm0= 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-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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: 13915197 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 844F9E7718D for ; Thu, 19 Dec 2024 16:07:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 604D510E4B7; Thu, 19 Dec 2024 16:07:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Wiz4x8jd"; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 16C6210E44B; Thu, 19 Dec 2024 02:35:16 +0000 (UTC) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-728ea1573c0so290410b3a.0; 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.freedesktop.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=Wiz4x8jdikthKgCfv6BY5z67V7JYaJliEV1ndcCl67DVrn08zmI/h/JgYqudBEgMow aRMh56JFW8Nf74QsTm7oW7d7NrasB6faZRSj/crpa16yETcu5sXgF3eOHx+B60ifGe6H qMy0zLH+9gKpb2jJsvbd7y4G9iOmj0S6A/RwWWSGz1UIgpotZo1MgLjaYUSADEYhKzll aMERShPNH1nqKaBdOUs8/JpR6DwknNk0P5ekj/KOVZSr1fB3X15SUp3CmpiSaLU0JVzd gKQR3EBV1js6MpInv2z92gAMSMsrVxhECcp8gblalsM96BbdrHt3krNJA7EnRGWCj/yp ZeOw== 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=kXk+nJ4lr9Do6Fd7ZlBJ+mofqwRIrjfztuau5Ul3ZvzDKJAmX+IfrsTYrgxvFvEmk3 AN7qQmAOAe2RkCZ4T2mwJi460N8ubL7t7INT7Pq4kSK7QuI3Ms6HQqzO5Mu+e717+GUB JEy5UloTnOp0cSOP19zW2dZS3o2MEadfUR1cHwSozWFi5nTtOOt79kKbH4NlQSx6Oaec dURr7ucxigIxT2ami+rwVxkny2ut/h0aG2G7YQPENvrXvdHvxU1S9Ti1G7bepKSwuOfr Sk1M25DZK4WqMkh+ep1XTKxXsuhhD+hSIFyfULXjnIfTysgp0OCjXsuE6EWUMj20sU6h g6zw== X-Forwarded-Encrypted: i=1; AJvYcCU4regOXPovfBhD8VXxLf2WNWaeiCYRpiNpfzmdU9dmNFTE1CO1kY6Y+u9VR+tal3dixVcvAK1EBD9m@lists.freedesktop.org, AJvYcCVZuY78NbdJEaA7v7AG83E8VGWluVGIxmTGAkqp95E1Fa6amVMB9Cdd6EAwH3y9SBMgHuLMzL5zP1c=@lists.freedesktop.org, AJvYcCXjbbcvWNA7zAwbz0jipdrJAHzebU5Row9Pn05ymx8vSjaOlXnymBwc4iOiZD/qA2ASN/fCdWaGMQ==@lists.freedesktop.org, AJvYcCXlN+EwkGWDVKmQ6kCmAvI/DXXPGfDgHEbIm9sQQ2r7LJ+2vNmpYcYRi0cqwaeu7QDfVemLUF/kx7E=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxA9jo4oW5XVAsHwdPZOCaawQuBHJFdG31jktfI27o1X3zKfygL ILlXpdqbCXoDqTC4heV2UZiNaoghjmEx+cxG9BFK8sJ2ZV9XwrRK X-Gm-Gg: ASbGncuWFXqxAbdzoSNL2LhzNmFTC09k0UtsN4/Hzw+ylNxrofxZqkqFo4hoW4naInG e7SZb8rrKVvINWnjF3N5H7HOIc3oYavl0K/14ZzNz4QMQM8ktHFNk8GLAJb8Kjr9Dq+vd84c+WX L6CN7Vt0WYe7cfK/kqqEW8R7+iMUpbHwDQJ+7lo+aLFznTzQ3guyOP5vzlpUk32G9nUaKkAPznQ c8nGiYV22lhU2t9AwToESXlUvyuUlpMDFzKIF/W/SzqR1HMr6SALeYwLx26wVmIzIVFXKNQYMdN 5dDyjVc= 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-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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: 13915199 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B293E7718E for ; Thu, 19 Dec 2024 16:07:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 605BB10ED35; Thu, 19 Dec 2024 16:07:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XnKOXrpy"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECAFA10E45F; Thu, 19 Dec 2024 02:35:20 +0000 (UTC) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-725f4623df7so304803b3a.2; 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.freedesktop.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=XnKOXrpyyMJ90nTU4ulBubzGWGrL8xvYjRBxAxcSe7cNdRSKDHxGo089gzZUh3WdKQ ErRO/ijaOnCwu04z3q/8UwxeoaH2tyU245QO7mUoMqpeC/V/JyaQlwhwYpX8yN5mHPR6 X5jMLkPXTwYmRPrTCj96aT/S5ge/8zy+KG/ncCnutAzELLGbJqmRVRO0IyyL6PWG7rq7 ymOGawNvCiSLBe0KBhpNIUqJuOcp5Sz065wm46Ut09kTvJqvVldf1nsyYQHMRcIljNrr Hi3XhQ8fqM0uSTuw+/Y+ozMGqfT2J7huZTDnvTbSTCp+Om/iw+xH+cSMzgI7vmCYpTrT MQ+A== 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=nm83KaayWIy0f3DM6FdspQ0IL7NIqpqvFL2PeGqiwMHR7RgTt4jvCIXLFNQJ5sGVv5 Tpi1XmsD2U3gnyxb772rFwCMo8yIPARmyrM+jAKPyfELZ4Jlm79YViTw/PITylZKllzr SxsuIvjYtI9fbDXVnz8q6A5QGqcfoJW8XerdrV53y6FL2yr1FvqLda92a295CwMY42fq PQXDd/ZUkRuPVBc7jhbeEGDKRQ1SAiaYmEvaJyJGz2ysRjwOeBj62QUOQvYS7j/s/0/6 XGyXqGV+fllB6Gsd3AxUP0wRj07hvWkIo3xlX3IP27h8+KE0o7/mia5NordO+NLm5r72 1VwQ== X-Forwarded-Encrypted: i=1; AJvYcCVOXVSQc0WnC1ewZBBsczT9ULiPOK3zy9vqdas4toF0uBVCyjT5Ps2OMXOphrt9XlevqVDxKwnW1Q==@lists.freedesktop.org, AJvYcCVPkWhsJfCNzr3f4TmMG611T0aA5s+jEZz7pUejdDqg2/Wi1ktOQe/DBzQGSKUetAbTxsKTlV3x4pc=@lists.freedesktop.org, AJvYcCVTj0uYfXlvRzxptyccUGlou6pvrNFg+LKcQNxnqGmrYIkWNBPi6Pg8Lbp9qPoqDLY98DcWoCEWr4s=@lists.freedesktop.org, AJvYcCWh57IqC9rUSn2W5U289Le5+d72mcMGLSJ+J3fKJ8+kRg40aq1z+BcnA62EzFpybjRmpOOOLsR2Qu4h@lists.freedesktop.org X-Gm-Message-State: AOJu0YzbzQIL/AXNzj5/1VyHYV+wpT6rVHtTjLpHfsDoTf4ogTuUM3I4 uIBwMWInoR13eUE/2oUwsOokShBx77n9OtXI23hfdZNjdUlx0NBF X-Gm-Gg: ASbGncv4QUcxRkO9MAuPNsG7aCY+zpCSaJrQAWDUZLWZmu3NUEVFXFIgjoBOkV7LeYN CKo36YG0vF6u4T5XZM3jkaYcX1SB/27Gc4ZC8/JdTNHSNbLIREnWG66cOd11HOA6PHBEW+2SHrr 6NKaG9uIOkp19xDcHluH5FT3PZNu/tNMbKzZaio881yU5rCy0ysgEYTw88/XHQzNHJqzxAQwYiJ aVt8DIumXbJXu51FytgDRUwPeLLlcXwS2i0Lmjep203UOxJY/SYq7R17i1wHBMm3uFObo/7TiIx 3V3g7hU= 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-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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: 13915195 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7CB3E7718A for ; Thu, 19 Dec 2024 16:07:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F18B910E33C; Thu, 19 Dec 2024 16:07:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VzDIAE9A"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 388D910E47F; Thu, 19 Dec 2024 02:35:27 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-728eedfca37so359613b3a.2; 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.freedesktop.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=VzDIAE9AM5w13wkTq0hop5aWb+GtUpSKo+MzLxG0swgCgwUihSFY2dmtZunTtFgauv fz5GBlnCeVGuxsmSVmLMgerJxYV2tinhLnCpfDgMgrYaxcCV3eyf4rXPKKVsR0830YJF 91e+JDekMNK5wrBMRYyXIUYN2ZMX00zWul0yqe0gsWxgvQEYYtGWP2vuhI47jT654BD6 F272Jj2WmHaxxvcNUyEy/8URdqwbsgqjtkny8LE96JgsIejTc2rI+AOH2FriJZ64+/SI 5A7CMXvLypHkxdC8HF188KQ5C//rVRk/C+Wg73NLIp0lqN1nwd5MFjIntEbO5NTnZo6T rqiA== 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=qPEFiUC+OJU7DJVcfpHR4EHY50nv8SBcuJGY8Q8/OZwANMaqfxWA4/VKML7Qg0Qjme vkQxVap5Z/TwQVFhNPk/NwSx5BDIrMeu/A3XElBEdiRjXr3XvhuRBdn6w8TesmCv9P8/ 74yJM8I+Xf05rOKXkxBgdUSWB7iYQ9KjgIsjO9QucHE2ew5BgTQt1cFYcPuS7gIR7X4i AY8+kdkQOWJkf+wWuleFfWM8VXoJHIPuv6pYcNjyIBhfwGjNFxBDYYUkWmxgmlV0wyOt lrOUkKeus1JsGXx3Ja8MpVLypRehiQQPVVEBvhGTWaXM0zrgD9zjF9UKHITekAxGt4MF +AUQ== X-Forwarded-Encrypted: i=1; AJvYcCU0QoeJIRRcEwWZxVeJCKmAfQlIn0prc6t7OPYMjT+lGVZJgewHru0eGzb6B48hPVWQ7vysChryMJ61@lists.freedesktop.org, AJvYcCVYdYzMY/+ayCfm+RJGG4tpH2oDCByNJaHN3h0jhFzIS5puER0S+qFuCmGfOSGEAXe1NL7pYGmfrGs=@lists.freedesktop.org, AJvYcCVlDtq/2L6vCO3o4Z9+DD/btQ8r7PYOXiO2plf0Q8dxPKKlhpGyFpyCis0dPtBydyL57UwK2PfHrAk=@lists.freedesktop.org, AJvYcCWvA8Xm3J9/mh4Oj+FVcYmA2/V+PHEL5jMvuQeSK42bFOnGQqW30tGtrYCLonrR+oY4sd3tui1YBQ==@lists.freedesktop.org X-Gm-Message-State: AOJu0YzoCiK8aTiEr+34yl9Y3EIGajdDvUl4JzmUeVoy98w3xd5ajmmQ xWZggDQGh7qHnqehaZchP746RxJhaOdKWjQ6uzINITQPqcXAz8VL X-Gm-Gg: ASbGnctdFD+1O0fZF2oaxpGDY3DO+nf83pxUHi22uiNLkj2Dv81pSW4C6QBr9NBRkhd ERIDTig4KgZejcF90n0eb9VgilxojMATOzvcjy3HJN3LxvXdBU6k/5o3T+YEcljiJdOnUiOzp/T USW9A/PCP32idyjyk2KfbuKcgmw+QhdlG9KdZhu4Xb+9AU1C5Kztop859c3Xac0npgroqJd3ArX 18g1rwtbuG46sDEKJyjxOcXqFPetsB1UyBkF87Z1LJwqUzVvkR5T46r0jZrU+NhVcyolTYkON22 reaPyAk= 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-Mailman-Approved-At: Thu, 19 Dec 2024 16:07:24 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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;