Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2541448rdb; Fri, 18 Aug 2023 03:41:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGiZ/Csr0MaOxDtXWcTNNuyLiLkACyKuev1O8gjwA8AYKCHynLpTfhapAoqOzAFGbdVlkn X-Received: by 2002:a17:906:8b:b0:988:6491:98e1 with SMTP id 11-20020a170906008b00b00988649198e1mr1753709ejc.42.1692355276649; Fri, 18 Aug 2023 03:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692355276; cv=none; d=google.com; s=arc-20160816; b=X7DeftAFR2AoHsmcpEMKQLhV/rrr1CZXVi1m+CvbR2Nu28wYj/g8VEribcNLuEbw9S u/9nRmW8axgdr+bIRD1z5nqBh1t4X291KcD2rRA14jLeu75YSaJFsLhjRlCQzbIDFbIt I9TT199bswbvutrsKQApJM/kzDfVricZ6C4IpYdKXe/2H/2TNuyONYxWXHHXAP9lwiWc ooFlD0mhsCTsqz/9WRaDHH9PUWLSzjWKXTdDedbdpRYDYkrTewR9cnPWrBk42lKM5aEf C/YUAi99XxhSoOVAvP+fMzkS/jD2Xe4CgfMHf/hhfjDjSSf4PJ4XyCwIMDwL/eC59Mal n93Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4UdRcJbzvMbKNgiXEXjZRcNJZvBGijPssoIyqGFaZhE=; fh=G3PlzF+XUvkHUqL6k16HyHUv4lLfJdSSN8q8ztENvks=; b=0FginT/sHDnYv0M0u+o0K/Bte+K/pDxe85fAcqR1J8KDbbmZknByNx2lJcA/1Yxims VCqJN8r8WoGvhbnTZwgFARyNCkt9ZcJD0QxGeGzrjQ0czKPD05q+NBjYAeMyELx8WciK WWbr3COWLaWsyUsosHxfF6arGvQgMMP16CdcGnm/pItV4jjw2z45d3okaiarhNeyKq0K vU3QgBXuWuhb17PaE9x0Ov4fBmODRgm3LLmzHoQT7z0YtG3JHHK9hd/lx6Fy6l6YcsJs YGjyTBVS2w0ED7H5nargfu7xNHsTIy4LBnHykef/vWt9ZMGx1q8lV2ZJJgfYKenr5HFg sa3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cOmd4JaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a1709066d0500b0098dfec24292si1183431ejr.829.2023.08.18.03.40.51; Fri, 18 Aug 2023 03:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cOmd4JaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245472AbjHPNXT (ORCPT + 99 others); Wed, 16 Aug 2023 09:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245494AbjHPNWu (ORCPT ); Wed, 16 Aug 2023 09:22:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A522D4A; Wed, 16 Aug 2023 06:22:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 58F8561F76; Wed, 16 Aug 2023 13:22:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E2B1C433C8; Wed, 16 Aug 2023 13:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692192138; bh=amUpVQjeWoSDfniN2IZ2yTaOcc0OwonZMQJboz3mWX0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cOmd4JaP5aVf90GKb8pydqb3saU1d7DRY3ptppWrcGic7IwfpPb8oV7mxHMA3Dawz BUoMmThR4BDqOrUBn3HqDTj/pIlfWeOoWIUPZ2qT38Vz+9Pyi6HvfEp+jTQEzcgLqW T4NEkQI01h/f63HsmpZQ0qXClo5gs5YiczUVOXiD6c+5tN7oIVKW9ZDHlkluwg50zu tJWrqDx4rC3pTngc3aJZPHy0yPnuthLb/bdGrBsMSPtvo3YvXyq6E4e4HHX+8Wu2Bt YRay3CvvdC0hteSL3bjx0uQyPakVpOrBdLhBA9gMjuE1RG1516HyT65nho1nbRghAE cgNH8lMLLN33g== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 50465404DF; Wed, 16 Aug 2023 10:22:15 -0300 (-03) Date: Wed, 16 Aug 2023 10:22:15 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , Tom Rix , Fangrui Song , Anshuman Khandual , Andi Kleen , Leo Yan , Madhavan Srinivasan , Carsten Haitzler , Ravi Bangoria , "Naveen N. Rao" , Athira Rajeev , Kan Liang , Yang Jihong , James Clark , Tiezhu Yang , Eduard Zingerman , Andrii Nakryiko , Yonghong Song , Rob Herring , LKML , linux-perf-users , bpf , llvm@lists.linux.dev, Wang Nan , Wang ShaoBo , YueHaibing , He Kuang , Brendan Gregg Subject: Re: [PATCH v1 2/4] perf trace: Migrate BPF augmentation to use a skeleton Message-ID: References: <20230810184853.2860737-1-irogers@google.com> <20230810184853.2860737-3-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Aug 16, 2023 at 10:11:11AM -0300, Arnaldo Carvalho de Melo escreveu: > Just taking notes about things to work on top of what is in > tmp.perf-tools-next, that will move to perf-tools-next soon: > > We need to make these libbpf error messages appear only in verbose mode, > and probably have a hint about unprivileged BPF, a quick attempt failed > after several attempts at getting privileges :-\ > > Probably attaching to tracepoints is off limits to !root even with > /proc/sys/kernel/unprivileged_bpf_disabled set to zero. yep, the libbpf sys_bpf call to check if it could load a basic BPF bytecode (prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2) succeeds, but then, later we manage to create the maps, etc to then stumble on bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PERCPU_ARRAY, key_size=4, value_size=8272, max_entries=1, map_flags=0, inner_map_fd=0, map_name="augmented_args_", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 7 bpf(BPF_BTF_LOAD, {btf="\237\353\1\0\30\0\0\0\0\0\0\0000\0\0\0000\0\0\0\t\0\0\0\1\0\0\0\0\0\0\1"..., btf_log_buf=NULL, btf_size=81, btf_log_size=0, btf_log_level=0}, 32) = -1 EPERM (Operation not permitted) and: bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=2, insns=0x1758340, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(6, 4, 7), prog_flags=0, prog_name="syscall_unaugme", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, fd_array=NULL}, 144) = -1 EPERM (Operation not permitted) So 'perf trace' should just not try to load the augmented_raw_syscalls BPF skel for !root. - Arnaldo [acme@quaco perf-tools-next]$ strace -e bpf perf trace -vv -e open* sleep 1 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffe95185300, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 116) = 3 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffe951854a0, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, fd_array=NULL}, 144) = 3 bpf(BPF_BTF_LOAD, {btf="\237\353\1\0\30\0\0\0\0\0\0\0\20\0\0\0\20\0\0\0\5\0\0\0\1\0\0\0\0\0\0\1"..., btf_log_buf=NULL, btf_size=45, btf_log_size=0, btf_log_level=0}, 32) = -1 EPERM (Operation not permitted) bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffe95185110, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="libbpf_nametest"}, 64) = 3 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_HASH, key_size=4, value_size=1, max_entries=64, map_flags=0, inner_map_fd=0, map_name="pids_filtered", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 3 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PROG_ARRAY, key_size=4, value_size=4, max_entries=512, map_flags=0, inner_map_fd=0, map_name="syscalls_sys_en", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 4 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PROG_ARRAY, key_size=4, value_size=4, max_entries=512, map_flags=0, inner_map_fd=0, map_name="syscalls_sys_ex", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 5 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PERF_EVENT_ARRAY, key_size=4, value_size=4, max_entries=4096, map_flags=0, inner_map_fd=0, map_name="__augmented_sys", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 6 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_PERCPU_ARRAY, key_size=4, value_size=8272, max_entries=1, map_flags=0, inner_map_fd=0, map_name="augmented_args_", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id=0, btf_vmlinux_value_type_id=0, map_extra=0}, 72) = 7 bpf(BPF_BTF_LOAD, {btf="\237\353\1\0\30\0\0\0\0\0\0\0000\0\0\0000\0\0\0\t\0\0\0\1\0\0\0\0\0\0\1"..., btf_log_buf=NULL, btf_size=81, btf_log_size=0, btf_log_level=0}, 32) = -1 EPERM (Operation not permitted) bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=2, insns=0x1758340, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(6, 4, 7), prog_flags=0, prog_name="syscall_unaugme", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, fd_array=NULL}, 144) = -1 EPERM (Operation not permitted) bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=2, insns=0x1758340, license="GPL", log_level=1, log_size=16777215, log_buf="", kern_version=KERNEL_VERSION(6, 4, 7), prog_flags=0, prog_name="syscall_unaugme", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, fd_array=NULL}, 144) = -1 EPERM (Operation not permitted) libbpf: prog 'syscall_unaugmented': BPF program load failed: Operation not permitted libbpf: prog 'syscall_unaugmented': failed to load: -1 libbpf: failed to load object 'augmented_raw_syscalls_bpf' libbpf: failed to load BPF skeleton 'augmented_raw_syscalls_bpf': -1 Failed to load augmented syscalls BPF skeleton: Operation not permitted Using CPUID GenuineIntel-6-8E-A intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch Error: No permissions to read /sys/kernel/tracing//events/raw_syscalls/sys_(enter|exit) Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/tracing/' +++ exited with 255 +++ [acme@quaco perf-tools-next]$