Message ID | 20240613023044.45873-8-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 6618FC27C53 for <linux-mm@archiver.kernel.org>; Thu, 13 Jun 2024 02:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D31726B00A8; Wed, 12 Jun 2024 22:32:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDD876B00A9; Wed, 12 Jun 2024 22:32:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7E4E6B00AA; Wed, 12 Jun 2024 22:32:01 -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 96FCB6B00A8 for <linux-mm@kvack.org>; Wed, 12 Jun 2024 22:32:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 20206161818 for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:32:01 +0000 (UTC) X-FDA: 82224290442.22.304F2C7 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 44BA34000A for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:31:59 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fXNGYZLt; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.176 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=1718245919; 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=MqSWr/pfZwtTIRxMBQN6sYuDk2R2VvioPDgEPjsCPow=; b=K7yIcC0/jDow98mLC9Wr1fYsJwSOYiLRisxIUe3Bi3U6Z0P+Wmjf32NxgVDbJLEJdvu2dB yeQHUolhSBRDA21MY3EkCxeXm+vE3iS5eouWdxta/rmoc5YFjTsJCwC270ssoBOrV0qzdR EFwMv2yKFE98yhnahb6uS8BkMOY3ESI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718245919; a=rsa-sha256; cv=none; b=yV4YCCE6JKfP0j5nBA9TJKFOu5pKWSYykzaBIMWcYu0xLDI3wmVXLHp/l3yo8yQ06SaR2z PaHQUDuk6zDnTMT16GjKocHfsUtif0rx4T0gPeo5u6AsoaaOBc4VPGIB9wRO2Evr0SIKBw aVTfvQdq9gT8Dl6ccuammUOcRvToeEE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fXNGYZLt; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1f6b0a40721so4016595ad.2 for <linux-mm@kvack.org>; Wed, 12 Jun 2024 19:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718245918; x=1718850718; 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=MqSWr/pfZwtTIRxMBQN6sYuDk2R2VvioPDgEPjsCPow=; b=fXNGYZLtmfkwg6ZFzwrXkcGNwbyTaPBPYKOQx1hjN6SOZAq56HEB3yVWeFeY6oKFLM EWxh3ww2Ey0s0mszA67bLMQz3QE627q3jls7m2Ej292d0gTrrwtV0F8rF+D8iFzQkGve bAAVTJgNyKKP7esJPsJEwtxkyeSb/L+YVhLNk5Lw7gfbKtHT2xfZEm8Dp8dUfaZ3cmCY g9I/QsD7GuyUafe+Xm+ijqw0+hYXk3xRdH3qQ6+CAMqorAPHAJwzxDPtdI8PIOClVcHS ncIypKki9T9AKzaku+VvLArGRcc6clVR6tfmz8ouHkPz+Gp7wTmLTVRCZ/9I1mj4tb9G TWiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718245918; x=1718850718; 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=MqSWr/pfZwtTIRxMBQN6sYuDk2R2VvioPDgEPjsCPow=; b=dkmZGKOvt+EG1h9YGQ/i5VJPdIjwNK4cIBoy8bA+4hmTSyoa06EUYy5YY1A/VXGr4j zlacKASQyG6b+ROUvumFQwPdLOsGYFCYGB3YJESvYo0/Qf3l8N9pRVz7fWumS43puvJL B+k4tuNT+SR6R1Itr/1mUzkjwA2yZ0kISeI9iMPnENJRNRuUBzG2J2nAdCk1V3MffXQm Vc8hBF0FPQTWn2ah6DVtdR9rxb+xhW8tJsGO29Y+TleF+vr+SDRUkIHlhPZd4KjfI9FJ R+2Dd5hAhcQIBROrP2fegju8wGoZpoWp20Dct1YbmiWjtulE7KRi0ocw6Sobw/Dle7Of /ZJQ== X-Forwarded-Encrypted: i=1; AJvYcCVsGz7tmZAyPpK08R5g1W/34A9pI55ZgIPb3vatyYz2/exObWLXRZFtmcL68FaOwDkiv1z5bklzpjpRap1Gz6rtI0Q= X-Gm-Message-State: AOJu0Yw16qEr0Nyn8+vcviZLyvXbTSVhyWIBFAfz3kmfovnr20iWA/kU kvJS/81W3GHbjX/W3iWQ5OYsNkXu2jIBl+NgU13MVYPMLoj+KzB9 X-Google-Smtp-Source: AGHT+IF+JYjBn0OjZmgrQWU2wgsy8ofTmlVYqxM2KmLwEfyu1c8K7LtQBzzKH0FH1zCzrNJ76ASDQQ== X-Received: by 2002:a17:902:d4c6:b0:1f7:1893:2587 with SMTP id d9443c01a7336-1f83b55b817mr42002945ad.14.1718245918153; Wed, 12 Jun 2024 19:31:58 -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.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2024 19:31:57 -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> Subject: [PATCH v2 07/10] tsacct: Replace strncpy() with __get_task_comm() Date: Thu, 13 Jun 2024 10:30:41 +0800 Message-Id: <20240613023044.45873-8-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-Queue-Id: 44BA34000A X-Stat-Signature: iejoo74sio6xk9uhrzope19q35jmbn5o X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718245919-999372 X-HE-Meta: U2FsdGVkX1+fiPpXn8t95qBVzp/Se218t6WLAsJy3B1srwv1Rs+2EcawNJE9dDDHee5Wql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pvdg8/QyvvHphUfVAjuSLWh0tIt0xuLfzk3Zxs5j/L0RagAFHU15EoUA2F19Qc06iY0mE5ttnHmo3tcyBE+MzLwCdSBDrmXWNK82aGzC0ZPEaajej0zoBr6CcpXzvrB1MlUhM14DaOlMrG37DrxOesLEvAHQvbbuqbbMm8Jb9pc95uLJ4Nj6wOtYRZ+FQub0P49wUxwo9cg8kVRFRwtZOaOt/MevYki+zFOdEEoMSNxVtSUVuToQ3BzTkgC7HtQ5q/AQKODX2riNdBuvSq2k4tX2roY6nVCRLkQkMDI2qDuQ1yrXNZ6gXORj3ZjuUzu8Mw0WXFw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <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/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); }
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> --- kernel/tsacct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)