From patchwork Sun Jun 2 02:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13682645 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 BAA25C25B76 for ; Sun, 2 Jun 2024 02:47:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B06A6B00AB; Sat, 1 Jun 2024 22:47:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45FED6B00AC; Sat, 1 Jun 2024 22:47:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3280A6B00AD; Sat, 1 Jun 2024 22:47:20 -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 127CE6B00AB for ; Sat, 1 Jun 2024 22:47:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 90D051A01F8 for ; Sun, 2 Jun 2024 02:47:19 +0000 (UTC) X-FDA: 82184412198.22.DAE7D07 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by imf16.hostedemail.com (Postfix) with ESMTP id D4E43180002 for ; Sun, 2 Jun 2024 02:47:17 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xsc6F5no; spf=pass (imf16.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.42 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=1717296437; 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=bu3o/1wkpiEjxw3AW0N2UpaOJE3SQdUz6rVg/pLPlFs=; b=eRnWsOvVGV6l+yErTC7kwtsIdvCacBKQ0gUIx8HtO4+E645hsHt4bdtDc8KXbPWVQDtODO vdK3UEjig8XJeClZsERCnF2j1SmCRyQ+VKOy8MUpH+mjBNBJ4PLLjidn6fTQW2Y8w7W11W 3EPOAcdsLzEj0yeGsIeyWrmZrEQe3KA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Xsc6F5no; spf=pass (imf16.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.42 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=1717296437; a=rsa-sha256; cv=none; b=ts0/aTqxkjqdFGUVjW1Cx2fYh/7Jw5yNzsOUueKvuTghmvcM+kKoeADlXmvBPAjSMfCkge X1aAROGBDVOP+0CFj8Noo/2VBKJZSArLin7cmLqe8zZ6fGxblQNKI2/tBmG/SthQfiRzpc bfFNujZo/dKO7rDLnygc/jn7A5NNDSU= Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6f120ae1ca3so1844343a34.1 for ; Sat, 01 Jun 2024 19:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717296437; x=1717901237; 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=bu3o/1wkpiEjxw3AW0N2UpaOJE3SQdUz6rVg/pLPlFs=; b=Xsc6F5noDLDkZlg2ArthrlPQR9Oel+AzA+y88i/HRU0gDhx98rDO1w/amrnL63O6vk rQUeeiWznwv7BsKhiu59GYhCl1KWtgP3F2fHMthfQ2lH15kU1D+aMocKc0kEatlb+0gG B+03EwAjxii3oTza95ZnKTLhYTCrGgLMDd6X/jhqa4nSsG8F7HBunMcd8TFU4icnlNqS si5ugs9o5I+g+na9+j4XzCXvmn0wK+kfWEVu/xkI/ffbBMFOBI257YzDTbtyCoA2K1Mx Br7iKRS9UtO5DFVUmVzfLrkJlutPoywZY5k6dEdqSSMhbNJS+Hphv/AIxmlbxK/elEYl 4DKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717296437; x=1717901237; 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=bu3o/1wkpiEjxw3AW0N2UpaOJE3SQdUz6rVg/pLPlFs=; b=W8VQQaepiOp3GpAGCUOaHDaOLo0qoW5LeRt1cRN/FgU2R3rJNFRXxuPzjqtRsbrEsp YzclIii5IghRpzDpHebhsmAzgseIa31tYu+TU5WgiyzxJs1LBW1bw7x/+itxY0M14/H6 hZ6gzehn7eMW42pYqmcCNmlCF8XnSaZWCd4ssIBBBHjE5xhwqBC4CWDZvVTZpWXjWd8R IFb2NRWZOP+3PhkY6OcEf1Rx67IqJT+O/daVn7d+TKzCn3eXLkkUcLqtiEJOQIUS6GGh KfocA4XQaPc9T9UMT57y9M0sKcMlNT0nPpUXU4tb9TcuxzCcIRF/iKXrBMW8aMsigEVL elPg== X-Gm-Message-State: AOJu0YzrmezTW6QbgwBpYhMMzyxcqJZqSXLyaSL+fWW3xyQRh01FjAGy x8SaGq9+7AfrYBCEX4AEz34Ell+//gV4Mw18rgVPhv7Eb5+J6pk0 X-Google-Smtp-Source: AGHT+IFc6pB9c2/xDQu9bENUVRyBXhBelq6v1sdhKRdECc7iHQz2zEq+tFq0IQc1xoKSQZnnKrMN/w== X-Received: by 2002:a9d:6c07:0:b0:6f9:91c:f275 with SMTP id 46e09a7af769-6f911fba0c7mr5694846a34.38.1717296436688; Sat, 01 Jun 2024 19:47:16 -0700 (PDT) Received: from localhost.localdomain ([39.144.45.187]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6c353f0aef3sm3289959a12.10.2024.06.01.19.47.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Jun 2024 19:47:16 -0700 (PDT) From: Yafang Shao To: laoar.shao@gmail.com, torvalds@linux-foundation.org Cc: 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, Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko Subject: [PATCH 6/6] selftests/bpf: Replace memcpy() with __get_task_comm() Date: Sun, 2 Jun 2024 10:46:58 +0800 Message-Id: <20240602024658.25922-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240602023754.25443-1-laoar.shao@gmail.com> References: <20240602023754.25443-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D4E43180002 X-Stat-Signature: cf5eb1rtfmea4qh9s5xs3sa46rmbb665 X-Rspam-User: X-HE-Tag: 1717296437-20961 X-HE-Meta: U2FsdGVkX1+fcjZmVOA9I5tCqE7PZzR0vWSuhGj+vWBQa4c728vK7cL6neGJYLrEpVo6aecKq9m3d5MDPx0Ua8IeAUzrWOL0hg6fx8uXmivgS+crnQZ62C68wBjOC0Sd7snXyU7o5S1SUrpJD3V8Zeg5e5v1HMb/HuQqiLdd0UGEzsrNzuzn8j/4//42BZVfSpPAL9ltQO7VN9aGDEifga89LDJjSR2mLN84c28fF9Ia9DjNjpStAiOCSJqQg4Fec6ozh5ekJCQy5fGkI+pcUf9CiOlmSsySuM9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howHPPBQfcAYtyYqzC/13cMRIFTu+Cl6byblxi+8wrn5Qz/+2kFk4H4iHnkLh+/1xKYa8iw82rvGfeQDi/uig1dpkOoCXVbFkGOfKEcx0RxOlQ5kMNg97I/sHGaKAkAAuXXTNFA1IhuA5QoTobQdCt06g2sZRU7qQynqba2v3LEh6/iPz6dP13MJS1yrBf1TdoIku5ZaO/4nT2C5r5swFXiWp4B6Cl/M4ywAJavGo3mOD36Qc9UxOHgCorXGQtOUnf8emNavV4VyKXBONSXveiWvCr6/QrNp92bt3JwQsISV/Ie0pzzKb9Uv3Rxs6oSIVxGYDA3fdT2cSSY9V5qj1cN8gQha/BevcKAKo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000116, 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 Cc: Andrii Nakryiko Cc: Eduard Zingerman Cc: Mykola Lysenko --- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h index 11ee801e75e7..e5df95b56c53 100644 --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h @@ -20,7 +20,7 @@ TRACE_EVENT(bpf_testmod_test_read, ), TP_fast_assign( __entry->pid = task->pid; - memcpy(__entry->comm, task->comm, TASK_COMM_LEN); + __get_task_comm(__entry->comm, TASK_COMM_LEN, task); __entry->off = ctx->off; __entry->len = ctx->len; ),