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: 13914409 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE5A586350; Thu, 19 Dec 2024 02:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575708; cv=none; b=mYpgrb/yveAwRdbMppWqc9vgGAlwzJBl0oeaE2mnX5Sn9GO/psOgfLMDT7eY+HdPSDi5Z8X22Fh841Fmo/dv72b1hS/EuDcUVf8odw76Dx+dPnQV/fK8N4RRFfcbrgOpd4yB9sVPNVe1Ff3kYG8q5TBiaD052XFC2NAM23ZEY70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575708; c=relaxed/simple; bh=yqzB/UQ5CgxwEer/KAHpFdkzi3xdVyXYQPOSmuyPZ6g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c7NuJA2rmFEgYMCanSqtwr0dwKdtCF/azhwM9F9zs/Vi6ZuNDBHRo6eJleZN/w675Yx3Txdzb2MgyH/RyhsVr2HFKZjcUlLq5MpTTlG6Z5PUrnLd9XEFA/AwoVsCncBUVOS2SjhC9t76tAvGFFIm3uueb+jwPgkBV5JgJnzjaXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CfGqnsXh; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CfGqnsXh" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-216395e151bso2164075ad.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6yZ75uwrgzXS/KAS9XiI4pfcH/Aa7U+Upt9QqSiD0i8=; b=CfGqnsXhJXA+m46v5RqUJAHNBloPxDHb57g8h4MKsyAeQu/vjT5mETOXizMHM51iWI Kwfbl4YSqMFOIyFR0Ix3Dkiq/ubZjSFsx5qAWBb+1I6H1dfX/zVglMZL+jtY8zO3Y2VI DfF/uZzUkdDscLZnLOmXXEKBBAOIMIK9vXUi27lhcKJcq1mZNfWh5Hho8DxnZ3WNUGRz ZcW01P6f92JdYvzBQskAYiQYQNJkMA2zQDNLEUJ+v95cqCl7mqnZn7fO0tvz9OHvmfcI R9qt4+/tO13z9zZw68Fh0ppidLoWOoPJn5DjPJ7VWOfPY+oxhdxO7d3L/hEj2K8FPTOb ZIgQ== 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=UZcVBN8vm7/BEW+Fx1j0eWIq30ILX5xhzdjZRpWyWaMnD3f4KTzpk+husRZ9Yg6df1 3WG8eZwt5PbAHDMBqgq4Als9i1b9TehEvzW4YppgSC1yxVAXrLofrVkFJxqOj7WxfvQu Xr74EN+7G/KRXgaUshItRqqpm+vjORM6SHTM3q/v8TOtWm1N3V/f0b18Q1rKsCHywoPM EavoFjvy2Oc+KsRGuhPq5pTi9VqI4X02wEZleaX2WwRcfQtuMZxSj+yxanag2IeG8Bvj b5FW+VpVUPpG14H45iJBDtv/RWduMOPA6ODVrmWs2C+CG9ome+ONTlh8P1L/wKWEp9sl KP0g== X-Forwarded-Encrypted: i=1; AJvYcCWGWeBjyQxiFvkm6H+vbnwzUDHt7a2//4yhgKIb3f02URzk0JiMnG+/A6KEaKHv/iZtIJji7ay/L7XmgoPov9w3VidEVtuv@vger.kernel.org, AJvYcCWKqMMy94bB/Kr/Nu+YIZ1Li8GhRUvRGkbO7j8lTUTAX9CZo+vhXrE05lkM1MQx1khi0B2ESpIMFuwlzoc=@vger.kernel.org, AJvYcCXwsibwNIP0aU9Wew5jgG4rB2QgVBEDqlE6QWFjFsbdofXyWV/kW/z3lIHhq4inBIUTP6vjg3WnhQf6SMJoVTA=@vger.kernel.org X-Gm-Message-State: AOJu0YwpVxMjhV7EC0n1/uTjYBpCRXz+9YJ1TTnSssbpIUBABuBllOky 4zHzW/eiwbsNT69opaH6iGznqJJjqtHfbYQe/z6sncyRqMt2N/mX X-Gm-Gg: ASbGnctTa9orhxfAjs/XfpzBVUter3LZKBqsvhoLNg4N2j7rCheRgzIHN3NnhtFCr8R e3ON1h3kfHTviso+Mdp1+63svKi6FTHGeAb+JDZCuMlptmLeEpwQqzbNL8k7Pmmyy6IMVOY7BpD UfMDB6KVqgEuw9g6V3JPsjP7Y6v32CHnNJ8X9aoWiXZWx/z0JzbFRLnDbipE0jy+yijYkVaWsMm XQCZPTdRf0VVioRZEwyM6p/9x8wHkjKwTMlF1kWeQ/6ya4y4G+mHeClgv9pFee6J0kWBhUhYTX7 l6+MUKU= X-Google-Smtp-Source: AGHT+IHDUXmWYVlYvXYhHIsD36N49JfOorXAToNFZUciCwG5nEYfG9fZ9g2sYrKUGUIeEzsd5pUGJQ== X-Received: by 2002:a17:902:f689:b0:215:2d2c:dd0c with SMTP id d9443c01a7336-219da5e3b97mr23433885ad.14.1734575706180; Wed, 18 Dec 2024 18:35:06 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:05 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Serge Hallyn , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 1/5] kernel: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:48 +0800 Message-Id: <20241219023452.69907-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: 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: 13914410 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08A3C35960; Thu, 19 Dec 2024 02:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575713; cv=none; b=P9yasWt+rrFmYCfCaAsbhf7fxBMmhtkzgZPgyET+QWI2jUQasGHSCvft81W4sVBSigJiv1Q4o5G//pMfFYhc0AroXjkEZNBCBtyFH8RCurWRciSSVp+DMKNokRW0CN+BLbTlKFo7z+DIxQ4zi3CXflTAMiroyLx77tnsaU90d30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575713; c=relaxed/simple; bh=fjvo4dYkUreQMMEsg3L8KRAKXKBd4yx0ng+KH/F5vq8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uhz5PMSOzmyyUwJit7Ip8pmZ/dGyrowAgz02zk9gYsu3zM8gd4JxVUku9qfB2iQ2osOYrYM7wFfufVu6CimgmSNlLToH2aiQKN1sudlwpVKKa01Rl8286dVCtg9uBRDGUzEtn0VTIbn46gpshIKS2maxoaKVODy7qr8er+U74k8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PtfE3ODB; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PtfE3ODB" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-728e1799d95so387803b3a.2; 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GFcOX4O91tQFD6muydW9g9dtgYf4vZjGzF6jEGHBeGo=; b=PtfE3ODBCLFYmX/zn4C8k29GTQcB/j5+bdgyrajaZtlHrFu84fpY/6X3TzSaUgzFqy olra9hev3FHVGxd+7nZXDcRyj/KzzaeZHS0fxC7aa6xD4jxcU2K6e4thieZJaU4z05iI 9LFfEeoAceRFMkSoaP0Yai/10HXIHa/PjM1J2a1cKKJoyBUBnRuKYhwIhiFB1ZeqR6Oe I4bsdPADpFFKHIhVsFzwem/h9/9Q1BQtaOHW35nBhZQYahtKoOesJLC6LLtIbxIUnHUz 9uk/xaHOhmrueSa+zAoaCsrjr5plNtKnmLP7B+/Khc8BNvs3+w5w6r9BvNO6Arfsx35x kkrw== 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=XRy2FjzIfEk4nvZyI3xrVuWjVX/xndZoR00tK9ICDysca9KLqUSjRn3vu26oWFfbe+ eMgkE1UTVlFcTNunB7zTyYa9tGYznsz5a4a6epeIcreolc25WFsMvaAiIXRCJtPsvK8J Y7acSMCaeF2WIBWBMtK3ydyh7gBlBOhcBsYB7U9JTzaOZkH358ZC30QtCFpbmXOBj29v QH/xUwShd1cw53BfosBlllo385lWv4dKDNHSTzJVvOUZ6W5a58I5NF3FxZnkPDmSxCPA CG/gZ+e7xgqnhDTvz10NDdPazzgIm3AbX1dzUMLYPCLp2REsR8cVy2nqTBi7j4P+oY6Q aukg== X-Forwarded-Encrypted: i=1; AJvYcCUMvQnAGddl/WVH4++x6DRGSg3XSqKgH11thKEFRmqLAtDjm9t/+PRVr3v/NYjykqs69wDB2CcwuCo36RY=@vger.kernel.org, AJvYcCVmMZb72x8Mk1+ZKDr2tc96gYfc2UCxJzkXzolOJdNRw9P0i1GDLcmV0yMzLLHG1ePx5pEBBTejtwBLPsqnN62l3eMLbt4S@vger.kernel.org, AJvYcCW12W+L1qmpgX3avhcIbc+O4Vrj4kAtC1hiJUsv5zCOVjAXwqgjfZ7mEchFPWj5PuXkrtE7KSFyTBOIfOA9iG8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6fq2nMub5YkaL4T6+eloY5JO17ockS8j9Q+Y8D8L++pQmKc9T xp78ULdvptpk3erybUep6HvduQrxtFvYq7je3Q0KgPSmadA/9rMF X-Gm-Gg: ASbGncta9bAy3JF/eoq96i4RNIQOx/4SWRVVJ6vEOAgwwNdlvVM4giAzaciKqs8uPaz 9E96f0Y2q3bJttw/YNLoQNnhWeCIQ6H/2GYjB7ilRfZNi5dz+Tn+gCOEBgbqs9YcKp38N7WxpR9 kgA+5K1heHsYLZdI8oRGQFTwiMGz1rr6PfjnGa3G19veUA6agTsoW7HeqBGxRVeoGXwq05bMqV+ cc/X+xuug5+HKtuj+5RYSI0gulLD1ITe5/xY3DKdojVJ3OEZQqRLfcYUgma6+jF7MOTTtP9rf3u wEMvPWU= X-Google-Smtp-Source: AGHT+IF8uDHPAeHRKoSWXDpZOfxN83+9I3jRkG5wW7qXuv+87XI+9vIxsP70Tcc6kEOf0TdmQfwRSg== X-Received: by 2002:a05:6a20:c6c2:b0:1e1:ca25:8da3 with SMTP id adf61e73a8af0-1e5b4820f26mr9200947637.20.1734575711218; Wed, 18 Dec 2024 18:35:11 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:10 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Vineet Gupta , Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v2 2/5] arch: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:49 +0800 Message-Id: <20241219023452.69907-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Vineet Gupta Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/arc/kernel/unaligned.c | 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: 13914411 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C8C91632FB; Thu, 19 Dec 2024 02:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575718; cv=none; b=Wu6Pzcw4UU7omxk4ShhmBUepeXgNh6zOoimecdLFIRF6W6BZ0riu0nmmTgCU47iebjZNGZvAbU2iz2L5D/X1QM/ndstwHiue17Y3egUnc+hFyTd7NFhPX/tCDv24xiuB2G559qdkieOi1vNfEydfB5o4HUjq1wcrB6aefS7s/Qs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575718; c=relaxed/simple; bh=hl37Iql5X8gsZ29nKhRpHi4iYM29ft8c5jBgwm122Go=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E8YvravP4EVR6S+zA9FQ3FWwRU5r5yWBOOTLc3xWfhSHlP+xr5w/JuAt/7yMFR+GMVGWdb86tXE/W+q1S9n0HIDamE/MJKhFfBsjwDyqihr5RES1NrBl+Tpdcm1VjOZDflTXFg5IsNdko0zFMp+D0Xqtz1JFcJ1uU47eU5vJZQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D9YcoqVi; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D9YcoqVi" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-728ea1573c0so290412b3a.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zz5f2fkK5TyUEN5/ypHLYKDvnfLQ33CHwDb71kc+wK0=; b=D9YcoqVifeRF547x1sGReun43yMOm4BG159+fwQ394JoK7Yr6ZUWWNAoKMTwjUlVnF w6LE4pz8gADn8g2d2XO444JG/DV9A8hgikB7wcqSYSH0zzPpCG1cLlMBkM+SXIXi1Xs1 Zh+nR2j7yloKhjxmX8cBNM6n8gdv2iVmmaYhXi+TaHqG4y4g+8doq8v2sZ7yyaJylhPp VISYnHq4K2npH9JygxVau257XGhj4y5YVBukqRtuJekxYj43j2FL6cVYd7Udl4j3jgFY t82rYJh4WJOvkWC9piCCP3XHqtU+HFHTyXZJ0wqyv5XcT5L3a3G4KQJBDF7z4hwCWiZZ x9Zw== 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=b1jHMLBn5MSD8iq0znw8E7rdPpv3ExI8270CseOHfe0I8F4WYuVqokoJzQbWmI5wo2 306PEL7Kl3oEvBQMQaQImL+QcWrWevch2dYHXz6LsDtgj3Ew8/TnbJ54/byEtAuwKzwB 566Gdgqm43MW+fH0v8ouXhfQJ/K2KFKoX1UNzkd8IYPV5srUtkVghnrxg7Q6ZAqSdVS+ QgPtO4BckDhz6EA84pRMEY5SPQHNW1OXRhXeRIeTxh0BvjlXTd5pp2fwByIhGNClttST bpczjsZpyojsTz0mz38UIi9BCJZFoWqdgOxOCZmfVOhPBdSqFhH1e7qfSYG6kSuzoCaU 4fxQ== X-Forwarded-Encrypted: i=1; AJvYcCV03CVNJMgxo3UpSUtWX15rPQT0voluV8gkSeQrfjwr4Dg4K3UxB6v0XVJOmi/sDJeQxgW8rS85lvRm1SE=@vger.kernel.org, AJvYcCWkX4MKapVRL5NkvTE8TjJ9HG73YdIvBRBOUBVq8UeDmC8TaZM7ydXUsonPw+QkYxiYwgekjV7ZQuXkVrOUgng=@vger.kernel.org, AJvYcCXx9eX7sbdQXCSeTA1hzhV9wwt/kA4Z0aIBYypQiHdCBSh5Lgj5ITf3oqKBxdspLSh3PYG4cVop3MulUigIMX+W0SFqIuXv@vger.kernel.org X-Gm-Message-State: AOJu0Yymygv8Mu2FX1Eb7R3BLllhYu7VmXBNxIw+5Odkzo313az33Bt/ sTh+9sej7GdhiZkvFHfB6V4YQ6CGOta4GUKj6k7paa/GHQ+rZ3Tg X-Gm-Gg: ASbGncuWVn2VQEg2HjSlNPxg1U8zQmr+EQqJDaEh9lT7U1a4JxP9WZe3eJSEcQGjD+5 ZpIa0UyaDeStKyAuRWu6QoeaDYn647F6FAs9isCMq9NpVqKCAIOzJR8g6sF1UL8Dvjkp1uACIvR JlE8lRhS0IFjz4ziSUkzEYXRa9+nYZCQAuhJE0VYmjihaRfXzcmrkGu8965xUFRZb7BMu/z1dch j0SHyO5bGNZPOUyYVz09g9WZN6TLDZ6d5xf9TCUTY6hxlZH3AOZbXq5TZCnp+l6ZLYPoLSz4uaU uqanrvI= X-Google-Smtp-Source: AGHT+IE+5BVERtvEj0uFGUNd3NBBPkGat0lwCNqupmyw0FAX2xvKE0cJmTowKcGod/Hmj9SrgliLyA== X-Received: by 2002:a05:6a20:a11f:b0:1e0:c0fa:e088 with SMTP id adf61e73a8af0-1e5b4810ff0mr7532504637.18.1734575715510; Wed, 18 Dec 2024 18:35:15 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:15 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Johannes Berg Subject: [PATCH v2 3/5] net: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:50 +0800 Message-Id: <20241219023452.69907-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao Cc: Johannes Berg --- net/wireless/wext-core.c | 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: 13914412 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5186186328; Thu, 19 Dec 2024 02:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575722; cv=none; b=OlNYlm3OKrhtM+wIwhpMfA3MwuG64nkNRuzbM1uQiWPe495TM1LA9aaNZ1PfhE0jhfmMYWc3Z9Tb/Ss452ZCz2Z33nvhDPwm2npNItgzQytx+39b9ah3IhTAusilXqpEdae0MqFRIlZx0RHNch0sGrs+ImdBPyc37kgLV75eLuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575722; c=relaxed/simple; bh=uW6gREAjVtJ2OpRjMy/n/Vx7nbzOviJdyVpvyg6VGj0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QoftRPDyod5EtycDT+MQ/98YLVdMzTxZun6BaN/KKbi1gTtePhuo4bdjOR/FCwvKvEGY6A+eivRB2auHwuZTdcRINIV0rAavkgC/HWvlkU54pcFfyUKHwL9AKV2uv/njlZ/k99EQP/O2VvHQiIbPvmOAmuCTzBN0l889DLHTel0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mQAYg0JK; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mQAYg0JK" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7292a83264eso280665b3a.0; 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=35FnTfH4WG+K4PY792luJMCXMpwCP4Hox12oxUuAxYU=; b=mQAYg0JKmLRdBr5/4QjBadhAuRHMwWvbEoS0m0hdxiUQSfMhUeCXIQz/XP/SDm53Ng 8ZTSS07kKMFUiUcbc3o5L5PEl9uTW7vF+TWBat/+2C/VKaVbCDAmTjf2FALVI4eRnt8k mOul29gPoAkkg0PcYcF1ejYmhK0rOSj6oMKON9HTTrebw4mOYlax5FmgGh8+XaYhb0kJ KmV1E6Lg5ALR3G5fF9g6N/VKvcZKeV5caGItziYoS/7ntsaxRnmxVlVp+aq+UuAPDMhr eU5FfpQkRbuL5BOI3kI/XiapTdD6BPcRTob+rZ/qA0wALiBSLlveSkgzdz+Kwsd1vVVQ IK3Q== 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=TDd1bY45qHi2XwCELq+soYWQBeI7NFLxKjExZv1CwAEaSp73fWP5gNrqBkqX/RKWJ9 Tz6x9ticvyCQMeg1dirgmE0DkB716upMxPI+g3fyPU1XDOjTJFOJI2TdxP+FgiTxbfd6 byIRSbgsntyhqDS0GkZlEoJwe0de62F/7jxjyDw2X3/Srac0Jld7luuuSuoG3z8C5jnL F0+30T6tfvnpr7x8Okl3aEgdmEZVn5JgBJi/V11bx+ypHAdd+RXitSuVIV70qAl+eeMq jAoKer7N0Z2sIQa7e4roI3vHImh5IKJ29tPfOuJMNuIepF+R7e+gYBeDVxsHbWY61Tnb QAIQ== X-Forwarded-Encrypted: i=1; AJvYcCVX44qiDMSSlJYZKAUvDOnO7cKC1fAlyr/vs33XupgqroBEtWMR9xPNVVB8dEMYCgSmzHPea3/T3GJPv2R4DaM=@vger.kernel.org, AJvYcCWKzu8Ourj9MRbKMxDvWvJn+psh4HU00VaCMZ2H0on30wO+OkuaJPYdg0RXDQejZ/c31Lbee2MkK5MdeyY=@vger.kernel.org, AJvYcCXxNEs+3GDcQjFKmgdCQs0t69i/oUjNewb1IM9gpcWJffNYFFwWAoJEhzccj2DEZLQuOVSjvshlXfxlKuK9p0RkppTDUA2F@vger.kernel.org X-Gm-Message-State: AOJu0Yyykx27QYHcWuaDG/IeKS3QAKK9Xg6yQ72a/lTxbSp+7IOSIDOh xaIe5V8u2ukfMRIV73g2yY+wnJ+Qh8NmSSvPuWZVIvYiZX0Pn7KW X-Gm-Gg: ASbGncu9eqymj31JBoc+8U1Cb22hm0EN7CzNGolSHRPVnJAlzy6Ni36Skg1A6+N9F4x PpMljKe/iw1T9rS7wJZNtKJ5XxX8xucfRiIePIgXRX4b5ESCKd/Oc0/pbds9X2vj6R85zsyhrxv caITcp466ashbEr3UcAwzBGPYXV60aFfIuTx7qH7k+RobB8F6abj2uMmKyOkI6XaSiBrzXpBDGl p8UiEoTBB3wI6fXHtwm4C1H+GNMTayGPLWtcoO9MN3JCmvAxCpClngz3bL3Q6xRSDV9SamtgeKR pM8BAJo= X-Google-Smtp-Source: AGHT+IEYa8/cPCrPUtV+8BluujgYPFlXKrKcInk+YdaLokr+l/jazm3QEi9WUGXKVKTvc9yKVja0nA== X-Received: by 2002:a05:6a00:9096:b0:725:e37d:cd35 with SMTP id d2e1a72fcca58-72a8d2c2269mr8262629b3a.18.1734575720422; Wed, 18 Dec 2024 18:35:20 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:20 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Paul Moore , Kees Cook , James Morris , "Serge E. Hallyn" Subject: [PATCH v2 4/5] security: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:51 +0800 Message-Id: <20241219023452.69907-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao 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: 13914413 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6926F86345; Thu, 19 Dec 2024 02:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575729; cv=none; b=nQtXLlQeRiDJzP4L6UVhBVsIKTxbje9HV8vn9aQMJfcs3WQxoi1lhkEtVTqDhnO+SW2x6xipPUJCmMEFRi+OOlGhVrVtvhWE1KlBSzUV9a43XUeun7VESFA44Bo8w2T7Q3T5Mb/zaixTsEqJy/GieL6o1yHHq8wcOz4X1gcIeRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575729; c=relaxed/simple; bh=VeLbyOfvsBoD/0QCt6XTwvSQyL69DBSOWRzzq8d05w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nHYo6jf3mgSPhu3vbSSUz+0V+a2eRGHC1xNUBKWTrcKx9jCd0Dg6hgJFPW5nfv3atbfNp2SvL3dhhAz8AIH2UNx7NHkOjbPlmPMia+zW1xF5l6NayP2FrKa2UVdNXhXlygEORnaq459Ke6q6J+W/QDjE8w9dm0nSe4hBCAiHKTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XPp9cMLX; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XPp9cMLX" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7273967f2f0so380879b3a.1; 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7lFqN6P61Vcxg60EP2migAvtPpkWX8ZEoCx5nNg3/cM=; b=XPp9cMLXnifLLA4GGsg2+q5Q833Ki5DDLHERUPCx6TM0WtQstBGyfYD5Su2QyA6hMX ropCIa7P4Gq4kOh7+UfI+PA/T5mCDx1pQodG5FG0A9wNhjiSRC9632dOwolJq/F7hPZY if/+tdS87qY2Ea2ZDp2deXHG7MOZA17vYHmnQGoXpY+v7Yy2cLypd7zk4WAnzizD+7Bv D9Qj3usvHB0sFf8NdtF2Id2beJL4GIpPYqNhkiP1Xp74Di+jhpLYJkeys+9RYuEUkkdi CPG75xw/fz1KI2+i2DBIpvC/ZR1w2TuUt//anTQ5ajwVsvIhJZgwLlbnaK07G6p/ZvMs 2mmQ== 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=s8rEQwBLJAlWGKqap6qxpJHZ2fcuRYt2TvvFmZhL3Hs2mzaD02LIP41X24TwczI7wj BInVAiedg/JpVkKsWzMjM36rsHkng5fXPRtANA4TDeNs3s/fgG8hIOAvxsopyUiZqTnE s6dXNrczS1KFozpXUvSzyh3KDFECkScQnXQX7fgzlcyapVZ5IDuLFkTc/QAQYPYbIIyt tYz/+q5i/C1moXpNsgFgjkmsDenOYsg0PPKYTK9Vtp8iEEa5iD7nny2JAo5dh8MHBPqE HFcthJxCtJ2gMXJ479YA6tGlQ9gkprACAq4tUoHepngLNYKo+IhbTH7P+isWySU69YYk OF6Q== X-Forwarded-Encrypted: i=1; AJvYcCV8jO9YPQrNnyH5a4maBWRH4nOhtSe1qKQ1x+uYFoIyVdda5PEa3yIAslltSVvKJjRvSVb4Rsz3zO4ZuGA=@vger.kernel.org, AJvYcCVmb99WscVrPyYIcTJ3eeYxbAwG/UfjjccJdkRe1RGA+KtJMOS7WNAs6AnlTC2L9Gx7bHC9xL5MWUQvj1/ZU/hdUuj1FtPs@vger.kernel.org, AJvYcCWPQKLfWajNaChZ50967PKgFUtLj19OWae/SW5/tbaeM7VPV45JRd3hvnPCv5G4hvjQ/qLoMBvFtOMEEkUNpwk=@vger.kernel.org X-Gm-Message-State: AOJu0YzMMUqUiXcsjwLcF8Gm4JehPlB8CZCfB7bSMsVguvwt/rYUF22u W+MF5Bdr5IWIQOMIsKb3JMXWrmXv7cDRHyPSDVxA2jpgdgtAiRC8vzd5EOgBl9c= X-Gm-Gg: ASbGncs/bNb2WKKkCj5c/4GIz7zig2sq50h0IZQ0QnjlqU3//4IQyH6lOLodqHEGMxe Q1+5VtBY+PYYQlZJ1b+/R06vpWbaIHBaOGPfw0vy8EPDYIUKjjbQJUmOHUZXb+ekZuWpuEifsIZ 8RAr9uDfGFSL8OMZ/blxE+mhRwbdgxLCBqOI/cZbSjGbAqbSgU2qdGZuYRfS196AcB0JI5wiX4v zHmXmNxFXbmb6SoqM+RHm6dZzILMAxTvgRWpn6YCCHXYFIeHh20vAlDtbM694I0c9EwjtLufzdO cU+Fmdg= X-Google-Smtp-Source: AGHT+IEASYTltYbmKh5ZDA03zBv0Z8CD36/wkPvI28CV3U8CPosE7HG5sfVxRVIBm8iQbfYV7EQNzQ== X-Received: by 2002:a05:6a21:788c:b0:1e1:b727:181a with SMTP id adf61e73a8af0-1e5c763cc43mr2386992637.24.1734575726666; Wed, 18 Dec 2024 18:35:26 -0800 (PST) Received: from localhost.localdomain ([180.159.118.224]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b821da83sm142163a12.40.2024.12.18.18.35.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 18 Dec 2024 18:35:26 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, pmladek@suse.com, kvalo@kernel.org, bp@alien8.de, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-wireless@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ocfs2-devel@lists.linux.dev, Yafang Shao , Jiri Slaby , Lyude Paul , Oded Gabbay , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Karol Herbst , Danilo Krummrich , Greg Kroah-Hartman Subject: [PATCH v2 5/5] drivers: Remove get_task_comm() and print task comm directly Date: Thu, 19 Dec 2024 10:34:52 +0800 Message-Id: <20241219023452.69907-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20241219023452.69907-1-laoar.shao@gmail.com> References: <20241219023452.69907-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since task->comm is guaranteed to be NUL-terminated, we can print it directly without the need to copy it into a separate buffer. This simplifies the code and avoids unnecessary operations. Signed-off-by: Yafang Shao 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;