Message ID | 20240621022959.9124-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 5AF77C2BA18 for <linux-mm@archiver.kernel.org>; Fri, 21 Jun 2024 02:32:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA5216B041E; Thu, 20 Jun 2024 22:32:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5F0E6B041F; Thu, 20 Jun 2024 22:32:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF52F6B0420; Thu, 20 Jun 2024 22:32:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AEB116B041E for <linux-mm@kvack.org>; Thu, 20 Jun 2024 22:32:04 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 476621A081D for <linux-mm@kvack.org>; Fri, 21 Jun 2024 02:32:04 +0000 (UTC) X-FDA: 82253320968.01.F22205D Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf26.hostedemail.com (Postfix) with ESMTP id 6DEF7140006 for <linux-mm@kvack.org>; Fri, 21 Jun 2024 02:32:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="itRsIEi/"; spf=pass (imf26.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.173 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=1718937109; 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=YLBTtkMiqpwrbmX5moG/Cui3KrNWoKaBHXqSp1BnarheP1OWBJ6lNdxPjHhrxwGLpY/MEC q9kpjKUA4aXV7YIssnYYNdNB5d0efzO6CAxPOmdE/4KaIB12yBMLUXmcI6t8bRorKzNm6o bLS+GhgzZrYuh0jk4y2LtgT3Xx29FAY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="itRsIEi/"; spf=pass (imf26.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.173 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718937109; a=rsa-sha256; cv=none; b=ezs3epWdrXCsiB5dwZoL71lLzB8yQwgiu5tyawKdtbZyW51gn64x5/WIaROKLf4Ja10TB6 tn0ipWrH8934qQTL2Ws/sluoh36qXNEvN8XaN2JnIeFiLKnpui99r+mhN4Abv3Pzrs3+/S 1USI8kzIQecx8ocZz6/y9kABSJS+oBs= Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3d21b3da741so775444b6e.2 for <linux-mm@kvack.org>; Thu, 20 Jun 2024 19:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718937121; x=1719541921; 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=itRsIEi/IiiLG5nWRJ461ggqXrqI5O3KUMkboiPbDpPfM/GxOmRtb9Lmr39GBUeYcB N+FHhtNybpVSKFhx3bxGPcjocfxjIMbSJHoSl3+vbM+8TTPcJavdlKLOnxbqoJtpXGki SjPHBlY/Kj41CKixre3HC38aTZTVP4/Z83jaNWovsCf64iwvQzNN+uy8HWJRw4f0lArm lvOYN1fGKQivaX/3FdbqTyIJkohaRhGgkLNdRuGGsJuXYLwlHFVs6acu8DMBVArEyVPJ 6n6RbyVxGXeTLHgfvCpT4zvcWK1TkUK3Il7gB8ISpsTBYNJP4QYtwo/+XbBBUnPAiFmH hweg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718937121; x=1719541921; 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=OQBpfedrJsA/zT57moYUAOvtdjWTOkpv2qiuHKZ8CWMVIPgI0StNrmkvOosm4gWvGd TrNeG1Rfr5a2kmtZdnchD/KXNVUGiQI8OT4ZNB2pqC2vGwSdmorQeQLpRuxJORqLPMTL ddkUUezngKlHmLRnKfIJw9+jD8ssl93E06YwmijgTootT8Qn615QktB3z0JFIoAOSpQ/ iGLgUVc0rXyKrf5XUIdkpjn6DkajwCnu8oVjU55yCt+9FPHzwvkJNSjUM5Z+aFWuxXh/ txgqtxrShI+SCelTGvjP4LdaZlvdcprOH9Xq7sntoKtuTZ/EvhI2QKJyCM2/c+PGyYXl YJAg== X-Forwarded-Encrypted: i=1; AJvYcCUvE30Tv9M9e9Y8QHjaJKrjHJOJqOIzALPwEuTKsnPIaCoEKqE3JwLz8FQ+BNKY8IULhAEmLvcCWkEBfbS/RpBmtpg= X-Gm-Message-State: AOJu0YwJvSy7p0ihAQ9J92zKXw6hfE2u+k6+fUcdvxZHy99TbmgKNT69 DYlQqurL8e//fP6F/NHQ6ZnVEgPV04FsjzpzvPy/DmI/VBKwwRtCq7g6JpTH X-Google-Smtp-Source: AGHT+IEDLpdYIw99Uz7LWzb9Zy/b+1+lbeIcbqra7aNgXOpLlSyDlDvG9wKvxKsFRnB2arbPqu9IVw== X-Received: by 2002:a05:6808:130b:b0:3d2:4a08:2cc8 with SMTP id 5614622812f47-3d51b9b4558mr8069073b6e.23.1718937121450; Thu, 20 Jun 2024 19:32:01 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.24]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706511944d2sm332488b3a.70.2024.06.20.19.31.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2024 19:32:00 -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, catalin.marinas@arm.com, akpm@linux-foundation.org, penguin-kernel@i-love.sakura.ne.jp, 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 v3 08/11] tsacct: Replace strncpy() with __get_task_comm() Date: Fri, 21 Jun 2024 10:29:56 +0800 Message-Id: <20240621022959.9124-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240621022959.9124-1-laoar.shao@gmail.com> References: <20240621022959.9124-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6DEF7140006 X-Stat-Signature: 3tpb8yxjr7k8y1gxyqizpddkat9myx1g X-Rspam-User: X-HE-Tag: 1718937122-320319 X-HE-Meta: U2FsdGVkX1+mtaoewMZ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gLQ79TepTH4jSycsZZsB0BLpqOsjg7ZCoWLbf8Zzq4REAg4M75G61VuI0l7cg+cEZEu5NsYVsDbLY+7el9dEB0LZ+PH5X45n/15JqbLeY9AqHNdA9ApqTHfp6lUa0bszqCicc3jQT9Ch0zGKxwJBTZ134vlz1pfYfuo9M9x7vW7AJOY9D3NMQhX5i2mnE6+E4IlNTdJByZzInHHF1SYSQXpS4M4pjH3g3rdwkifkiVvg7pmEuN4Ajv/8Iv1VdWtMWOqwRU8swvwwIxFYjrlaLfDtNGBGbxrG84f1uEtPNbID+BLiSSuB2+TwJIyoZsQsrLE8Il09x/0T67u8qHXiM7yqhZe4TVu4dvMGgArOebNU53tD14nAh2ENbGvEE264yO6K8o45WNbA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000713, 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(-)