From patchwork Fri Jun 28 09:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13715783 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 39BC0C30659 for ; Fri, 28 Jun 2024 09:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9E556B00A9; Fri, 28 Jun 2024 05:06:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4D606B00AA; Fri, 28 Jun 2024 05:06:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EF6B6B00AB; Fri, 28 Jun 2024 05:06:17 -0400 (EDT) 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 7E9526B00A9 for ; Fri, 28 Jun 2024 05:06:17 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0062B818A7 for ; Fri, 28 Jun 2024 09:06:16 +0000 (UTC) X-FDA: 82279715994.18.16DD4BB Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf03.hostedemail.com (Postfix) with ESMTP id 2019820003 for ; Fri, 28 Jun 2024 09:06:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=H9blIUFY; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 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=1719565557; 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=aN2V+duoRLP5mjQclolxXRJl1PN7YZIwA2PLtFFVKQo=; b=GhAr/M3HmsseJoLbkxnfyD6iTCPCjUARYwO7VRa4J4RFlBRQXZ8RlDk7iGQf7MRGVfTs8i Eguk/f3kTvhkyaWe2d5jwv4oZ4gZPtEhdy1ONF67v6sOJf3cd3Tkg38Is5m8Z+XAHrOOsD Z73o92lCZ6fwufylqweMAHtFxNkixiQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719565557; a=rsa-sha256; cv=none; b=XScF54Ru8991o0Ktpsur9QWru1+BYZGqPaA3FQD2l5d86ESLVMftX+Eaf+CwtzmhCZL9on qq3FkRbS1DGelQQ4dHKbU9IoMaIKNtIsngwq14hMknK5lgNvWrSSA8L4sMTI01VboMM+6R mwgoL0OYJ3LWM6i1yFvWKC8fYJXjFIw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=H9blIUFY; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1f480624d10so2276485ad.1 for ; Fri, 28 Jun 2024 02:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719565574; x=1720170374; 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=aN2V+duoRLP5mjQclolxXRJl1PN7YZIwA2PLtFFVKQo=; b=H9blIUFYQOSVrzys0ho+bjCU7ituZb0oWQ1/LJmaiqRBsujIdc+rq1V8W3JbsmaSmO iuc7pqOgRIq02mf+dtY2cNVGPuRS/ISjZ5+dm8Ojj/7UJjSKmlhOdcsK1T/FCpsQL4/B SjljcuKhkZ/xz4q80rBT9KNtmCeEWzQxvyzASshmJdmynvRFhQqDr2B5Y4m5AzYAt7xs 1lxXFTtDNt+jIY42sd0zXokxayKnomhNlwUezRHituL0zaQY4gVIKDZ49QyVlmB4eUfS L02nxgplC78GVvFKhOW7TackEiDoF1fYdX3OGao4D3koMyvwIAW+6sTZ0KU8o3pdiXSI 8OQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719565574; x=1720170374; 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=aN2V+duoRLP5mjQclolxXRJl1PN7YZIwA2PLtFFVKQo=; b=V7sBSABop5ab9f7GzCW3SMr31aTJZy5MzyiJmH2SCJiUxvhnWajp1d+8Xn/7IgJx8m 1YxmDPEQU/zV+8JIbIi1cnDa5ZUtxveNlXHwNTei45qjtA/ruVcQESB2/48fk2xzPRgw Noxp7PqDEtodARAQ/4gEz5PBCvfebj4LAORduTf4q+tyfghClOH895zQMln17vqkvj12 l4V0GK+fLI45tPDSLXaOi4BSUMFIDcFEuaPMpbdiZ6fSmlXDHu4Qvqv4e5VjVK9TXQfB n/ugZSMSvvSzYxhUmGF3PE5aPyxKpht9tnmh1BeGG8sITq3ORxL4VcS6hjvlLVbab2B8 uZfA== X-Forwarded-Encrypted: i=1; AJvYcCX7bd/A4AohEuSHA041+hO7zbc7ZQBYwU0qUz6nYLwc8Lmcvsq4+eMYyeqdOHLk6vtIjrviXFOWgtWqre77S0jxb/4= X-Gm-Message-State: AOJu0YwEun38bGMtA1TeUPRftNX6RQTmGqLoXGhhhydXlUWEe4b5N4mp +CsdrFHYjs3X1THgwihAqm0XX7vgeaWjhnE3AkMYsTA3QTSnKCu9 X-Google-Smtp-Source: AGHT+IH8hbTH/mkdkSjyBT5baT0IFO1FQw7wMYLskc8y3Zcc6iSLCmGElb9qtOP7mNAm10MFemyYoQ== X-Received: by 2002:a17:902:d50b:b0:1f9:e7b4:5def with SMTP id d9443c01a7336-1fa1d3e0157mr181052415ad.3.1719565573956; Fri, 28 Jun 2024 02:06:13 -0700 (PDT) Received: from localhost.localdomain ([39.144.106.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac10e3a1dsm10473085ad.68.2024.06.28.02.06.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2024 02:06:13 -0700 (PDT) From: Yafang Shao To: torvalds@linux-foundation.org, laoar.shao@gmail.com Cc: akpm@linux-foundation.org, alexei.starovoitov@gmail.com, audit@vger.kernel.org, bpf@vger.kernel.org, catalin.marinas@arm.com, dri-devel@lists.freedesktop.org, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, penguin-kernel@i-love.sakura.ne.jp, rostedt@goodmis.org, selinux@vger.kernel.org Subject: [PATCH v4 08/11] tsacct: Replace strncpy() with __get_task_comm() Date: Fri, 28 Jun 2024 17:05:14 +0800 Message-Id: <20240628090517.17994-8-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240628090517.17994-1-laoar.shao@gmail.com> References: <20240628085750.17367-1-laoar.shao@gmail.com> <20240628090517.17994-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2019820003 X-Stat-Signature: x965zccc833yp187cs34z94zweehwaty X-HE-Tag: 1719565574-693078 X-HE-Meta: U2FsdGVkX18VBXZWE3RMSCb0g+HGfHqPW80TJi4k0qLkTc0Lwsx+jLH+gvmVmCoGKSp2ZPPW/EyVy8zO6nzcAs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i6/Y/RPmGvONUupUsDBwwsaMJfqUbyNuCS3Nu+de/dTzdD9Ediyf7l/MrvQCnpJTLMO3PhvuhwtlHp6+tAnhRHdkcW08ftLEQhTlMBqkOt+71ybQLUAYnIg8GutW6uec9dbHWR8wI28L5JKcTpjABMRzG1xXM5KO8GALCdR5UoG86tEI7igS5Quu6bENA8fDkJc2vmVIcl7qbnmlB8Gl2F3X3LxB/0fNBCFA6vTe2mZ7YsgtnleoiqehBUsb/GyOIcJFyNPf+D/mDkck0ZPc9A5gu6qfr3EamOF7hfY0U0C8K2FTXUsSsSVZGSMDpmCxA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000036, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Using __get_task_comm() to read the task comm ensures that the name is always NUL-terminated, regardless of the source string. This approach also facilitates future extensions to the task comm. Signed-off-by: Yafang Shao --- kernel/tsacct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 4252f0645b9e..6b094d5d9135 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c @@ -76,7 +76,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, stats->ac_minflt = tsk->min_flt; stats->ac_majflt = tsk->maj_flt; - strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm)); + __get_task_comm(stats->ac_comm, sizeof(stats->ac_comm), tsk); }