From patchwork Mon Nov 8 08:38:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12608059 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A1C5C433EF for ; Mon, 8 Nov 2021 08:39:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B179B6124D for ; Mon, 8 Nov 2021 08:39:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B179B6124D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 530CA6B0082; Mon, 8 Nov 2021 03:39:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E15D6B0083; Mon, 8 Nov 2021 03:39:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D0056B0085; Mon, 8 Nov 2021 03:39:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 2D38C6B0082 for ; Mon, 8 Nov 2021 03:39:52 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E97A98249980 for ; Mon, 8 Nov 2021 08:39:51 +0000 (UTC) X-FDA: 78785114982.04.4EAB23C Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 97860193F for ; Mon, 8 Nov 2021 08:39:51 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id b68so4649761pfg.11 for ; Mon, 08 Nov 2021 00:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vo2MttItjwsBsGEUYM0AHAekU+2EW8dsU5b9ohsZ6Ts=; b=FwceL46eexAcZCPqGKjKQWeRmziWQbb8WStX5KoHEXQ0HRFmEoxTbDvAd2WtYlt/Iq RV1aZIohd0k1nzuLtqYyDQsHVCTdIuYJugDZ0V9WYpWbfcprziMckAwkMF3P72cn28p/ Fk9qKo8Sey/QfeZj9QuPTurT1T6LmzlyfbLYpV3Yf0aYdurW1SfmpoGa49NZ17w5WvBu oU5R53qvv6cuDYKDcLFhs1MnsgLoJhAQ543YqxZQxNycMHUyCbwdADEUaUIs146ujYSW 6Opr6p4VaBbmaq2iTzrR8/qlo48gQy3i8VH1hHSoNO8IinNuyi03EHFENln+fZCVri+R 9lJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vo2MttItjwsBsGEUYM0AHAekU+2EW8dsU5b9ohsZ6Ts=; b=Qsr1VOuNhHbR6n8yqjqzqahLr/6ZeCCPd8KkX2lRyWRzDU2uxHoSR7UXw1skmpf7BJ VYdnZGbKMZNutAMlucGfZEObURK9vBFXMGJl+p96506VpkC3y0sQjeOJsN6iLEw6tP6S rIzVwnf1i8CglmuyL/Dt1dbAsNxi3PmVMD1gyUF21G84kl+M1s4lGpgfWRDIZTh3SI3C ku6VAftXxz4RGB2bSNfDu2QiF84xXfDV9F3VOqIrRh9LnHN3m8fTIfpslUOoA9egHFkG 1IpRaA8WezouTiyTEu+zklRCkmteKsHmk6lWQ8piuteqQAeq2FHEiVZ9JI2+e1Y3HvIZ 4VLQ== X-Gm-Message-State: AOAM533jhnoZjigu6GoxI1pJbPAwezpdJMrU3vHCJekyv1h12kILFnJI mB84lpvOvz/1xsoiEE+VwOw= X-Google-Smtp-Source: ABdhPJwgo4zI7DiDbY+RIIxuCe+WtrN4O4psiCBih6u5/j6TLIYm8NMWW7enVf1avJoGZz+hPCeR4w== X-Received: by 2002:a63:556:: with SMTP id 83mr48600913pgf.222.1636360790838; Mon, 08 Nov 2021 00:39:50 -0800 (PST) Received: from localhost.localdomain ([45.63.124.202]) by smtp.gmail.com with ESMTPSA id w3sm12253206pfd.195.2021.11.08.00.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 00:39:50 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Yafang Shao , Andrii Nakryiko , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Alexei Starovoitov , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Steven Rostedt , Matthew Wilcox , David Hildenbrand , Al Viro , Kees Cook , Petr Mladek Subject: [PATCH 6/7] tools/bpf/bpftool/skeleton: use bpf_probe_read_kernel_str to get task comm Date: Mon, 8 Nov 2021 08:38:39 +0000 Message-Id: <20211108083840.4627-7-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211108083840.4627-1-laoar.shao@gmail.com> References: <20211108083840.4627-1-laoar.shao@gmail.com> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FwceL46e; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 97860193F X-Stat-Signature: 69s4re9nnija87ijbozp6pku64npf7n5 X-HE-Tag: 1636360791-469002 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: bpf_probe_read_kernel_str() will add a nul terminator to the dst, then we don't care about if the dst size is big enough. Signed-off-by: Yafang Shao Acked-by: Andrii Nakryiko Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek Reviewed-by: David Hildenbrand --- tools/bpf/bpftool/skeleton/pid_iter.bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c index d9b420972934..f70702fcb224 100644 --- a/tools/bpf/bpftool/skeleton/pid_iter.bpf.c +++ b/tools/bpf/bpftool/skeleton/pid_iter.bpf.c @@ -71,8 +71,8 @@ int iter(struct bpf_iter__task_file *ctx) e.pid = task->tgid; e.id = get_obj_id(file->private_data, obj_type); - bpf_probe_read_kernel(&e.comm, sizeof(e.comm), - task->group_leader->comm); + bpf_probe_read_kernel_str(&e.comm, sizeof(e.comm), + task->group_leader->comm); bpf_seq_write(ctx->meta->seq, &e, sizeof(e)); return 0;