Message ID | 20240613023044.45873-9-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 6FA50C27C53 for <linux-mm@archiver.kernel.org>; Thu, 13 Jun 2024 02:32:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D1096B00AA; Wed, 12 Jun 2024 22:32:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 082566B00AB; Wed, 12 Jun 2024 22:32:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3D216B00AC; Wed, 12 Jun 2024 22:32:08 -0400 (EDT) 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 C5B0C6B00AA for <linux-mm@kvack.org>; Wed, 12 Jun 2024 22:32:08 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 86F6A1A0236 for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:32:08 +0000 (UTC) X-FDA: 82224290736.23.CBF6F24 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf02.hostedemail.com (Postfix) with ESMTP id B67B080002 for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:32:06 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ne3hgYwh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718245926; a=rsa-sha256; cv=none; b=q85dmEWD58vfg5i6GKc0YmJdejEjizLBZq38bXcEAy6cgI2sfnY9VbfE8eU4PXYbV2ZpFi JML9cQsNOgNrsFLLO/He+eU2kv74Z+1u/2nl372aEzb0K3gGevNwW1aHofJViSQO265Jf9 4exGigGFTqEfdOTTJfytyUhiq0cCR2c= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ne3hgYwh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718245926; 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=HQT31JSkonb7Xmqn+k1uqrjgngeoHr6IFKrX/+KN6Ok=; b=wRYslaYL7wchOjCE3EtN2CpKBn/VTGjeZp5qlIfvk8asylzi2u/9GUT1BY4KsIQI2+g60l KYenmGSbBFYsjVas/1nLGmu/zqp+XIAj1rvpxQYMRoraphueUyq/mtvYBUUa8xSvj+V5dU 31WxF2Zazyq6zFBFBluwQz+kx46fECc= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1f44b5b9de6so4608865ad.3 for <linux-mm@kvack.org>; Wed, 12 Jun 2024 19:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718245925; x=1718850725; 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=HQT31JSkonb7Xmqn+k1uqrjgngeoHr6IFKrX/+KN6Ok=; b=ne3hgYwh1PtmofVFFA8ZcUFURtp9y0lqiawewTKpz7BdUd1yK+8PvpEdEwP1mWXhoB SdCZerH5CnpQczvMOpJduHCU1tnfLnAPMCkIsANcpVS3xjCyrT97Gn3Y6y1FfWdM++2g aQ3lQjscjTAa3m86IaXH3nK4fuxa2Mo7ANAtu2EpvJ/Tu8Rp++Bku75iyyCWfz57/Ytq UlWZkcuRD6SQF24/IWxIO9qM58YgcfcIiFYFsvRw+gRucyAEGNMQIGAIdiSN+rU4NXiz XEuGwXN+jpLPN+p3or7Ft6ZRkBmkvg9uoOvbbwgPqYFQ74qXur1VnCq1PRmmt4iWI72n q+JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718245925; x=1718850725; 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=HQT31JSkonb7Xmqn+k1uqrjgngeoHr6IFKrX/+KN6Ok=; b=UOM+NFHGwPACEvqUdIu/axpeN3KvY/ioVKweBYCF6rQWBJJELqG8epuhVQUJCW/VZT X/gPN9V0K/e7I8hjMyg7A8mO+uWZi31rcyfNkZppoMYScVwni6VqhrrXu8bxbX1veqn3 TsFyGI81Clr8nAUUwireG3kDT3xaYaWoNWncjh/ZZIozBer18GlCPfWPF2BngUmNJgvP PMVPIAhk6lq7xcsKff526RzXVfcNnZrIOgRnQdlOgvXPlU+BiAAyi+hhxKDBoORh+Xol OQi+ZILTlLyYujgstQRN9EXpED33vNSLHrYqDfJQzTwP6XeZkLUVKxVnFA+J6+oGBmlR 1dXw== X-Forwarded-Encrypted: i=1; AJvYcCVwq/bdSDv8D3B+zPbe4lKWmvuHmd+/mNNFAZUrEzZv1TrMUadLEKMf0xhQYd+u4vIkYwkBd1mGv5DzVHccuTwUI4s= X-Gm-Message-State: AOJu0Yw0eepXCauuY3XtlgYTKGhS2Q/8bBW4HKeIUnHGtzYwotuXE1yK IMDpEntiSSvqLEaIyJyFmWsNIol+dnUr9hH7UdVf3uM/0mUSojxV X-Google-Smtp-Source: AGHT+IE/Thj9zy8OzNEgltY85A2YMlP/9PBe6RK31xV6C4QSBrLzPw+agMFJyhDUlBI6xydC6ujXaw== X-Received: by 2002:a17:903:1c2:b0:1f6:89b1:a419 with SMTP id d9443c01a7336-1f83b5583a6mr41814045ad.17.1718245925584; Wed, 12 Jun 2024 19:32:05 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.92]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855f4d159sm1755695ad.289.2024.06.12.19.31.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2024 19:32:05 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: torvalds@linux-foundation.org Cc: ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, audit@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Yafang Shao <laoar.shao@gmail.com>, Masami Hiramatsu <mhiramat@kernel.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Subject: [PATCH v2 08/10] tracing: Replace strncpy() with __get_task_comm() Date: Thu, 13 Jun 2024 10:30:42 +0800 Message-Id: <20240613023044.45873-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240613023044.45873-1-laoar.shao@gmail.com> References: <20240613023044.45873-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B67B080002 X-Stat-Signature: 6e9mkmftr4wsni7hqumbekaodjfxhhsp X-Rspam-User: X-HE-Tag: 1718245926-903744 X-HE-Meta: U2FsdGVkX19Yt4OKkx38jE6EpGMh5EOf3Nf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DaTObFpBs/g7mvojbQzJXewuKQ+nc1hWtwHlBK7wpqTzrLZa+n4uGOqSM2fQ4nDc4B+1x/LWp5XPUKHISShgmo5yBTnd+QpMUIuuXRACf0mFoTgCaPSj43Mt42oX3TEWxYhTDpj56QxusHizQUnQf1GxKYunRHe0f1eVz/z0Ws5ZLsTcI+1iNpMN/XIxYLbD9jERvHhywUVbTS6wVyD4Sas9bi6k6nTItqjEt3NGmdEgF9i4JW149+Nx/ApVEwEFb9bP8F6+UKpmcPtk6OMv63Bq36tchir9tqs7XehnUYZNilkaC38Rll6Qz4c8BaWBjA9gqKsfg/VytZWnDNxlFZURC3Xv/jBp05MTZh9mrkdlDYtoIC16sYKEmli226XCRfNamPgRRSmwzi5vBbSawY/fafp/1vgdDPCFEUelK71ueuSCK8zzxiQUvzeCeAamLbon2ch5QmF9zjaU2kh7LhRyTHdJvox2S8u+Z53oKwBa2BSP9qi6Jg4RBcYqOq5PGyULh8XyKt5f0jMJTY+ozMkps+uCaBmzTn1yJEI7a5750pC64gete64= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000845, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Improve the copy of task comm
|
expand
|
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 578a49ff5c32..ce94a86154a2 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1907,7 +1907,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) max_data->critical_start = data->critical_start; max_data->critical_end = data->critical_end; - strncpy(max_data->comm, tsk->comm, TASK_COMM_LEN); + __get_task_comm(max_data->comm, TASK_COMM_LEN, tsk); max_data->pid = tsk->pid; /* * If tsk == current, then use current_uid(), as that does not use diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 6ece1308d36a..721d4758a79f 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1599,7 +1599,7 @@ static inline void save_comm(char *comm, struct task_struct *task) return; } - strncpy(comm, task->comm, TASK_COMM_LEN); + __get_task_comm(comm, TASK_COMM_LEN, task); } static void hist_elt_data_free(struct hist_elt_data *elt_data)
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 <laoar.shao@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> --- kernel/trace/trace.c | 2 +- kernel/trace/trace_events_hist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)