Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1090705pxb; Thu, 21 Oct 2021 15:41:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW6wC6kKmqstHrZgU63wTd+Ld+MhhGbksFXZUuTgOrJP1tS2PlopJyrPnz9fwXBJfxcT6n X-Received: by 2002:a63:7444:: with SMTP id e4mr6474304pgn.87.1634856081514; Thu, 21 Oct 2021 15:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634856081; cv=none; d=google.com; s=arc-20160816; b=ZKDtSyDySWjiawqfQPmTgEbMOia7raHfGjOIgJQd0HAgSVrirE4puttgOi2IIf7cQ4 J2u1pjVIi3IujOmU/k/ZsXWHA4XnuJwhK6RA9MZ2/wvwkNEeODjYXOCaV0Tb5E4gcJja wIjntCRNhEapohR8GI+OpW9MzMMr1PILkFyX86sbNKrPFTXpwiUzun9p+vEXOdMkTk7J awD1Ud+HzKHFY2nYJfYiBzxE4xwuk6b1UAUOnCBOR1Y86r1NWlRMgfZ1U7Ma1cBrPekx d4MMdFvDst8wRUJoGdlm8jh5iUy6UmTNY8Av9UngFlyunqJeXRc+buf7w/DXMKFdsYcP LbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mX0gvzf/8QgI7lZxsXDzZG6vg6V+U9yQ0ZFCiOuBHEo=; b=aVDYe1fnM5wEjSU5uUY6SsZ2CWKqLzVtJ7b/bLm/671sUZ38GzAVpKX/ZTD26ivl9l rAY0MeBRAEPWFsa4oxOWxuzak+P6B+luNZ4bORtvm6dvwfOhN18jhA07l139I0c3C6Kg s/5qYar7jntQAfR+WKvgqKsYIlpSnsvCTOtAx3VFUqg9990MLa8KchXafE1OFzlWAGTH kgb11nGsUOf44H8wE054yaQaPFBsoLEftkjSnrI/CGC1wmdjKfOVhMIFAh7PFYBPz5/y E5CGMIaFhP/I/ZkaksGu+K8rfGzf20fMqZkXHqk5kZr/cbQ20Vsdcd7a1Nwa9D/5iTWV W+yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KonIF20s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si13746872pjg.78.2021.10.21.15.41.07; Thu, 21 Oct 2021 15:41:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KonIF20s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231895AbhJUWkj (ORCPT + 99 others); Thu, 21 Oct 2021 18:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231515AbhJUWki (ORCPT ); Thu, 21 Oct 2021 18:40:38 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14029C061764; Thu, 21 Oct 2021 15:38:22 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id v200so2665798ybe.11; Thu, 21 Oct 2021 15:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mX0gvzf/8QgI7lZxsXDzZG6vg6V+U9yQ0ZFCiOuBHEo=; b=KonIF20sHgoOuKrWtmsRSJMbRoVsWrVKS7hixfNEbWzYzmdNQOUHSeH2r3EEdg8dx1 RrJekPfWfHsiNT+WMokibqdKZN4GBvnyCyDokh2s4wYfQR5Y3xqh/b1LKTpW9f1bnps9 hMeTeAn4xtpUCBbol1qcC8fnhs2XLafB/BEmuaPNFcjGCcTiH2+sKDrrUkAPadKzJRMs TRcPZastxBaMNAoROM/WhbhChKVCmOLuScNq5KeWC01+x92K/cSsPZONKzuiAnLjUJCj hxgeEKqqhKqCVQI22wcEcNnQ0E/bxPixyGn/4IXj+kd+lZ69I+IvDw3aWOESF8khVoqd XZJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mX0gvzf/8QgI7lZxsXDzZG6vg6V+U9yQ0ZFCiOuBHEo=; b=Q/u8i9iN1zdkOv5PA3EWP1ooJBZt7LmZSlR+Zu2bWU7JPrZHKqqeVckbvsC6eXJkEx IJZQa9P+GRBEv5mcELx0OAeLcKWd4kltiGHs6o8hWt7r5ifOku63scHA7KH0EisxDIca L3tYcb7DqW8Haa1xDwVjXX8VW/IxqmHdUn9jIFacBQ7fpN3XQpbvTvfNZO+F6RfgChmv MahtQHwMcHWAEurOm7lHPm2c+nT0woYatyZ74OYwZGIKRCISJAaOn5aQ7jrTgLCoereC dZetLAjNpEUKT0jjP4qow2sJM68PyyII73YQNMPgJrGpGBb65RpQSHpW/tz83waZmO2L ICBQ== X-Gm-Message-State: AOAM532kfrKg2QX3mBKvy2NFKzEvHwGlHO84d5CoOAMC6X8em0V8d3hl suWiWNJ4ZQ/1mM/MHT9Rp+qkYgI1lnTJLtsgqfU= X-Received: by 2002:a25:5606:: with SMTP id k6mr9160954ybb.51.1634855901340; Thu, 21 Oct 2021 15:38:21 -0700 (PDT) MIME-Version: 1.0 References: <20211021034603.4458-1-laoar.shao@gmail.com> <20211021034603.4458-2-laoar.shao@gmail.com> In-Reply-To: <20211021034603.4458-2-laoar.shao@gmail.com> From: Andrii Nakryiko Date: Thu, 21 Oct 2021 15:38:10 -0700 Message-ID: Subject: Re: [PATCH v5 11/15] tools/bpf/bpftool: use TASK_COMM_LEN_16 instead of hard-coded 16 To: Yafang Shao Cc: Kees Cook , Steven Rostedt , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Petr Mladek , Peter Ziljstra , Al Viro , Andrew Morton , Valentin Schneider , qiang.zhang@windriver.com, robdclark@chromium.org, Christian Brauner , Dietmar Eggemann , Ingo Molnar , juri.lelli@redhat.com, Vincent Guittot , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , john fastabend , KP Singh , Networking , bpf , "linux-perf-use." , linux-fsdevel@vger.kernel.org, open list , oliver.sang@intel.com, kbuild test robot Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 8:46 PM Yafang Shao wrote: > > Use TASK_COMM_LEN_16 instead of hard-coded 16 to make it more grepable. > It uses bpf_probe_read_kernel() to get task comm, which may return a > string without nul terminator. We should use bpf_probe_read_kernel_str() > instead. > > Signed-off-by: Yafang Shao > Cc: Mathieu Desnoyers > Cc: Arnaldo Carvalho de Melo > Cc: Peter Zijlstra > Cc: Steven Rostedt > Cc: Kees Cook > Cc: Al Viro > Cc: Petr Mladek > --- > tools/bpf/bpftool/Makefile | 1 + > tools/bpf/bpftool/main.h | 3 ++- > tools/bpf/bpftool/skeleton/pid_iter.bpf.c | 4 ++-- > tools/bpf/bpftool/skeleton/pid_iter.h | 4 +++- > 4 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile > index d73232be1e99..33fbde84993c 100644 > --- a/tools/bpf/bpftool/Makefile > +++ b/tools/bpf/bpftool/Makefile > @@ -164,6 +164,7 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF) > $(QUIET_CLANG)$(CLANG) \ > -I$(if $(OUTPUT),$(OUTPUT),.) \ > -I$(srctree)/tools/include/uapi/ \ > + -I$(srctree)/tools/include/ \ bpftool shouldn't rely on internal kernel headers for compilation. If you want to have TASK_COMM_LEN_16 constant for grep-ability, just #define it where appropriate > -I$(LIBBPF_PATH) \ > -I$(srctree)/tools/lib \ > -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@ > diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h > index 90caa42aac4c..5efa27188f68 100644 > --- a/tools/bpf/bpftool/main.h > +++ b/tools/bpf/bpftool/main.h > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > [...]