Message ID | 20240729023719.1933-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 095B4C3DA49 for <linux-mm@archiver.kernel.org>; Mon, 29 Jul 2024 02:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 971B46B00A2; Sun, 28 Jul 2024 22:46:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9225B6B00A4; Sun, 28 Jul 2024 22:46:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EA066B00A5; Sun, 28 Jul 2024 22:46:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 58D756B00A2 for <linux-mm@kvack.org>; Sun, 28 Jul 2024 22:46:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 081F6A0248 for <linux-mm@kvack.org>; Mon, 29 Jul 2024 02:46:30 +0000 (UTC) X-FDA: 82391251740.18.B1AB69D Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf05.hostedemail.com (Postfix) with ESMTP id 2DAF4100005 for <linux-mm@kvack.org>; Mon, 29 Jul 2024 02:46:27 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YiULiF37; spf=pass (imf05.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.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=1722221162; 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=1pjCapklVn3dOBXb1i2wMmiETVZVRlEQNRVcNpQhsG7kTjk534j4u8vPAqUFRv5NspNjpP v7v10eN8eG6GfqzyA/0qCIvOgB91+8Xgnz20PXXsD098EgPtJVi+Wg1k+a9PLk+8lbm63v HvoedtEDx/7xtGtlkKlUiJvNOPWCfws= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YiULiF37; spf=pass (imf05.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.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=1722221162; a=rsa-sha256; cv=none; b=IhMO0WLxDSmSK8AOp5hlbkD4eRJZ+0pvHjU7nbH9xvaZUIgYQo6J4n+hIrs8XpzqT+NXd+ VBxdBGHied/ujR4IgXPDgQ5qaD8en8MLd65cFwROa3B+c3vrl1I3Bg3GoXEjMmcu8erIMu BYLybGCwenQgw4Ot8IYwoJTL1oSsLyo= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-70d333d5890so2683617b3a.0 for <linux-mm@kvack.org>; Sun, 28 Jul 2024 19:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722221187; x=1722825987; 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=YiULiF37iet4iPUVlQlAxdpfoNkEvGR9QvkUwnPEELGzSpN9CXDHLuaqWPNkVss9Vi nbialFvuJY/E9go6AItMEMwVYcFs8mHnjIA9PtqQY9uMyQSmX6dSS0wcLaPVKtzgMlwL /IzpdCM4FYKc0AuqmCqc2QEUPCOftW6ERDqyLCjiI6OaF6a2K1HYYPkS1q4X7r4L6K0A blCZADDsSwwJTPdpO4FgoRnsfKEHNW3Gs+B2k/8pcd6CUSnb54kC+YciFtanWuATWSHu aZx12N2A8sUzlUMn4p5qYvZ4ABWdEqpUQwHv80Y/R02/vDH/VDOn9nsVku17Ts25Ikcx Zo3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722221187; x=1722825987; 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=SeTZuKOpdRq58xWJL1A6jwRVK0y3CAX2xbRzHv3A7TFBB7lHiyS8qISHGOTPrMIgs+ GKC4ipcmLyi6DdRaqwz39hzscLGEytITSk841uNpLqLXgG9o/f3LbN9XyAzU4qxZSoHX dKQ+sxRKhcv13O1D4MtVauHi5aNE+zAKKlU73mZeYcLYOw+jP/2nSJ+weNOghZt02dYO ozx3XFEwfjPsOGFnyl/TJWLAdRyL/Kv4mW00rc8ugdcBAc2XuczuLO6qVBxb7VGsEfhx 7gd3YBc6IBSqkDKHp0WYrNgeTUrDylpl+xHzIJe1dkL8Ej+KabzirkqsZa3yOZgz9hBH OywA== X-Forwarded-Encrypted: i=1; AJvYcCWMK9FmbQKd3oCJ7oIw/JquQ3HuuCGlyGsG9N7F2n/+4PQOs0fPj2G4YDG2I2tnzti4OLYXR8lOV3IO9p6GjzYjeaA= X-Gm-Message-State: AOJu0Yx1mdbuIbN09hB8aWBt+ycWt1BJSTfo8NsIQmD8m0FdkIDLh/D6 ExWkYWMh5duEoROH6z48TLRl/Om3Esim68a1Bb5W9RCPeF2UZBEY X-Google-Smtp-Source: AGHT+IFg6cYKlkoyAPcpyLktfLarITyb9Rzi/fq7hOtiqCqd30rMJ+pCgZRrHbxyCAgQM++WsL2P3A== X-Received: by 2002:a05:6a20:7fa6:b0:1c3:a55e:6199 with SMTP id adf61e73a8af0-1c4a14ded25mr9866605637.44.1722221186954; Sun, 28 Jul 2024 19:46:26 -0700 (PDT) Received: from localhost.localdomain ([223.104.210.31]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cf28c55a38sm7332247a91.10.2024.07.28.19.45.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2024 19:46:26 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, catalin.marinas@arm.com, 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 v4 08/11] tsacct: Replace strncpy() with __get_task_comm() Date: Mon, 29 Jul 2024 10:37:16 +0800 Message-Id: <20240729023719.1933-9-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240729023719.1933-1-laoar.shao@gmail.com> References: <20240729023719.1933-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 2DAF4100005 X-Stat-Signature: y4ofpg3srth191jxgq61gfx5e16ctpzi X-HE-Tag: 1722221187-705013 X-HE-Meta: U2FsdGVkX1+OF0h4A0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qWx9FU3xlqQ2kYfAhsV6TtFQpEUnq8jtH79liDS+iYzv2QPTNMV/TdK5uPsbtW8c2RFARyWBSMGwVy6g/B1eUoknPlcKw+S8JK4c9hUgOnWLqNsxRWN/GKYobgx5tya+ZLwRmS7jHpRwwAo5yAGza7zkFPwK1AzuJvVsDw+2zuWh7mwh9f6nw8XSa49JKhBSCzrElBscCGZAx8N70Vmx56gUmolmHTkTlurcD4ceLQuIN/iWDsPd5hZvz0CRPEoQzU3OkllnQaiXiCKp7TWcMV/v27TyFutc23JaTENPzwBOgqmeQnch1i4GXRAELp6XNci8YcZVTOoqsRhhC2mwN4xqMrYlZbDDgZOKeOiU/g8+2eKXjlEtUNaG6/807rCa78Jx7cIqszpWQ== 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(-)